[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240508025502.3928296-1-liuhangbin@gmail.com>
Date: Wed, 8 May 2024 10:55:02 +0800
From: Hangbin Liu <liuhangbin@...il.com>
To: netdev@...r.kernel.org
Cc: "David S. Miller" <davem@...emloft.net>,
David Ahern <dsahern@...nel.org>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Vasiliy Kovalev <kovalev@...linux.org>,
Sabrina Dubroca <sd@...asysnail.net>,
Hangbin Liu <liuhangbin@...il.com>,
Guillaume Nault <gnault@...hat.com>
Subject: [PATCHv2 net] ipv6: sr: fix invalid unregister error path
The error path of seg6_init() is wrong in case CONFIG_IPV6_SEG6_LWTUNNEL
is not defined. In that case if seg6_hmac_init() fails, the
genl_unregister_family() isn't called.
At the same time, add seg6_local_exit() and fix the genl unregister order
in seg6_exit().
Fixes: 5559cea2d5aa ("ipv6: sr: fix possible use-after-free and null-ptr-deref")
Reported-by: Guillaume Nault <gnault@...hat.com>
Signed-off-by: Hangbin Liu <liuhangbin@...il.com>
---
v2: define label out_unregister_genl in CONFIG_IPV6_SEG6_LWTUNNEL(Sabrina Dubroca)
---
net/ipv6/seg6.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c
index 35508abd76f4..6a80d93399ce 100644
--- a/net/ipv6/seg6.c
+++ b/net/ipv6/seg6.c
@@ -551,8 +551,8 @@ int __init seg6_init(void)
#endif
#ifdef CONFIG_IPV6_SEG6_LWTUNNEL
out_unregister_genl:
- genl_unregister_family(&seg6_genl_family);
#endif
+ genl_unregister_family(&seg6_genl_family);
out_unregister_pernet:
unregister_pernet_subsys(&ip6_segments_ops);
goto out;
@@ -564,8 +564,9 @@ void seg6_exit(void)
seg6_hmac_exit();
#endif
#ifdef CONFIG_IPV6_SEG6_LWTUNNEL
+ seg6_local_exit();
seg6_iptunnel_exit();
#endif
- unregister_pernet_subsys(&ip6_segments_ops);
genl_unregister_family(&seg6_genl_family);
+ unregister_pernet_subsys(&ip6_segments_ops);
}
--
2.43.0
Powered by blists - more mailing lists