lkml.org 
[lkml]   [2020]   [Apr]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 0/2] Replace and improve "mcsafe" with copy_safe()
On Thu, Apr 30, 2020 at 11:42:20AM -0700, Andy Lutomirski wrote:
> 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()
>
> These names are fairly verbose and could probably be improved.

How about

try_copy_catch(void *dst, void *src, size_t count, int *fault)

returns number of bytes not-copied (like copy_to_user etc).

if return is not zero, "fault" tells you what type of fault
cause the early stop (#PF, #MC).

-Tony

\
 
 \ /
  Last update: 2020-04-30 21:24    [W:0.140 / U:1.560 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site