lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 23 Apr 2024 21:53:45 +0200
From: Eric Dumazet <edumazet@...gle.com>
To: Breno Leitao <leitao@...ian.org>
Cc: Florian Westphal <fw@...len.de>, netdev@...r.kernel.org, Paolo Abeni <pabeni@...hat.com>, 
	"David S. Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>
Subject: Re: [PATCH net-next] ip6_vti: fix memleak on netns dismantle

On Tue, Apr 23, 2024 at 11:46 AM Breno Leitao <leitao@...ian.org> wrote:
>
> Hello Florian,
>
> On Mon, Apr 15, 2024 at 02:23:44PM +0200, Florian Westphal wrote:
> > kmemleak reports net_device resources are no longer released, restore
> > needs_free_netdev toggle.  Sample backtrace:
> >
> > unreferenced object 0xffff88810874f000 (size 4096): [..]
> >     [<00000000a2b8af8b>] __kmalloc_node+0x209/0x290
> >     [<0000000040b0a1a9>] alloc_netdev_mqs+0x58/0x470
> >     [<00000000b4be1e78>] vti6_init_net+0x94/0x230
> >     [<000000008830c1ea>] ops_init+0x32/0xc0
> >     [<000000006a26fa8f>] setup_net+0x134/0x2e0
> > [..]
> >
> > Cc: Breno Leitao <leitao@...ian.org>
> > Fixes: a9b2d55a8f1e ("ip6_vti: Do not use custom stat allocator")
> > Signed-off-by: Florian Westphal <fw@...len.de>
> > ---
> >  net/ipv6/ip6_vti.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
> > index 4d68a0777b0c..78344cf3867e 100644
> > --- a/net/ipv6/ip6_vti.c
> > +++ b/net/ipv6/ip6_vti.c
> > @@ -901,6 +901,7 @@ static void vti6_dev_setup(struct net_device *dev)
> >  {
> >       dev->netdev_ops = &vti6_netdev_ops;
> >       dev->header_ops = &ip_tunnel_header_ops;
> > +     dev->needs_free_netdev = true;
>
> Thanks for the fix!
>
> Could you help me to understand how needs_free_netdev will trigger the
> free()here?
>
> I _though_ that any device that is being unregistered would have the stats
> freed.
>
> This is the flow I am reading:
>
> 1) When the device is unregistered, then it is marked as todo:
>
>         unregister_netdevice_many_notify() {
>                 list_for_each_entry(dev, head, unreg_list) {
>                         net_set_todo(dev);
>                 }
>         }
>
> 2) Then, "run_todo" will run later, and it does:
>         netdev_run_todo() {
>                 list_for_each_entry_safe(dev, tmp, &list, todo_list) {
>                 if (unlikely(dev->reg_state != NETREG_UNREGISTERING)) {
>                         netdev_WARN(dev, "run_todo but not unregistering\n");
>                         list_del(&dev->todo_list);
>                         continue;
>                 }
>
>                 while (!list_empty(&list)) {
>                         netdev_do_free_pcpu_stats(dev);

The relevant part is missing:

                         if (dev->needs_free_netdev)
                                  free_netdev(dev);

>                 }
>
>         }
>
> Thank you!

I do not think Florian patch has anything to do with free_pcpu_stats()

Please take a look at

git show cf124db566e -- net/ipv6/ip6_vti.c

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ