summaryrefslogtreecommitdiffstats
path: root/drivers/nvme
diff options
context:
space:
mode:
authorKeith Busch <kbusch@kernel.org>2022-09-22 07:54:06 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-12-08 11:18:34 +0100
commit4722ac3b7809747cc116dc4355757d26e2e6e1fb (patch)
tree264d5a44d78384950c3884de85ebae6bafcfe2c2 /drivers/nvme
parentbbfbdca680b0cbea0e57be597b5e2cae19747052 (diff)
downloadlinux-stable-4722ac3b7809747cc116dc4355757d26e2e6e1fb.tar.gz
linux-stable-4722ac3b7809747cc116dc4355757d26e2e6e1fb.tar.bz2
linux-stable-4722ac3b7809747cc116dc4355757d26e2e6e1fb.zip
nvme: restrict management ioctls to admin
commit 23e085b2dead13b51fe86d27069895b740f749c0 upstream. The passthrough commands already have this restriction, but the other operations do not. Require the same capabilities for all users as all of these operations, which include resets and rescans, can be disruptive. Signed-off-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Diffstat (limited to 'drivers/nvme')
-rw-r--r--drivers/nvme/host/core.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 986912e680d8..f47f3b992161 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2675,11 +2675,17 @@ static long nvme_dev_ioctl(struct file *file, unsigned int cmd,
case NVME_IOCTL_IO_CMD:
return nvme_dev_user_cmd(ctrl, argp);
case NVME_IOCTL_RESET:
+ if (!capable(CAP_SYS_ADMIN))
+ return -EACCES;
dev_warn(ctrl->device, "resetting controller\n");
return nvme_reset_ctrl_sync(ctrl);
case NVME_IOCTL_SUBSYS_RESET:
+ if (!capable(CAP_SYS_ADMIN))
+ return -EACCES;
return nvme_reset_subsystem(ctrl);
case NVME_IOCTL_RESCAN:
+ if (!capable(CAP_SYS_ADMIN))
+ return -EACCES;
nvme_queue_scan(ctrl);
return 0;
default: