[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Zjn2tNTJF-sq1Aoe@Laptop-X1>
Date: Tue, 7 May 2024 17:39:00 +0800
From: Hangbin Liu <liuhangbin@...il.com>
To: Sabrina Dubroca <sd@...asysnail.net>
Cc: netdev@...r.kernel.org, "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>,
Guillaume Nault <gnault@...hat.com>
Subject: Re: [PATCH net] ipv6: sr: fix invalid unregister error path
On Tue, May 07, 2024 at 11:14:45AM +0200, Sabrina Dubroca wrote:
> 2024-05-07, 16:11:00 +0800, Hangbin Liu wrote:
> > 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>
> > ---
> > net/ipv6/seg6.c | 5 ++---
> > 1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c
> > index 35508abd76f4..3c5ccc52d0e1 100644
> > --- a/net/ipv6/seg6.c
> > +++ b/net/ipv6/seg6.c
> > @@ -549,10 +549,8 @@ int __init seg6_init(void)
> > seg6_iptunnel_exit();
> > #endif
> > #endif
> > -#ifdef CONFIG_IPV6_SEG6_LWTUNNEL
> > out_unregister_genl:
> > genl_unregister_family(&seg6_genl_family);
>
> That label will be defined but unused for !CONFIG_IPV6_SEG6_LWTUNNEL.
Ah, yes, I will add the CONFIG_IPV6_SEG6_LWTUNNEL definition in v2.
diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c
index 3c5ccc52d0e1..6a80d93399ce 100644
--- a/net/ipv6/seg6.c
+++ b/net/ipv6/seg6.c
@@ -549,7 +549,9 @@ int __init seg6_init(void)
seg6_iptunnel_exit();
#endif
#endif
+#ifdef CONFIG_IPV6_SEG6_LWTUNNEL
out_unregister_genl:
+#endif
genl_unregister_family(&seg6_genl_family);
out_unregister_pernet:
unregister_pernet_subsys(&ip6_segments_ops);
Thanks
Hangbin
Powered by blists - more mailing lists