Skip to content

Commit c2efc49

Browse files
101010zylgregkh
authored andcommitted
ipv6: xfrm6: release dst on error in xfrm6_rcv_encap()
commit bc0fcb9 upstream. xfrm6_rcv_encap() performs an IPv6 route lookup when the skb does not already have a dst attached. ip6_route_input_lookup() returns a referenced dst entry even when the lookup resolves to an error route. If dst->error is set, xfrm6_rcv_encap() drops the skb without attaching the dst to the skb and without releasing the reference returned by the lookup. Repeated packets hitting this path therefore leak dst entries. Release the dst before jumping to the drop path. Fixes: 0146dca ("xfrm: add support for UDPv6 encapsulation of ESP") Cc: stable@kernel.org Reported-by: Yifan Wu <yifanwucs@gmail.com> Reported-by: Juefei Pu <tomapufckgml@gmail.com> Co-developed-by: Yuan Tan <yuantan098@gmail.com> Signed-off-by: Yuan Tan <yuantan098@gmail.com> Suggested-by: Xin Liu <bird@lzu.edu.cn> Tested-by: Ruide Cao <caoruide123@gmail.com> Signed-off-by: Yilin Zhu <zylzyl2333@gmail.com> Signed-off-by: Ren Wei <n05ec@lzu.edu.cn> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3bf4e93 commit c2efc49

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

net/ipv6/xfrm6_protocol.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ int xfrm6_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi,
8888

8989
dst = ip6_route_input_lookup(dev_net(skb->dev), skb->dev, &fl6,
9090
skb, flags);
91-
if (dst->error)
91+
if (dst->error) {
92+
dst_release(dst);
9293
goto drop;
94+
}
9395
skb_dst_set(skb, dst);
9496
}
9597

0 commit comments

Comments
 (0)