Netdev List
 help / color / mirror / Atom feed
From: Toshiaki Makita <toshiaki.makita1@gmail.com>
To: Yang Yingliang <yangyingliang@huawei.com>, netdev@vger.kernel.org
Cc: davem@davemloft.net
Subject: Re: [PATCH] veth: fix memleak in veth_newlink()
Date: Tue, 24 Nov 2020 11:18:50 +0900	[thread overview]
Message-ID: <560f4040-e6a4-5745-050b-4628deecb070@gmail.com> (raw)
In-Reply-To: <20201120093057.1477009-1-yangyingliang@huawei.com>

On 2020/11/20 18:30, Yang Yingliang wrote:

Hi,

> I got a memleak report when doing fault-inject test:
> 
> unreferenced object 0xffff88810ace9000 (size 1024):
>    comm "ip", pid 4622, jiffies 4295457037 (age 43.378s)
>    hex dump (first 32 bytes):
>      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>    backtrace:
>      [<00000000008abe41>] __kmalloc+0x10f/0x210
>      [<000000005d3533a6>] veth_dev_init+0x140/0x310
>      [<0000000088353c64>] register_netdevice+0x496/0x7a0
>      [<000000001324d322>] veth_newlink+0x40b/0x960
>      [<00000000d0799866>] __rtnl_newlink+0xd8c/0x1360
>      [<00000000d616040a>] rtnl_newlink+0x6b/0xa0
>      [<00000000e0a1600d>] rtnetlink_rcv_msg+0x3cc/0x9e0
>      [<000000009eeff98b>] netlink_rcv_skb+0x130/0x3a0
>      [<00000000500f8be1>] netlink_unicast+0x4da/0x700
>      [<00000000666c03b3>] netlink_sendmsg+0x7fe/0xcb0
>      [<0000000073b28103>] sock_sendmsg+0x143/0x180
>      [<00000000ad746a30>] ____sys_sendmsg+0x677/0x810
>      [<0000000087dd98e5>] ___sys_sendmsg+0x105/0x180
>      [<00000000028dd365>] __sys_sendmsg+0xf0/0x1c0
>      [<00000000a6bfbae6>] do_syscall_64+0x33/0x40
>      [<00000000e00521b4>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
> 
> If call_netdevice_notifiers() failed in register_netdevice(),
> dev->priv_destructor() is not called, it will cause memleak.
> Fix this by assigning ndo_uninit with veth_dev_free(), so
> the memory can be freed in rollback_registered();

We have discussed this before and it seems we should fix
register_netdevice() rather than each driver.

https://patchwork.ozlabs.org/project/netdev/patch/20200830131336.275844-1-rkovhaev@gmail.com/

Toshiaki Makita

      reply	other threads:[~2020-11-24  2:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-20  9:30 [PATCH] veth: fix memleak in veth_newlink() Yang Yingliang
2020-11-24  2:18 ` Toshiaki Makita [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=560f4040-e6a4-5745-050b-4628deecb070@gmail.com \
    --to=toshiaki.makita1@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=yangyingliang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox