Re: [PATCH v2 1/2] nvme: Fix compat NVME_IOCTL_SUBMIT_IO numbering
From: Nick Bowler
Date: Sat Mar 28 2020 - 09:56:36 EST
On 28/03/2020, Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote:
> 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.
OK, I found that one and it looks to solve the same problem.
I'm not sure about copying the nonexistent trailing padding from 32-bit
userspace but that may not be a problem in practice.
So feel free to drop this patch.
Thanks,
Nick