Skip to content

Commit 9593c7c

Browse files
igsilyaPaolo Abeni
authored andcommitted
ipv6: tcp: add a missing nf_reset_ct() in 3WHS handling
Commit b0e214d ("netfilter: keep conntrack reference until IPsecv6 policy checks are done") is a direct copy of the old commit b59c270 ("[NETFILTER]: Keep conntrack reference until IPsec policy checks are done") but for IPv6. However, it also copies a bug that this old commit had. That is: when the third packet of 3WHS connection establishment contains payload, it is added into socket receive queue without the XFRM check and the drop of connection tracking context. That leads to nf_conntrack module being impossible to unload as it waits for all the conntrack references to be dropped while the packet release is deferred in per-cpu cache indefinitely, if not consumed by the application. The issue for IPv4 was fixed in commit 6f0012e ("tcp: add a missing nf_reset_ct() in 3WHS handling") by adding a missing XFRM check and correctly dropping the conntrack context. However, the issue was introduced to IPv6 code afterwards. Fixing it the same way for IPv6 now. Fixes: b0e214d ("netfilter: keep conntrack reference until IPsecv6 policy checks are done") Link: https://lore.kernel.org/netdev/[email protected]/ Signed-off-by: Ilya Maximets <[email protected]> Acked-by: Florian Westphal <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 4b2b606 commit 9593c7c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

net/ipv6/tcp_ipv6.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,9 +1640,12 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
16401640
struct sock *nsk;
16411641

16421642
sk = req->rsk_listener;
1643-
drop_reason = tcp_inbound_md5_hash(sk, skb,
1644-
&hdr->saddr, &hdr->daddr,
1645-
AF_INET6, dif, sdif);
1643+
if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
1644+
drop_reason = SKB_DROP_REASON_XFRM_POLICY;
1645+
else
1646+
drop_reason = tcp_inbound_md5_hash(sk, skb,
1647+
&hdr->saddr, &hdr->daddr,
1648+
AF_INET6, dif, sdif);
16461649
if (drop_reason) {
16471650
sk_drops_add(sk, skb);
16481651
reqsk_put(req);
@@ -1689,6 +1692,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
16891692
}
16901693
goto discard_and_relse;
16911694
}
1695+
nf_reset_ct(skb);
16921696
if (nsk == sk) {
16931697
reqsk_put(req);
16941698
tcp_v6_restore_cb(skb);

0 commit comments

Comments
 (0)