nvme: fix NVME_IOCTL_SUBMIT_IO for compat_ioctl
diff mbox series

Message ID 2caa4c913579464bbfdf06b36001ffc9@TGXML281.toshiba.local
State New, archived
Headers show
Series
  • nvme: fix NVME_IOCTL_SUBMIT_IO for compat_ioctl
Related show

Commit Message

masahiro31.yamada@kioxia.com Feb. 28, 2020, 9:28 a.m. UTC
From: Masahiro Yamada <masahiro31.yamada@kioxia.com>

Currently 32 bit application gets ENOTTY when it calls
compat_ioctl with NVME_IOCTL_SUBMIT_IO in 64 bit kernel.

The cause is that the results of sizeof(struct nvme_user_io),
which is used to define NVME_IOCTL_SUBMIT_IO,
are not same between 32 bit compiler and 64 bit compiler.

* 32 bit: the result of sizeof nvme_user_io is 44.
* 64 bit: the result of sizeof nvme_user_io is 48.

64 bit compiler seems to add 32 bit padding for multiple of 8 bytes.

This patch adds 32 bit padding to struct nvme_user_io
for 32 bit compiler to define same NVME_IOCTL_SUBMIT_IO as 64 bit.

nvme-cli also needs to be fixed if this patch is accepted.

Signed-off-by: Masahiro Yamada <masahiro31.yamada@kioxia.com>
---
 include/uapi/linux/nvme_ioctl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Christoph Hellwig Feb. 29, 2020, 6:59 p.m. UTC | #1
We can't just change the existing structure, instead we'll need
a compat handler for the 32-bit x86 case.
masahiro31.yamada@kioxia.com March 2, 2020, 4:31 a.m. UTC | #2
>We can't just change the existing structure, instead we'll need
>a compat handler for the 32-bit x86 case.

Thank you for your comment.
OK. I'll recreate this patch which adds a handler for compat_ioctl,
not to change the existing structure.

Patch
diff mbox series

diff --git a/include/uapi/linux/nvme_ioctl.h b/include/uapi/linux/nvme_ioctl.h
index d99b5a772698..a50ea474c21a 100644
--- a/include/uapi/linux/nvme_ioctl.h
+++ b/include/uapi/linux/nvme_ioctl.h
@@ -14,7 +14,7 @@  struct nvme_user_io {
 	__u8	flags;
 	__u16	control;
 	__u16	nblocks;
-	__u16	rsvd;
+	__u16	rsvd1;
 	__u64	metadata;
 	__u64	addr;
 	__u64	slba;
@@ -22,6 +22,7 @@  struct nvme_user_io {
 	__u32	reftag;
 	__u16	apptag;
 	__u16	appmask;
+	__u32	rsvd2;
 };
 
 struct nvme_passthru_cmd {