]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
xfrm: flush all states in xfrm_state_fini
authorSabrina Dubroca <sd@queasysnail.net>
Mon, 4 Aug 2025 09:05:43 +0000 (11:05 +0200)
committerSteffen Klassert <steffen.klassert@secunet.com>
Wed, 6 Aug 2025 07:23:38 +0000 (09:23 +0200)
While reverting commit f75a2804da39 ("xfrm: destroy xfrm_state
synchronously on net exit path"), I incorrectly changed
xfrm_state_flush's "proto" argument back to IPSEC_PROTO_ANY. This
reverts some of the changes in commit dbb2483b2a46 ("xfrm: clean up
xfrm protocol checks"), and leads to some states not being removed
when we exit the netns.

Pass 0 instead of IPSEC_PROTO_ANY from both xfrm_state_fini
xfrm6_tunnel_net_exit, so that xfrm_state_flush deletes all states.

Fixes: 2a198bbec691 ("Revert "xfrm: destroy xfrm_state synchronously on net exit path"")
Reported-by: syzbot+6641a61fe0e2e89ae8c5@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=6641a61fe0e2e89ae8c5
Tested-by: syzbot+6641a61fe0e2e89ae8c5@syzkaller.appspotmail.com
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/ipv6/xfrm6_tunnel.c
net/xfrm/xfrm_state.c

index 5120a763da0d95d6eb1f4a839b05bd60f9584c8f..0a0eeaed05910158a275533d80b92060cdcd17fa 100644 (file)
@@ -334,7 +334,7 @@ static void __net_exit xfrm6_tunnel_net_exit(struct net *net)
        struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net);
        unsigned int i;
 
-       xfrm_state_flush(net, IPSEC_PROTO_ANY, false);
+       xfrm_state_flush(net, 0, false);
        xfrm_flush_gc();
 
        for (i = 0; i < XFRM6_TUNNEL_SPI_BYADDR_HSIZE; i++)
index 77db3b5fe4acacc9b113c4e6cd71ca05673eb63f..78fcbb89cf3256cbbe56bc40d4d2cabecb09bf28 100644 (file)
@@ -3297,7 +3297,7 @@ void xfrm_state_fini(struct net *net)
        unsigned int sz;
 
        flush_work(&net->xfrm.state_hash_work);
-       xfrm_state_flush(net, IPSEC_PROTO_ANY, false);
+       xfrm_state_flush(net, 0, false);
        flush_work(&xfrm_state_gc_work);
 
        WARN_ON(!list_empty(&net->xfrm.state_all));