linux/drivers/block
Jan Kara 33ec3e53e7 loop: Don't change loop device under exclusive opener
Loop module allows calling LOOP_SET_FD while there are other openers of
the loop device. Even exclusive ones. This can lead to weird
consequences such as kernel deadlocks like:

mount_bdev()				lo_ioctl()
  udf_fill_super()
    udf_load_vrs()
      sb_set_blocksize() - sets desired block size B
      udf_tread()
        sb_bread()
          __bread_gfp(bdev, block, B)
					  loop_set_fd()
					    set_blocksize()
            - now __getblk_slow() indefinitely loops because B != bdev
              block size

Fix the problem by disallowing LOOP_SET_FD ioctl when there are
exclusive openers of a loop device.

[Deliberately chosen not to CC stable as a user with priviledges to
trigger this race has other means of taking the system down and this
has a potential of breaking some weird userspace setup]

Reported-and-tested-by: syzbot+10007d66ca02b08f0e60@syzkaller.appspotmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-05-27 07:34:04 -06:00
..
aoe treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
drbd treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 91 2019-05-24 17:37:53 +02:00
mtip32xx treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
paride Linux 5.1-rc6 2019-04-22 09:47:36 -06:00
rsxx treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
xen-blkback treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
zram treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
amiflop.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
ataflop.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
brd.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
cryptoloop.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 30 2019-05-24 17:27:10 +02:00
floppy.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
Kconfig drivers/block: Remove DAC960 driver 2018-10-17 09:42:30 -06:00
loop.c loop: Don't change loop device under exclusive opener 2019-05-27 07:34:04 -06:00
loop.h block/loop: Use global lock for ioctl() operation. 2018-11-08 06:30:11 -07:00
Makefile drivers/block: Remove DAC960 driver 2018-10-17 09:42:30 -06:00
nbd.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next 2019-04-28 08:42:41 -04:00
null_blk_main.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
null_blk_zoned.c null_blk: Add conventional zone configuration for zoned support 2018-11-07 13:41:50 -07:00
null_blk.h null_blk: add zoned config support information 2019-01-06 10:58:27 -07:00
pktcdvd.c block: genhd: remove async_events field 2019-04-12 13:35:22 -06:00
ps3disk.c block: remove CONFIG_LBDAF 2019-04-06 10:48:35 -06:00
ps3vram.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
rbd_types.h rbd: RBD_V{1,2}_DATA_FORMAT macros 2017-02-20 12:16:15 +01:00
rbd.c rbd: don't assert on writes to snapshots 2019-05-07 19:43:04 +02:00
skd_main.c block: kill BLK_MQ_F_SG_MERGE 2019-02-15 08:40:12 -07:00
skd_s1120.h skd: Use __packed only when needed 2017-08-18 08:45:29 -06:00
sunvdc.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
swim3.c Revert "block: unexport DISK_EVENT_MEDIA_CHANGE for legacy/fringe drivers" 2019-04-12 13:35:27 -06:00
swim_asm.S
swim.c Revert "block: unexport DISK_EVENT_MEDIA_CHANGE for legacy/fringe drivers" 2019-04-12 13:35:27 -06:00
sx8.c sx8: use a per-host tag_set 2018-11-09 08:14:14 -07:00
umem.c block: remove the lock argument to blk_alloc_queue_node 2018-11-15 12:13:35 -07:00
umem.h
virtio_blk.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
xen-blkfront.c block: kill BLK_MQ_F_SG_MERGE 2019-02-15 08:40:12 -07:00
xsysace.c Linux 5.1-rc6 2019-04-22 09:47:36 -06:00
z2ram.c powerpc updates for 4.20 2018-10-26 14:36:21 -07:00