]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-cli: fix ioctl argument
authorWarner Losh <imp@FreeBSD.org>
Fri, 5 Oct 2018 04:08:01 +0000 (22:08 -0600)
committerWarner Losh <imp@FreeBSD.org>
Fri, 5 Oct 2018 04:14:37 +0000 (22:14 -0600)
The command argument for ioctl is unsigned long, not int. Fix all the
places that we pass cmd through to the ioctl call to handle it as an
unsigned long. This prevents a sign extension bug when IOCTL commands
encode with the top bit set.

nvme-ioctl.c
nvme-ioctl.h

index 1866f438792e2888732d623c5b7fa2a10d0d8922..be0823dfbcc20813b63cc351a8c31d449efe04c4 100644 (file)
@@ -81,7 +81,8 @@ int nvme_get_nsid(int fd)
        return ioctl(fd, NVME_IOCTL_ID);
 }
 
-int nvme_submit_passthru(int fd, int ioctl_cmd, struct nvme_passthru_cmd *cmd)
+int nvme_submit_passthru(int fd, unsigned long ioctl_cmd,
+                        struct nvme_passthru_cmd *cmd)
 {
        return ioctl(fd, ioctl_cmd, cmd);
 }
@@ -96,7 +97,8 @@ static int nvme_submit_io_passthru(int fd, struct nvme_passthru_cmd *cmd)
        return ioctl(fd, NVME_IOCTL_IO_CMD, cmd);
 }
 
-int nvme_passthru(int fd, int ioctl_cmd, __u8 opcode, __u8 flags, __u16 rsvd,
+int nvme_passthru(int fd, unsigned long ioctl_cmd, __u8 opcode,
+                 __u8 flags, __u16 rsvd,
                  __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11,
                  __u32 cdw12, __u32 cdw13, __u32 cdw14, __u32 cdw15,
                  __u32 data_len, void *data, __u32 metadata_len,
index bb06f8255981fa3f6e7562718ac9c0ec786819ae..3fb740c323417e3c1bca3f8aa6e0349f76ba0585 100644 (file)
@@ -9,9 +9,10 @@
 int nvme_get_nsid(int fd);
 
 /* Generic passthrough */
-int nvme_submit_passthru(int fd, int ioctl_cmd, struct nvme_passthru_cmd *cmd);
+int nvme_submit_passthru(int fd, unsigned long ioctl_cmd,
+                        struct nvme_passthru_cmd *cmd);
 
-int nvme_passthru(int fd, int ioctl_cmd, __u8 opcode, __u8 flags,
+int nvme_passthru(int fd, unsigned long ioctl_cmd, __u8 opcode, __u8 flags,
                  __u16 rsvd, __u32 nsid, __u32 cdw2, __u32 cdw3,
                  __u32 cdw10, __u32 cdw11, __u32 cdw12,
                  __u32 cdw13, __u32 cdw14, __u32 cdw15,