* [PATCH] virtio_blk: fix race at module removal
@ 2014-10-23 16:12 Michael S. Tsirkin
2014-10-24 2:13 ` Ming Lei
0 siblings, 1 reply; 3+ messages in thread
From: Michael S. Tsirkin @ 2014-10-23 16:12 UTC (permalink / raw)
To: linux-kernel; +Cc: Rusty Russell, virtualization
If a device appears while module is being removed,
driver will get a callback after we've given up
on the major number.
In theory this means this major number can get reused
by something else, resulting in a conflict.
To fix, cleanup in reverse order of initialization.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
drivers/block/virtio_blk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 56aadbc..adfba9f 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -883,8 +883,8 @@ out_destroy_workqueue:
static void __exit fini(void)
{
- unregister_blkdev(major, "virtblk");
unregister_virtio_driver(&virtio_blk);
+ unregister_blkdev(major, "virtblk");
destroy_workqueue(virtblk_wq);
}
module_init(init);
--
MST
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] virtio_blk: fix race at module removal
2014-10-23 16:12 [PATCH] virtio_blk: fix race at module removal Michael S. Tsirkin
@ 2014-10-24 2:13 ` Ming Lei
2014-10-28 0:25 ` Rusty Russell
0 siblings, 1 reply; 3+ messages in thread
From: Ming Lei @ 2014-10-24 2:13 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Linux Kernel Mailing List, Rusty Russell, Linux Virtualization
On Fri, Oct 24, 2014 at 12:12 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
> If a device appears while module is being removed,
> driver will get a callback after we've given up
> on the major number.
>
> In theory this means this major number can get reused
> by something else, resulting in a conflict.
Yes, there is a tiny race window.
>
> To fix, cleanup in reverse order of initialization.
Reviewed-by: Ming Lei <ming.lei@canonical.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> drivers/block/virtio_blk.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index 56aadbc..adfba9f 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -883,8 +883,8 @@ out_destroy_workqueue:
>
> static void __exit fini(void)
> {
> - unregister_blkdev(major, "virtblk");
> unregister_virtio_driver(&virtio_blk);
> + unregister_blkdev(major, "virtblk");
> destroy_workqueue(virtblk_wq);
> }
> module_init(init);
Thanks,
--
Ming Lei
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] virtio_blk: fix race at module removal
2014-10-24 2:13 ` Ming Lei
@ 2014-10-28 0:25 ` Rusty Russell
0 siblings, 0 replies; 3+ messages in thread
From: Rusty Russell @ 2014-10-28 0:25 UTC (permalink / raw)
To: Ming Lei, Michael S. Tsirkin
Cc: Linux Kernel Mailing List, Linux Virtualization
Ming Lei <tom.leiming@gmail.com> writes:
> On Fri, Oct 24, 2014 at 12:12 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
>> If a device appears while module is being removed,
>> driver will get a callback after we've given up
>> on the major number.
>>
>> In theory this means this major number can get reused
>> by something else, resulting in a conflict.
>
> Yes, there is a tiny race window.
Applied.
Thanks,
Rusty.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-10-28 0:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-23 16:12 [PATCH] virtio_blk: fix race at module removal Michael S. Tsirkin
2014-10-24 2:13 ` Ming Lei
2014-10-28 0:25 ` Rusty Russell
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).