[PATCH v2] nvme: pass partition flags to passthrough checks
Yao Sang
sangyao at kylinos.cn
Tue Oct 13 00:53:24 PDT 2026
nvme_user_cmd() handles NVME_IOCTL_IO_CMD on namespace block devices,
including partitions. It receives flags identifying a partition, but
passes 0 to nvme_cmd_allowed(), bypassing the partition guard and
allowing unprivileged passthrough commands to access sectors outside
the partition.
Pass flags to the permission check, rejecting unprivileged commands on
partitions.
Fixes: 313c08c72ee7 ("nvme: don't allow unprivileged passthrough on partitions")
Signed-off-by: Yao Sang <sangyao at kylinos.cn>
Reviewed-by: Kanchan Joshi <joshi.k at samsung.com>
---
Change in v2:
- Correct the Fixes tag as pointed out by Kanchan. No code changes.
drivers/nvme/host/ioctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 6539d4750098..f2904c7fe0ab 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -343,7 +343,7 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
c.common.cdw14 = cpu_to_le32(cmd.cdw14);
c.common.cdw15 = cpu_to_le32(cmd.cdw15);
- if (!nvme_cmd_allowed(ctrl, ns, &c, 0, open_for_write))
+ if (!nvme_cmd_allowed(ctrl, ns, &c, flags, open_for_write))
return -EACCES;
if (cmd.timeout_ms)
--
2.25.1
More information about the Linux-nvme
mailing list