loop: Set correct device size when using LOOP_CONFIGURE
authorMartijn Coenen <maco@android.com>
Tue, 25 Aug 2020 07:18:29 +0000 (09:18 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Sep 2020 10:59:49 +0000 (12:59 +0200)
commit3531913b68be7356575279e32cc2d944bf6d3df6
treea01c2d7f803fe993c18ffde14aefb7edd6d7b78e
parent0fb2de68a876af1c1ae8f3943dc1a70f0b020d45
loop: Set correct device size when using LOOP_CONFIGURE

commit 79e5dc59e2974a48764269fa9ff544ae8ffe3338 upstream.

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>
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/block/loop.c