[PATCH] nvme: restrict management ioctls to admin
Keith Busch
kbusch at fb.com
Thu Sep 8 14:35:17 PDT 2022
From: Keith Busch <kbusch at kernel.org>
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 can be disruptive.
Signed-off-by: Keith Busch <kbusch at kernel.org>
---
drivers/nvme/host/ioctl.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 27614bee7380..d23978e993c6 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -749,6 +749,9 @@ long nvme_dev_ioctl(struct file *file, unsigned int cmd,
struct nvme_ctrl *ctrl = file->private_data;
void __user *argp = (void __user *)arg;
+ if (!capable(CAP_SYS_ADMIN))
+ return -EACCES;
+
switch (cmd) {
case NVME_IOCTL_ADMIN_CMD:
return nvme_user_cmd(ctrl, NULL, argp);
--
2.30.2
More information about the Linux-nvme
mailing list