All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] loop: Do not call loop_unplug for not configured loop device.
@ 2008-12-12 13:46 Milan Broz
  2008-12-12 13:51 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Milan Broz @ 2008-12-12 13:46 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Linux Kernel Mailing List, Andrew Morton, Alasdair G Kergon

Do not call loop_unplug for not configured loop device.

In loop_unplug() function is expected that mapping is set
and lo->lo_backing_file is not NULL.

Unfortunately loop_set_fd() set the request queue unplug function,
but loop_clr_fd() doesn't clear that.

Loop device allows open of non-configured loop in some situations.
If the unplug on request queue is called, loop module oopses because
of missing lo_backing_file.

Simple reproducer:
	losetup /dev/loop0 /xxx
	losetup -d /dev/loop0
	dmsetup create x --table "0 1 linear /dev/loop0 0"

 EIP is at loop_unplug+0x1d/0x3b
 ...
  Call Trace:
   blk_unplug+0x57/0x5e
   dm_table_unplug_all+0x34/0x77 [dm_mod]
   destroy_inode+0x27/0x38
   generic_delete_inode+0xd5/0xd9
   iput+0x4b/0x4e
   dm_resume+0xca/0xfe [dm_mod]
   dev_suspend+0x143/0x165 [dm_mod]
   dm_ctl_ioctl+0x18e/0x1cf [dm_mod]
   dev_suspend+0x0/0x165 [dm_mod]
   dm_ctl_ioctl+0x0/0x1cf [dm_mod]
   vfs_ioctl+0x22/0x69
   do_vfs_ioctl+0x39d/0x3c7
   trace_hardirqs_on+0xb/0xd
   remove_vma+0x50/0x56
   do_munmap+0x21c/0x237
   sys_ioctl+0x2c/0x45
   sysenter_do_call+0x12/0x31

Several reports here
http://www.kerneloops.org/search.php?search=loop_unplug

Fix it by simply clear unplug function together with
removing of backing file.

Signed-off-by: Milan Broz <mbroz@redhat.com>
---
 drivers/block/loop.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 90d19df..1e4b41e 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -919,6 +919,7 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
 
 	kthread_stop(lo->lo_thread);
 
+	lo->lo_queue->unplug_fn = NULL;
 	lo->lo_backing_file = NULL;
 
 	loop_release_xfer(lo);



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] loop: Do not call loop_unplug for not configured loop device.
  2008-12-12 13:46 [PATCH] loop: Do not call loop_unplug for not configured loop device Milan Broz
@ 2008-12-12 13:51 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2008-12-12 13:51 UTC (permalink / raw)
  To: Milan Broz; +Cc: Linux Kernel Mailing List, Andrew Morton, Alasdair G Kergon

On Fri, Dec 12 2008, Milan Broz wrote:
> Do not call loop_unplug for not configured loop device.
> 
> In loop_unplug() function is expected that mapping is set
> and lo->lo_backing_file is not NULL.
> 
> Unfortunately loop_set_fd() set the request queue unplug function,
> but loop_clr_fd() doesn't clear that.
> 
> Loop device allows open of non-configured loop in some situations.
> If the unplug on request queue is called, loop module oopses because
> of missing lo_backing_file.
> 
> Simple reproducer:
> 	losetup /dev/loop0 /xxx
> 	losetup -d /dev/loop0
> 	dmsetup create x --table "0 1 linear /dev/loop0 0"
> 
>  EIP is at loop_unplug+0x1d/0x3b
>  ...
>   Call Trace:
>    blk_unplug+0x57/0x5e
>    dm_table_unplug_all+0x34/0x77 [dm_mod]
>    destroy_inode+0x27/0x38
>    generic_delete_inode+0xd5/0xd9
>    iput+0x4b/0x4e
>    dm_resume+0xca/0xfe [dm_mod]
>    dev_suspend+0x143/0x165 [dm_mod]
>    dm_ctl_ioctl+0x18e/0x1cf [dm_mod]
>    dev_suspend+0x0/0x165 [dm_mod]
>    dm_ctl_ioctl+0x0/0x1cf [dm_mod]
>    vfs_ioctl+0x22/0x69
>    do_vfs_ioctl+0x39d/0x3c7
>    trace_hardirqs_on+0xb/0xd
>    remove_vma+0x50/0x56
>    do_munmap+0x21c/0x237
>    sys_ioctl+0x2c/0x45
>    sysenter_do_call+0x12/0x31
> 
> Several reports here
> http://www.kerneloops.org/search.php?search=loop_unplug
> 
> Fix it by simply clear unplug function together with
> removing of backing file.
> 
> Signed-off-by: Milan Broz <mbroz@redhat.com>
> ---
>  drivers/block/loop.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index 90d19df..1e4b41e 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -919,6 +919,7 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
>  
>  	kthread_stop(lo->lo_thread);
>  
> +	lo->lo_queue->unplug_fn = NULL;
>  	lo->lo_backing_file = NULL;
>  
>  	loop_release_xfer(lo);
> 
> 

Thanks, applied.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-12-12 13:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-12 13:46 [PATCH] loop: Do not call loop_unplug for not configured loop device Milan Broz
2008-12-12 13:51 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.