Re: [PATCH v2 1/2] nvme: Fix compat NVME_IOCTL_SUBMIT_IO numbering

From: Christoph Hellwig
Date: Sat Mar 28 2020 - 04:27:02 EST


On Sat, Mar 28, 2020 at 01:09:08AM -0400, Nick Bowler wrote:
> When __u64 has 64-bit alignment, the nvme_user_io structure has trailing
> padding. This causes problems in the compat case with 32-bit userspace
> that has less strict alignment because the size of the structure differs.
>
> Since the NVME_IOCTL_SUBMIT_IO macro encodes the structure size itself,
> the result is that this ioctl does not work at all in such a scenario:
>
> # nvme read /dev/nvme0n1 -z 512
> submit-io: Inappropriate ioctl for device
>
> But by the same token, this makes it easy to handle both cases and
> since the structures differ only in unused trailing padding bytes
> we can simply not read those bytes.
>
> Signed-off-by: Nick Bowler <nbowler@xxxxxxxxxx>

I think we already have a similar patch titled
"nvme: Add compat_ioctl handler for NVME_IOCTL_SUBMIT_IO" in
linux-next, with the difference of actually implementing the
.compat_ioctl entry point.