[Devel] [PATCH RH7 2/3] ms/xfrm: Fix warning in xfrm6_tunnel_net_exit.

Vasily Averin vvs at virtuozzo.com
Tue Jun 15 13:48:27 MSK 2021


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 at syzkaller.appspotmail.com
Signed-off-by: Steffen Klassert <steffen.klassert at secunet.com>
(cherry picked from ms commit b48c05ab5d32af2af4bc63851c153782d1c6ba42)
VvS: reworked to use old version of xfrm_state_flush() call
     also dropped creation of xfrm_flush_gc()
https://jira.sw.ru/browse/PSBM-130602
Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
---
 net/ipv6/xfrm6_tunnel.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
index 39ab6636d8ff..8a0138441cd4 100644
--- a/net/ipv6/xfrm6_tunnel.c
+++ b/net/ipv6/xfrm6_tunnel.c
@@ -342,8 +342,15 @@ static int __net_init xfrm6_tunnel_net_init(struct net *net)
 static void __net_exit xfrm6_tunnel_net_exit(struct net *net)
 {
 	struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net);
+	struct xfrm_audit audit_info;
 	unsigned int i;
 
+	audit_info.loginuid = INVALID_UID;
+	audit_info.sessionid = (unsigned int)-1;
+	audit_info.secid = 0;
+	xfrm_state_flush(net, IPSEC_PROTO_ANY, &audit_info);
+	flush_work(&net->xfrm.state_gc_work);
+
 	for (i = 0; i < XFRM6_TUNNEL_SPI_BYADDR_HSIZE; i++)
 		WARN_ON_ONCE(!hlist_empty(&xfrm6_tn->spi_byaddr[i]));
 
-- 
2.25.1



More information about the Devel mailing list