nvme: restrict management ioctls to admin
PATCH 1/1 nvme: restrict management ioctls to admin
From: Keith Busch <[email protected]>
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.
--- drivers/nvme/host/ioctl.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/nvme/host/ioctl.c +3 -0
@@ -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);
Signature · 1 line
2.30.2
Quoted 16 lines · Keith Busch
From: Keith Busch <[email protected]>
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 <[email protected]>---
drivers/nvme/host/ioctl.c| 3 +++1 file changed, 3 insertions(+)drivers/nvme/host/ioctl.c +0
-0
drivers/nvme/host/ioctl.c long nvme_dev_ioctl(struct file *file, unsigned int cmd, · line 754
Quoted 6 lines
drivers/nvme/host/ioctl.c +3
-0@@ -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 ; +
I too came across this and wondered why this check is not present here.
It's a different matter that I was looking at increasing the access granularity (something like scsi whitelisting). Hope to have conversations on a RFC soon.
Quoted 2 lines
Jens Axboe
maintainerQuoted 5 lines · Keith Busch
From: Keith Busch <[email protected]>
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.
Would it be saner to require that you have write permissions on the opened device? Not sure this CAP_SYS_ADMIN is really necessary, and might break existing setups as this is new.
I do agree that passthrough and sync ioctl based issue should be consistent, though.
Signature · 1 line
Jens Axboe
Christoph Hellwig
maintainerQuoted 5 lines · Keith Busch
From: Keith Busch <[email protected]>
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.
Where "these operations" are: NVME_IOCTL_RESET, NVME_IOCTL_SUBSYS_RESET, NVME_IOCTL_RESCAN. Yes, I think those are very disruptive and the definition of what CAP_SYS_ADMIN was designed for, but that should be spelled out in the commit log.
That being said I think we should just do the capable() check in the individul ioctl opcode to document things better, even if that does't currently make any difference. Any we really need a FIXES tag going back to the addition of the first of these ioctls.
Sagi Grimberg
maintainerQuoted 5 lines
Quoted 4 lines
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.
Quoted 8 lines
Where "these operations" are:
NVME_IOCTL_RESET,NVME_IOCTL_SUBSYS_RESET,NVME_IOCTL_RESCAN. Yes, I think those are very disruptive and the definition of whatCAP_SYS_ADMINwas designed for, but that should be spelled out in the commit log.That being said I think we should just do the
capable()check in the individul ioctl opcode to document things better, even if that does't currently make any difference.
Agree.
Quoted 2 lines
Any we really need a FIXES tag going
back to the addition of the first of these ioctls.
100% agree on the fixes tag