* [PATCH v2] nvme: pass partition flags to passthrough checks
@ 2026-10-13 7:53 Yao Sang
2026-10-13 14:20 ` Christoph Hellwig
2026-10-13 15:44 ` Keith Busch
0 siblings, 2 replies; 3+ messages in thread
From: Yao Sang @ 2026-10-13 7:53 UTC (permalink / raw)
To: kbusch, axboe, hch, sagi, linux-nvme; +Cc: Yao Sang, Kanchan Joshi
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@kylinos.cn>
Reviewed-by: Kanchan Joshi <joshi.k@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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] nvme: pass partition flags to passthrough checks
2026-10-13 7:53 [PATCH v2] nvme: pass partition flags to passthrough checks Yao Sang
@ 2026-10-13 14:20 ` Christoph Hellwig
2026-10-13 15:44 ` Keith Busch
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2026-10-13 14:20 UTC (permalink / raw)
To: Yao Sang; +Cc: kbusch, axboe, hch, sagi, linux-nvme, Kanchan Joshi
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] nvme: pass partition flags to passthrough checks
2026-10-13 7:53 [PATCH v2] nvme: pass partition flags to passthrough checks Yao Sang
2026-10-13 14:20 ` Christoph Hellwig
@ 2026-10-13 15:44 ` Keith Busch
1 sibling, 0 replies; 3+ messages in thread
From: Keith Busch @ 2026-10-13 15:44 UTC (permalink / raw)
To: Yao Sang; +Cc: axboe, hch, sagi, linux-nvme, Kanchan Joshi
On Tue, Oct 13, 2026 at 03:53:24PM +0800, Yao Sang wrote:
> 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.
Thanks, applied to nvme-7.4.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-13 15:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13 7:53 [PATCH v2] nvme: pass partition flags to passthrough checks Yao Sang
2026-10-13 14:20 ` Christoph Hellwig
2026-10-13 15:44 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox