block: fail op_is_write() requests to read-only partitions
authorIlya Dryomov <[email protected]>
Thu, 11 Jan 2018 13:09:11 +0000 (14:09 +0100)
committerJens Axboe <[email protected]>
Thu, 18 Jan 2018 19:57:17 +0000 (12:57 -0700)
commit721c7fc701c71f693307d274d2b346a1ecd4a534
tree02b8934cb55c6b00a533c536419e2d157d18917b
parent17534c6f2c065ad8e34ff6f013e5afaa90428512
block: fail op_is_write() requests to read-only partitions

Regular block device writes go through blkdev_write_iter(), which does
bdev_read_only(), while zeroout/discard/etc requests are never checked,
both userspace- and kernel-triggered.  Add a generic catch-all check to
generic_make_request_checks() to actually enforce ioctl(BLKROSET) and
set_disk_ro(), which is used by quite a few drivers for things like
snapshots, read-only backing files/images, etc.

Reviewed-by: Sagi Grimberg <[email protected]>
Signed-off-by: Ilya Dryomov <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
block/blk-core.c