netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Jiri Pirko <jpirko@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>, David Miller <davem@davemloft.net>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	torvalds@linux-foundation.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: Fix spinlock use in alloc_netdev_mq()
Date: Wed, 5 Aug 2009 10:13:27 -0700	[thread overview]
Message-ID: <20090805101327.2c49cc62.akpm@linux-foundation.org> (raw)
In-Reply-To: <20090805084746.GA3897@psychotron.englab.brq.redhat.com>

On Wed, 5 Aug 2009 10:47:47 +0200 Jiri Pirko <jpirko@redhat.com> wrote:

> >it's using an zero-initialized spinlock. This is a side-effect of:
> >
> >        dev_unicast_init(dev);
> >
> >in alloc_netdev_mq() making use of dev->addr_list_lock.
> >
> >The device has just been allocated freshly, it's not accessible
> >anywhere yet so no locking is needed at all - in fact it's wrong
> >to lock it here (the lock isnt initialized yet).
> 
> Yes this looks like the right approach. Sorry for this bug :(

Really?

> >--- a/net/core/dev.c
> >+++ b/net/core/dev.c
> >@@ -4007,9 +4007,7 @@ static void dev_unicast_flush(struct net_device *dev)
> > 
> > static void dev_unicast_init(struct net_device *dev)
> > {
> >-	netif_addr_lock_bh(dev);
> > 	__hw_addr_init(&dev->uc);
> >-	netif_addr_unlock_bh(dev);
> > }

This means that the net_device is still floating around for quite a
long time with an uninitialised spinlock, so it will be quite easy for
the same problem to reoccur as the code evolves.

It would be more robust were we to initialise that lock close to the
netdev's allocation site.


  parent reply	other threads:[~2009-08-05 17:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-04 19:57 [GIT]: Networking David Miller
2009-08-05  7:02 ` Ingo Molnar
2009-08-05  7:14   ` Ingo Molnar
2009-08-05  7:16     ` [PATCH] net: Fix spinlock use in alloc_netdev_mq() Ingo Molnar
2009-08-05  8:47       ` Jiri Pirko
2009-08-05 15:37         ` David Miller
2009-08-05 17:13         ` Andrew Morton [this message]
2009-08-06  8:31           ` Jiri Pirko
2009-08-12 23:44             ` David Miller
2009-08-05  7:19     ` [GIT]: Networking Eric Dumazet

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=20090805101327.2c49cc62.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=davem@davemloft.net \
    --cc=jpirko@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=netdev@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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).