RE: [PATCH v2 0/2] Replace and improve "mcsafe" with copy_safe()

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

 



From: Andy Lutomirski
> Sent: 30 April 2020 19:42
...
> I suppose there could be a consistent naming like this:
> 
> copy_from_user()
> copy_to_user()
> 
> copy_from_unchecked_kernel_address() [what probe_kernel_read() is]
> copy_to_unchecked_kernel_address() [what probe_kernel_write() is]
> 
> copy_from_fallible() [from a kernel address that can fail to a kernel
> address that can't fail]
> copy_to_fallible() [the opposite, but hopefully identical to memcpy() on x86]
> 
> copy_from_fallible_to_user()
> copy_from_user_to_fallible()

You missed out:
copy_to/from_io()
copy_to_io_from_user()
copy_from_io_to_user()
All of which want aligned addresses on the 'io' side.

It might even be worth saying that the copy_to/from_io() can
fail due to bad IO accesses (rather than bad addresses).
This is not entirely unexpected since all PCIe accesses
can fail unexpectedly (usually without a trap and returning -1).
But a system could arrange to generate a synchronous fault.

If you are copying directly from io to user you need to
differentiate between a user page fault and an io access
error. The latter shouldn't generate SIGSEGV.
Possibly return -EFAULT on user page fault and 'transfer
length remaining' on io access error.
Although filling the rest of the buffer with 0xff might be
appropriate.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux