Re: [PATCH v6] mmc: Add mmc CMD+ACMD passthrough ioctl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



W dniu 21 kwietnia 2011 13:15 użytkownik Arnd Bergmann <arnd@xxxxxxxx> napisał:
> On Thursday 21 April 2011, Michał Mirosław wrote:
>> Subject: Re: [PATCH v4] mmc: Add ioctl to let userspace apps send ACMDs
>> Date: Wed, 13 Apr 2011 01:00:39 +0200
>> Message-Id: <201104130100.39810.arnd@xxxxxxxx>
>>
>> Then I already provided an example of implementation that's
>> independent of endianness and avoids casts on userspace.
>
> Yes, v4 got that aspect right, as far as I can tell, aside
> from an incorrect cast (u8* instead of u8 __user *).

Just to have an understanding about the issue. In the mail I pointed
to, you argued that union will not work because of endianness
problems. I haven't seen other arguments against the union approach,
and I have provided a solution for this case.

BTW, kernel side can also avoid the cast if the union is extended with
32-bit field. This works because an address of a union is an address
of each of its fields. IOW all fields start at the same address
regardless if the they are 32 or 64 bits in size.

struct mmc_ioc_cmd {
  union {
    __u64 __data_ptr_storage64;
    __u32 __data_ptr_storage32;
    void __user *data_ptr;
  };
  ...
};

[...]

static int mmc_blk_compat_ioctl(struct block_device *bdev, fmode_t mode,
    unsigned int cmd, unsigned long arg)
{
  struct mmc_ioc_cmd blk;

  if (cmd != MMC_IOC_CMD)
    return -EINVAL;

  copy_from_user(compat_ptr(arg), &blk) ...
  blk.data_ptr = compat_ptr(blk.__data_ptr_storage32);

  return mmc_blk_ioctl_cmd(bdev, &blk);
}

Best Regards,
Michał Mirosław
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux