netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "wanghai (M)" <wanghai26@huawei.com>,
	syzbot <syzbot+6024817a931b2830bc93@syzkaller.appspotmail.com>,
	alexander.h.duyck@intel.com, amritha.nambiar@intel.com,
	davem@davemloft.net, f.fainelli@gmail.com, idosch@mellanox.com,
	joe@perches.com, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, stephen@networkplumber.org,
	syzkaller-bugs@googlegroups.com, tyhicks@canonical.com,
	yuehaibing@huawei.com
Subject: Re: kernel BUG at net/core/net-sysfs.c:LINE!
Date: Mon, 25 Mar 2019 11:55:54 -0700	[thread overview]
Message-ID: <20190325185554.GA97916@dtor-ws> (raw)
In-Reply-To: <20190325161031.GH9224@smile.fi.intel.com>

On Mon, Mar 25, 2019 at 06:10:31PM +0200, Andy Shevchenko wrote:
> On Mon, Mar 25, 2019 at 11:20:01PM +0800, wanghai (M) wrote:
> > thanks , Can it be fixed like this?
> 
> I dunno. I think no, it can't.

I agree, it can't.

> 
> As far as I can see the issue happened due to freeing entire network device at
> the point of putting reference count to the device (struct device is embedded
> into struct net_device).
> 
> When it happens the access to _any_ field of struct net_device will crash the
> system.
> 
> Basically it means that put_device() should be carefully placed case-by-case,
> because on real hardware the actual device is parent and usually no-one does
> access to the child without need. On the contrary the tunX devices are
> artificial and are controlled by the network stack.
> 
> So, it means we need to do something like
> 
> ret = register_netdev(...);
> if (ret) {
> 	put_device(&ndev->dev);
> 	...
> }
> 
> But as I mentioned, it would be tricky to not break something else.

I'd say that the entity that called alloc_netdev() should be the one
that calls put_device() (but the way of free_netdev()), not net/core
code. Do we have a driver that is messed up and does not do proper
cleanup?

Thanks.

-- 
Dmitry

  reply	other threads:[~2019-03-25 18:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-23  7:32 kernel BUG at net/core/net-sysfs.c:LINE! syzbot
2019-03-23 17:16 ` Andy Shevchenko
2019-03-25 15:20   ` wanghai (M)
2019-03-25 16:10     ` Andy Shevchenko
2019-03-25 18:55       ` Dmitry Torokhov [this message]
2019-03-25 19:18         ` Dmitry Torokhov
2019-04-04  3:19 ` wanghai (M)
2019-04-04  3:53   ` Eric Dumazet
2019-04-05  2:55   ` Al Viro

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=20190325185554.GA97916@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=alexander.h.duyck@intel.com \
    --cc=amritha.nambiar@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=idosch@mellanox.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=syzbot+6024817a931b2830bc93@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tyhicks@canonical.com \
    --cc=wanghai26@huawei.com \
    --cc=yuehaibing@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;
as well as URLs for NNTP newsgroup(s).