[PATCH] nvme: fix NVME_IOCTL_SUBMIT_IO for compat_ioctl

From: masahiro31.yamada
Date: Fri Feb 28 2020 - 04:41:18 EST


From: Masahiro Yamada <masahiro31.yamada@xxxxxxxxxx>

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@xxxxxxxxxx>
---
include/uapi/linux/nvme_ioctl.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

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 {
--
2.20.1