* [PATCHv2] nvme: restrict management ioctls to admin
@ 2022-09-22 14:54 Keith Busch
2022-09-27 7:20 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Keith Busch @ 2022-09-22 14:54 UTC (permalink / raw)
To: linux-nvme, hch, sagi; +Cc: Keith Busch
From: Keith Busch <kbusch@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, which include resets and rescans, can be disruptive.
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
v1->v2:
Check the user's capability in each case individually.
drivers/nvme/host/ioctl.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index d3281f87cd6e..a48a79ed5c4c 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -764,11 +764,17 @@ 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:
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCHv2] nvme: restrict management ioctls to admin
2022-09-22 14:54 [PATCHv2] nvme: restrict management ioctls to admin Keith Busch
@ 2022-09-27 7:20 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2022-09-27 7:20 UTC (permalink / raw)
To: Keith Busch; +Cc: linux-nvme, hch, sagi, Keith Busch
Thanks,
applied to nvme-6.1.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-27 7:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-22 14:54 [PATCHv2] nvme: restrict management ioctls to admin Keith Busch
2022-09-27 7:20 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox