[PATCH] block: deny zone management ioctl on mounted fs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If a user submits a zone management ioctl from user-space, like a zone
reset and a file-system (like zonefs or f2fs) is mounted on the zoned
block device, the zone will get reset and the file-system's cached value
of the zone's write-pointer becomes invalid.

Subsequent writes to this zone from the file-system will result in
unaligned writes and the drive will error out.

Deny zone management ioctls when a super_block is found on the block
device.

Reported-by: Coly Li <colyli@xxxxxxx>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@xxxxxxx>
---

Is there a better way to check for a mounted FS than get_super()/drop_super()?

 block/blk-zoned.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 23831fa8701d..6923695ec414 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -325,6 +325,7 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
 			   unsigned int cmd, unsigned long arg)
 {
 	void __user *argp = (void __user *)arg;
+	struct super_block *sb;
 	struct request_queue *q;
 	struct blk_zone_range zrange;
 	enum req_opf op;
@@ -345,6 +346,12 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
 	if (!(mode & FMODE_WRITE))
 		return -EBADF;
 
+	sb = get_super(bdev);
+	if (sb) {
+		drop_super(sb);
+		return -EINVAL;
+	}
+
 	if (copy_from_user(&zrange, argp, sizeof(struct blk_zone_range)))
 		return -EFAULT;
 
-- 
2.24.1




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux