Skip to content

Commit 79e5dc5

Browse files
Martijn Coenenaxboe
authored andcommitted
loop: Set correct device size when using LOOP_CONFIGURE
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: 3448914("loop: Add LOOP_CONFIGURE ioctl") Reported-by: Lennart Poettering <mzxreary@0pointer.de> Tested-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com> Signed-off-by: Martijn Coenen <maco@android.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent acb19e1 commit 79e5dc5

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/block/loop.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,8 +1114,6 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
11141114
mapping = file->f_mapping;
11151115
inode = mapping->host;
11161116

1117-
size = get_loop_size(lo, file);
1118-
11191117
if ((config->info.lo_flags & ~LOOP_CONFIGURE_SETTABLE_FLAGS) != 0) {
11201118
error = -EINVAL;
11211119
goto out_unlock;
@@ -1165,6 +1163,8 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
11651163
loop_update_rotational(lo);
11661164
loop_update_dio(lo);
11671165
loop_sysfs_init(lo);
1166+
1167+
size = get_loop_size(lo, file);
11681168
loop_set_size(lo, size);
11691169

11701170
set_blocksize(bdev, S_ISBLK(inode->i_mode) ?

0 commit comments

Comments
 (0)