Skip to content

Commit 41df65c

Browse files
qsnUlrich Hecht
authored andcommitted
xfrm: flush all states in xfrm_state_fini
[ Upstream commit 42e42562c9cfcdacf000f1b42284a4fad24f8546 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Ulrich Hecht <uli@kernel.org>
1 parent 3f6e24f commit 41df65c

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

net/ipv6/xfrm6_tunnel.c

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

347-
xfrm_state_flush(net, IPSEC_PROTO_ANY, false);
347+
xfrm_state_flush(net, 0, false);
348348
xfrm_flush_gc();
349349

350350
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
@@ -2421,7 +2421,7 @@ void xfrm_state_fini(struct net *net)
24212421
unsigned int sz;
24222422

24232423
flush_work(&net->xfrm.state_hash_work);
2424-
xfrm_state_flush(net, IPSEC_PROTO_ANY, false);
2424+
xfrm_state_flush(net, 0, false);
24252425
flush_work(&xfrm_state_gc_work);
24262426

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

0 commit comments

Comments
 (0)