On 31/10/2023 17:20, Akram Ahmad wrote:
@@ -46,9 +49,9 @@ struct mmc_ioc_cmd { __u32 __pad; /* DAT buffer */
- __u64 data_ptr;
- __kernel_uintptr_t data_ptr;
So... we have a bit of a problem here. It seems to be the first time that we hit it, probably because we haven't converted many (any?) ioctls yet. The ioctl command corresponding to this struct is defined thus:
#define MMC_IOC_CMD _IOWR(MMC_BLOCK_MAJOR, 0, struct mmc_ioc_cmd)
What this means is that the size of the struct is part of the command numerical value (see the definition of _IOWR and _IOC). Unavoidably, if we modify the struct as we do here, its size increases and the command value changes.
This is not really a problem in purecap, as applications need to be rebuilt against the updated kernel headers anyway, but it is a major issue in compat64, as it is essential for userspace to keep working as-is (without rebuilding). Sure enough, mmc-utils built against unmodified headers fails with this patch, as the value of MMC_IOC_CMD it uses is not what the kernel expects any more.
Unfortunately I don't see a way to solve this problem without hardcoding the size in the command definition (something like _IOC(_IOC_READ|_IOC_WRITE, MMC_BLOCK_MAJOR, 0, 64)) - compat structs are not defined in uapi headers, so we cannot use them. Opinions very welcome however!
Kevin