mirror of
https://github.com/fail0verflow/switch-linux.git
synced 2025-05-04 02:34:21 -04:00
block: move CAP_SYS_ADMIN check in blkdev_roset()
Check for CAP_SYS_ADMIN before calling into the driver, similar to blkdev_flushbuf(). This is safer and can spare a check in the driver. (Currently BLKROSET is overridden by md and rbd, rbd is missing the check. md has the check, but it covers a lot more than BLKROSET.) Acked-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
351499a172
commit
bb749b31c2
1 changed files with 3 additions and 2 deletions
|
@ -443,11 +443,12 @@ static int blkdev_roset(struct block_device *bdev, fmode_t mode,
|
||||||
{
|
{
|
||||||
int ret, n;
|
int ret, n;
|
||||||
|
|
||||||
|
if (!capable(CAP_SYS_ADMIN))
|
||||||
|
return -EACCES;
|
||||||
|
|
||||||
ret = __blkdev_driver_ioctl(bdev, mode, cmd, arg);
|
ret = __blkdev_driver_ioctl(bdev, mode, cmd, arg);
|
||||||
if (!is_unrecognized_ioctl(ret))
|
if (!is_unrecognized_ioctl(ret))
|
||||||
return ret;
|
return ret;
|
||||||
if (!capable(CAP_SYS_ADMIN))
|
|
||||||
return -EACCES;
|
|
||||||
if (get_user(n, (int __user *)arg))
|
if (get_user(n, (int __user *)arg))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
set_device_ro(bdev, n);
|
set_device_ro(bdev, n);
|
||||||
|
|
Loading…
Add table
Reference in a new issue