Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f031c89 authored by Martijn Coenen's avatar Martijn Coenen Committed by Connor O'Brien
Browse files

UPSTREAM: 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: 3448914e8cc5("loop: Add LOOP_CONFIGURE ioctl")
Reported-by: default avatarLennart Poettering <mzxreary@0pointer.de>
Tested-by: default avatarYang Xu <xuyang2018.jy@cn.fujitsu.com>
Signed-off-by: default avatarMartijn Coenen <maco@android.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
(cherry picked from commit 79e5dc59e2974a48764269fa9ff544ae8ffe3338)
Bug: 187129171
Signed-off-by: default avatarConnor O'Brien <connoro@google.com>
Change-Id: I823aba7e482eaf347992d507c875c10469a27c16
parent 38866fe5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1113,8 +1113,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;
@@ -1166,6 +1164,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) ?