lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <BANLkTim9jfB1fNq23n9FG4VuJJawTXj-6g@mail.gmail.com>
Date:	Tue, 12 Apr 2011 10:09:12 +0100
From:	Stefan Hajnoczi <stefanha@...il.com>
To:	Takuma Umeya <tumeya@...hat.com>
Cc:	virtualization@...ts.linux-foundation.org,
	Stephen Hemminger <shemminger@...tta.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] virtio: decrement dev_index when device is unregistered

On Mon, Apr 11, 2011 at 10:11 AM, Takuma Umeya <tumeya@...hat.com> wrote:
> ----- Original Message -----
>> On Tue, Apr 5, 2011 at 5:49 AM, Takuma Umeya <tumeya@...hat.com>
>> wrote:
>> > When virtio device is removed, dev_index does not get decremented.
>> > The next device hotplug event results in consuming the next pci to
>> > the one that is suppose to be available.
>> >
>> > Signed-off-by: Takuma Umeya <tumeya@...hat.com>
>> >
>> > diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
>> > index efb35aa..67fe71d 100644
>> > --- a/drivers/virtio/virtio.c
>> > +++ b/drivers/virtio/virtio.c
>> > @@ -216,6 +216,7 @@ EXPORT_SYMBOL_GPL(register_virtio_device);
>> >  void unregister_virtio_device(struct virtio_device *dev)
>> >  {
>> >        device_unregister(&dev->dev);
>> > + dev_index--;
>>
>> I don't think there is any guarantee that virtio devices are
>> added/removed in first-in-last-out order.
>>
>> That means I could add a virtio-net device (index 0) followed by a
>> virtio-blk device (index 1). Now I remove the virtio-net device
>> (index 0) which causes me to decrement dev_index and hand index 1 out
>> again to the next device. This leaves us with virtio-blk (index 1)
>> and the new device with index 1, which is not unique.
>>
>> Perhaps I missed a constraint which prevents this from occurring?
> I believe the address is assigned up to 1f so using u32 value
> to track use/free. This should make the code immune to the scenario.
> Would this be adequate?

This issue was also brought up by Jens Axboe on your other patch for
virtio block devices.  He suggested using idr.  I think that would be
a nicer solution than a u32 bitfield.

I'm not sure where you got 0x1f from but that seems like an artifical
limitation.  Nothing should stop us from having more virtio devices.

Stefan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ