public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Tushar Behera <tushar.behera@linaro.org>,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-samsung-soc@vger.kernel.org, jslaby@suse.cz,
	ben.dooks@codethink.co.uk, broonie@kernel.org
Subject: Re: [PATCH 2/2] serial: pl011: Move uart_register_driver call to device probe
Date: Thu, 13 Feb 2014 16:14:36 -0800	[thread overview]
Message-ID: <20140214001436.GA16287@kroah.com> (raw)
In-Reply-To: <20140214000717.GG30257@n2100.arm.linux.org.uk>

On Fri, Feb 14, 2014 at 12:07:17AM +0000, Russell King - ARM Linux wrote:
> On Thu, Feb 13, 2014 at 03:26:06PM -0800, Greg KH wrote:
> > On Thu, Feb 13, 2014 at 06:42:49PM +0000, Russell King - ARM Linux wrote:
> > > We went through this before, and I stated the paths, and no one disagreed
> > > with that.
> > > 
> > > It /is/ racy.
> > 
> > Ok, I just went and looked at the uart driver register path, and I don't
> > see the race (note, if there is one, it's there today, regardless of
> > this patch).
> 
> The race isn't the uart code, it's the driver model.
> 
> Consider what happens when this happens:
> 
> * Two pl011 devices get registered at the same time by two different
>   threads.

How?  What two different busses will see this same device?  The amba bus
code should prevent that from happening, right?  If not, there's bigger
problems in that bus code :)

That's where this problem should be fixed, if there is one, otherwise
this same issue would be there for any type of driver that calles into
the uart core, right?

> * Both devices have a lock taken on the _device_ itself before matching
>   against the driver.
> 
> * Both devices get matched to the same driver.
> 
> * Both devices are passed into the driver's probe function.
> 
> * Both check uart_reg.state, both call uart_register_driver() on that
>   at the same time, which results in two allocations inside
>   uart_register_driver(), one gets overwritten...
> 
> So, the /only/ thing which stops this happening is that the devices
> are generally available before the driver is registered, and driver
> registration results in devices being probed serially.  Moreover, both
> attempt to call tty_register_driver()... one succeeds, the other fails.
> 
> However, what about the userspace bind/unbind methods.  Yes, userspace
> can ask the driver core to unbind devices from a driver or bind - and
> again, there's no per-driver locking here.  So, if you can trigger two
> concurrent binds from userspace, you hit the same race as above.
> 
> So, if you want to accept these patches, go ahead, introduce races, but
> personally I'd recommend plugging these races.

The only way to solve this would be to do it in the bus, I don't see
anything here that makes it any "racier" than it currently is.

thanks,

greg k-h

  reply	other threads:[~2014-02-14  0:13 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-20  9:02 [PATCH 0/2] serial: Move uart_register_driver call to device probe Tushar Behera
2014-01-20  9:02 ` [PATCH 1/2] serial: samsung: " Tushar Behera
2014-01-20 10:05   ` Russell King - ARM Linux
2014-01-20 11:53     ` Tushar Behera
2014-01-20 12:26       ` Russell King - ARM Linux
2014-01-20 21:43       ` Alan Cox
2014-01-20 23:14         ` Mark Brown
2014-01-20 23:21           ` Russell King - ARM Linux
2014-01-20 23:35             ` Alan Cox
2014-01-20 23:52               ` Greg Kroah-Hartman
2014-01-20 23:47           ` Alan Cox
2014-01-21  0:16             ` Russell King - ARM Linux
2014-01-21  9:03               ` Alan Cox
2014-01-21  9:49                 ` Russell King - ARM Linux
     [not found]               ` <50b66ac6-1150-4ad7-aeaf-3d0dce77334d@email.android.com>
2014-01-26 11:54                 ` Russell King - ARM Linux
2014-01-27  4:30                   ` Nicolas Pitre
2014-01-27 10:07                     ` Alan Cox
2014-01-27 12:32                     ` Russell King - ARM Linux
2014-01-27 15:03                       ` Nicolas Pitre
2014-01-21 16:59             ` Mark Brown
2014-01-21 18:30               ` Russell King - ARM Linux
2014-01-23 18:04       ` Alan Cox
2014-01-23 18:40         ` Mark Brown
2014-01-23 18:47           ` Tomasz Figa
2014-01-23 19:36             ` Mark Brown
2014-01-23 19:51               ` Alan Cox
2014-01-23 20:05                 ` Mark Brown
2014-01-23 21:33                   ` Alan Cox
2014-01-24 12:03                     ` Mark Brown
2014-01-24 14:38                       ` Alan Cox
2014-01-27  0:15                         ` Mark Brown
2014-01-26 21:09               ` Pavel Machek
2014-01-27  0:04                 ` Alan Cox
2014-01-20 21:16     ` Greg KH
2014-01-20 21:32       ` Russell King - ARM Linux
2014-01-20 23:11         ` Greg KH
2014-01-20 23:16           ` Russell King - ARM Linux
2014-01-20 23:51             ` Greg KH
2014-01-21  0:07               ` Russell King - ARM Linux
2014-01-21  0:26                 ` Greg KH
2014-01-21  0:38                   ` Russell King - ARM Linux
2014-01-21  9:25                     ` One Thousand Gnomes
2014-01-21  9:45                       ` Russell King - ARM Linux
2014-01-20  9:02 ` [PATCH 2/2] serial: pl011: " Tushar Behera
2014-01-20 10:04   ` Russell King - ARM Linux
2014-02-13 18:12     ` Greg KH
2014-02-13 18:15       ` Russell King - ARM Linux
2014-02-13 18:27         ` Greg KH
2014-02-13 18:42           ` Russell King - ARM Linux
2014-02-13 23:26             ` Greg KH
2014-02-14  0:07               ` Russell King - ARM Linux
2014-02-14  0:14                 ` Greg KH [this message]
2014-02-14  0:38                   ` Russell King - ARM Linux
2014-02-17 15:35                     ` One Thousand Gnomes
2014-02-17 15:54                       ` One Thousand Gnomes
2014-02-17 23:50                       ` Mark Brown
2014-02-18 10:09                         ` Etched Pixels
2014-02-19 13:57                           ` Mark Brown
2014-02-19 14:47                             ` One Thousand Gnomes
2014-02-19 15:53                               ` Mark Brown
2014-02-19  0:47                   ` One Thousand Gnomes

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=20140214001436.GA16287@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=ben.dooks@codethink.co.uk \
    --cc=broonie@kernel.org \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=tushar.behera@linaro.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