loop: block changing lo_offset/lo_sizelimit on mounted device#705
loop: block changing lo_offset/lo_sizelimit on mounted device#705blktests-ci[bot] wants to merge 1 commit intolinus-master_basefrom
Conversation
|
Upstream branch: 7aaa804 |
c781e1e to
255b4bf
Compare
|
Upstream branch: d0c3bcd |
659b9e0 to
44f5989
Compare
255b4bf to
3236861
Compare
|
Upstream branch: 9147566 |
44f5989 to
da55e39
Compare
ecbdbb4 to
480b162
Compare
|
Upstream branch: 9147566 |
da55e39 to
177b1e1
Compare
a96fba7 to
0cd6ac2
Compare
|
Upstream branch: 9147566 |
177b1e1 to
c10dbad
Compare
0cd6ac2 to
910d344
Compare
|
Upstream branch: d8a9a4b |
c10dbad to
0e12787
Compare
910d344 to
ed862bc
Compare
|
Upstream branch: 7ca6d1c |
0e12787 to
bb30882
Compare
ed862bc to
2d0c3d5
Compare
|
Upstream branch: 3aae938 |
bb30882 to
4e11d76
Compare
2d0c3d5 to
931d9b0
Compare
|
Upstream branch: 3036cd0 |
4e11d76 to
da5de4c
Compare
931d9b0 to
78a4682
Compare
LOOP_SET_STATUS{64} allows changing lo_offset and shrinking
lo_sizelimit while a filesystem is mounted on the loop device.
This effectively mutates the data visible to the mounted filesystem,
which is equivalent to writing directly to the block device.
When CONFIG_BLK_DEV_WRITE_MOUNTED is disabled, direct writes to a
mounted block device are blocked. However, LOOP_SET_STATUS{64}
bypasses this protection because it modifies the loop configuration
through an ioctl rather than opening the block device for writing.
Fix this by checking bdev_writes_blocked() before allowing changes
to lo_offset or shrinking lo_sizelimit. If the loop device has
writes blocked, return -EBUSY. Increasing lo_sizelimit is still
allowed since growing the device is harmless and has legitimate
use cases such as online resize.
Move bdev_writes_blocked() from block/bdev.c to
include/linux/blk_types.h as a static inline function so it can
be used from the loop driver without exporting a symbol.
Suggested-by: Theodore Ts'o <tytso@mit.edu>
Reported-by: syzbot+fb32afec111a7d61b939@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=fb32afec111a7d61b939
Tested-by: syzbot+fb32afec111a7d61b939@syzkaller.appspotmail.com
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
|
Upstream branch: 9a9c8ce |
da5de4c to
901c6b6
Compare
Pull request for series with
subject: loop: block changing lo_offset/lo_sizelimit on mounted device
version: 2
url: https://patchwork.kernel.org/project/linux-block/list/?series=1074954