All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] loop: Set correct device size when using LOOP_CONFIGURE
@ 2020-08-25  7:18 Martijn Coenen
  2020-08-26  4:15 ` Yang Xu
  2020-08-26 15:30 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Martijn Coenen @ 2020-08-25  7:18 UTC (permalink / raw)
  To: mzxreary, axboe; +Cc: linux-block, hch, xuyang2018.jy, Martijn Coenen

The device size calculation was done before processing the loop
configuration, which meant that the we set the size on the underlying
block device incorrectly in case lo_offset/lo_sizelimit were set in the
configuration. Delay computing the size until we've setup the device
parameters correctly.

Fixes: 3448914e8cc5("loop: Add LOOP_CONFIGURE ioctl")
Reported-by: Lennart Poettering <mzxreary@0pointer.de>
Signed-off-by: Martijn Coenen <maco@android.com>
---
 drivers/block/loop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 2f137d6ce169..fbda14840d8e 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1111,8 +1111,6 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
 	mapping = file->f_mapping;
 	inode = mapping->host;
 
-	size = get_loop_size(lo, file);
-
 	if ((config->info.lo_flags & ~LOOP_CONFIGURE_SETTABLE_FLAGS) != 0) {
 		error = -EINVAL;
 		goto out_unlock;
@@ -1162,6 +1160,8 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
 	loop_update_rotational(lo);
 	loop_update_dio(lo);
 	loop_sysfs_init(lo);
+
+	size = get_loop_size(lo, file);
 	loop_set_size(lo, size);
 
 	set_blocksize(bdev, S_ISBLK(inode->i_mode) ?
-- 
2.28.0.297.g1956fa8f8d-goog


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

end of thread, other threads:[~2020-08-26 15:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-25  7:18 [PATCH] loop: Set correct device size when using LOOP_CONFIGURE Martijn Coenen
2020-08-26  4:15 ` Yang Xu
2020-08-26 15:30 ` 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.