Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xfrm: Fix warning in xfrm6_tunnel_net_exit.

We need to make sure that all states are really deleted
before we check that the state lists are empty. Otherwise
we trigger a warning.

Fixes: baeb0dbbb5659 ("xfrm6_tunnel: exit_net cleanup check added")
Reported-and-tested-by:syzbot+777bf170a89e7b326405@syzkaller.appspotmail.com
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>

+10
+1
include/net/xfrm.h
··· 375 375 int xfrm_input_register_afinfo(const struct xfrm_input_afinfo *afinfo); 376 376 int xfrm_input_unregister_afinfo(const struct xfrm_input_afinfo *afinfo); 377 377 378 + void xfrm_flush_gc(void); 378 379 void xfrm_state_delete_tunnel(struct xfrm_state *x); 379 380 380 381 struct xfrm_type {
+3
net/ipv6/xfrm6_tunnel.c
··· 341 341 struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); 342 342 unsigned int i; 343 343 344 + xfrm_state_flush(net, IPSEC_PROTO_ANY, false); 345 + xfrm_flush_gc(); 346 + 344 347 for (i = 0; i < XFRM6_TUNNEL_SPI_BYADDR_HSIZE; i++) 345 348 WARN_ON_ONCE(!hlist_empty(&xfrm6_tn->spi_byaddr[i])); 346 349
+6
net/xfrm/xfrm_state.c
··· 2175 2175 return afinfo; 2176 2176 } 2177 2177 2178 + void xfrm_flush_gc(void) 2179 + { 2180 + flush_work(&xfrm_state_gc_work); 2181 + } 2182 + EXPORT_SYMBOL(xfrm_flush_gc); 2183 + 2178 2184 /* Temporarily located here until net/xfrm/xfrm_tunnel.c is created */ 2179 2185 void xfrm_state_delete_tunnel(struct xfrm_state *x) 2180 2186 {