Skip to content

Commit 42e4256

Browse files
qsnklassert
authored andcommitted
xfrm: flush all states in xfrm_state_fini
While reverting commit f75a280 ("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 dbb2483 ("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: 2a198bb ("Revert "xfrm: destroy xfrm_state synchronously on net exit path"") Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=6641a61fe0e2e89ae8c5 Tested-by: [email protected] Signed-off-by: Sabrina Dubroca <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent d942fe1 commit 42e4256

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

net/ipv6/xfrm6_tunnel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ static void __net_exit xfrm6_tunnel_net_exit(struct net *net)
334334
struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net);
335335
unsigned int i;
336336

337-
xfrm_state_flush(net, IPSEC_PROTO_ANY, false);
337+
xfrm_state_flush(net, 0, false);
338338
xfrm_flush_gc();
339339

340340
for (i = 0; i < XFRM6_TUNNEL_SPI_BYADDR_HSIZE; i++)

net/xfrm/xfrm_state.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3297,7 +3297,7 @@ void xfrm_state_fini(struct net *net)
32973297
unsigned int sz;
32983298

32993299
flush_work(&net->xfrm.state_hash_work);
3300-
xfrm_state_flush(net, IPSEC_PROTO_ANY, false);
3300+
xfrm_state_flush(net, 0, false);
33013301
flush_work(&xfrm_state_gc_work);
33023302

33033303
WARN_ON(!list_empty(&net->xfrm.state_all));

0 commit comments

Comments
 (0)