* [PATCH] nvme: handle the compat submit-I/O command without copying tail padding
@ 2026-12-04 2:11 Pengpeng Hou
2026-12-04 8:20 ` Christoph Hellwig
2026-12-04 15:36 ` Keith Busch
0 siblings, 2 replies; 3+ messages in thread
From: Pengpeng Hou @ 2026-12-04 2:11 UTC (permalink / raw)
To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg
Cc: linux-nvme, linux-kernel, Pengpeng Hou
On ABIs with less trailing padding in the compat submit-I/O request,
the encoded command number differs from the native one. The old compat
translation handled that command separately. Commit 89b3d6e60550
("nvme: simplify the compat ioctl handling") folded the paths together
but guarded the compat case with the bare COMPAT_FOR_U64_ALIGNMENT
name, so dispatch misses the request on those ABIs.
Use the configured symbol and copy only through the last shared field,
appmask. The commands use the same field offsets; accepting the compat
command should not require access to native tail padding.
The issue was found by our static-analysis tool and manually reviewed.
Fixes: 89b3d6e60550 ("nvme: simplify the compat ioctl handling")
Signed-off-by: Pengpeng Hou <hppiscas@163.com>
---
The original patch was prepared with Gemini. Codex assisted with this
review and revision (Assisted-by: gpt 5).
Built ioctl.o on x86-64 with GCC 11.4 and W=1 (CONFIG_BLK_DEV_NVME=m,
CONFIG_COMPAT_FOR_U64_ALIGNMENT=y). No runtime or hardware test was
performed.
drivers/nvme/host/ioctl.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index a87c9ca9d06cea703701e40682428dce40a33e71..35d7e0a9b1c96ce7a1689f1b24231a39356a5936 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -242,7 +242,7 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio,
unsigned length, meta_len;
void __user *metadata;
- if (copy_from_user(&io, uio, sizeof(io)))
+ if (copy_from_user(&io, uio, offsetofend(struct nvme_user_io, appmask)))
return -EFAULT;
if (io.flags)
return -EINVAL;
@@ -595,7 +595,7 @@ static int nvme_ctrl_ioctl(struct nvme_ctrl *ctrl, unsigned int cmd,
}
}
-#ifdef COMPAT_FOR_U64_ALIGNMENT
+#ifdef CONFIG_COMPAT_FOR_U64_ALIGNMENT
struct nvme_user_io32 {
__u8 opcode;
__u8 flags;
@@ -611,7 +611,7 @@ struct nvme_user_io32 {
__u16 appmask;
} __attribute__((__packed__));
#define NVME_IOCTL_SUBMIT_IO32 _IOW('N', 0x42, struct nvme_user_io32)
-#endif /* COMPAT_FOR_U64_ALIGNMENT */
+#endif /* CONFIG_COMPAT_FOR_U64_ALIGNMENT */
static int nvme_ns_ioctl(struct nvme_ns *ns, unsigned int cmd,
void __user *argp, unsigned int flags, bool open_for_write)
@@ -627,7 +627,7 @@ static int nvme_ns_ioctl(struct nvme_ns *ns, unsigned int cmd,
* Just accept the compat version as all fields that are used are the
* same size and at the same offset.
*/
-#ifdef COMPAT_FOR_U64_ALIGNMENT
+#ifdef CONFIG_COMPAT_FOR_U64_ALIGNMENT
case NVME_IOCTL_SUBMIT_IO32:
#endif
case NVME_IOCTL_SUBMIT_IO:
base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] nvme: handle the compat submit-I/O command without copying tail padding
2026-12-04 2:11 [PATCH] nvme: handle the compat submit-I/O command without copying tail padding Pengpeng Hou
@ 2026-12-04 8:20 ` Christoph Hellwig
2026-12-04 15:36 ` Keith Busch
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2026-12-04 8:20 UTC (permalink / raw)
To: Pengpeng Hou
Cc: Keith Busch, Jens Axboe, Sagi Grimberg, linux-nvme, linux-kernel
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nvme: handle the compat submit-I/O command without copying tail padding
2026-12-04 2:11 [PATCH] nvme: handle the compat submit-I/O command without copying tail padding Pengpeng Hou
2026-12-04 8:20 ` Christoph Hellwig
@ 2026-12-04 15:36 ` Keith Busch
1 sibling, 0 replies; 3+ messages in thread
From: Keith Busch @ 2026-12-04 15:36 UTC (permalink / raw)
To: Jens Axboe, Christoph Hellwig, Sagi Grimberg, Pengpeng Hou
Cc: linux-nvme, linux-kernel
On Fri, 4 Dec 2026 10:11:24 +0800, Pengpeng Hou wrote:
> On ABIs with less trailing padding in the compat submit-I/O request,
> the encoded command number differs from the native one. The old compat
> translation handled that command separately. Commit 89b3d6e60550
> ("nvme: simplify the compat ioctl handling") folded the paths together
> but guarded the compat case with the bare COMPAT_FOR_U64_ALIGNMENT
> name, so dispatch misses the request on those ABIs.
>
> [...]
Thanks, applied to nvme-7.5.
[1/1] nvme: handle the compat submit-I/O command without copying tail padding
commit: 9355a9275ffd32eb8a445b1c4741950563d0cbf2
--
Keith Busch <kbusch@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-04 15:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-04 2:11 [PATCH] nvme: handle the compat submit-I/O command without copying tail padding Pengpeng Hou
2026-12-04 8:20 ` Christoph Hellwig
2026-12-04 15:36 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®