diff options
author | Jan Kara <jack@suse.cz> | 2019-07-30 13:10:14 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-08-06 19:08:18 +0200 |
commit | 4c825540af16197d84e6cf943972eccf6ea54ff6 (patch) | |
tree | 2c264c18b205db9fdd574339068bc720f5f8bd67 /lib/ioremap.c | |
parent | 4461f834098f88df90abaefbfe283d60a117feea (diff) | |
download | linux-stable-4c825540af16197d84e6cf943972eccf6ea54ff6.tar.gz linux-stable-4c825540af16197d84e6cf943972eccf6ea54ff6.tar.bz2 linux-stable-4c825540af16197d84e6cf943972eccf6ea54ff6.zip |
loop: Fix mount(2) failure due to race with LOOP_SET_FD
commit 89e524c04fa966330e2e80ab2bc50b9944c5847a upstream.
Commit 33ec3e53e7b1 ("loop: Don't change loop device under exclusive
opener") made LOOP_SET_FD ioctl acquire exclusive block device reference
while it updates loop device binding. However this can make perfectly
valid mount(2) fail with EBUSY due to racing LOOP_SET_FD holding
temporarily the exclusive bdev reference in cases like this:
for i in {a..z}{a..z}; do
dd if=/dev/zero of=$i.image bs=1k count=0 seek=1024
mkfs.ext2 $i.image
mkdir mnt$i
done
echo "Run"
for i in {a..z}{a..z}; do
mount -o loop -t ext2 $i.image mnt$i &
done
Fix the problem by not getting full exclusive bdev reference in
LOOP_SET_FD but instead just mark the bdev as being claimed while we
update the binding information. This just blocks new exclusive openers
instead of failing them with EBUSY thus fixing the problem.
Fixes: 33ec3e53e7b1 ("loop: Don't change loop device under exclusive opener")
Cc: stable@vger.kernel.org
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib/ioremap.c')
0 files changed, 0 insertions, 0 deletions