From: Andy Lutomirski
Sent: 30 April 2020 19:42
I suppose there could be a consistent naming like this:
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]
You missed out:
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
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)