public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Kay Sievers <kay@vrfy.org>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartmann <gregkh@linuxfoundation.org>,
	Stable Kernel <stable@kernel.org>
Subject: Re: [PATCH] driver core: check 'start' argument in bus iterators
Date: Mon, 16 Apr 2012 14:10:23 +0200	[thread overview]
Message-ID: <4F8C0C2F.7020306@suse.de> (raw)
In-Reply-To: <CAPXgP11S6R4L-8tZ4cPY=MZfcvTBBHkUdTvt7FTKhvhVF6uKPQ@mail.gmail.com>

On 04/16/2012 01:51 PM, Kay Sievers wrote:
> On Mon, Apr 16, 2012 at 12:48, Hannes Reinecke <hare@suse.de> wrote:
>> bus_for_each_dev() and bus_find_device() both take a 'start'
>> argument to start the iteration at a specific list entry.
>> However, this list entry might already been detached by
>> the time these functions are called.
>> So we need to check if the arguments are still valid.
> 
>> +       if (start && !klist_node_attached(&start->p->knode_bus))
>> +               return -ENODEV;
>> +
>>        klist_iter_init_node(&bus->p->klist_devices, &i,
>>                             (start ? &start->p->knode_bus : NULL));
> 
> Shouldn't we do this check in klist_iter_init_node()?
> After a kref_get(), and return -ENODEV from there if the node it as
> asked to start is gone?
> 
Sure, if you prefer.

> This check otherwise still has the window between the check and the
> use of it, only very unlikely to hit now, hasn't it?
> 
yeah, very.
The iteration itself could take some time (locks etc), but the race
between those two lines is really tiny.

But yeah, for the sake of correctness, we should.

I'll be sending an updated patch.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

      reply	other threads:[~2012-04-16 12:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-16 10:48 [PATCH] driver core: check 'start' argument in bus iterators Hannes Reinecke
2012-04-16 11:51 ` Kay Sievers
2012-04-16 12:10   ` Hannes Reinecke [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=4F8C0C2F.7020306@suse.de \
    --to=hare@suse.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=kay@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@kernel.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