lkml.org 
[lkml]   [2022]   [Jun]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC,iov_iter v2 3/8] iov_iter: add copyin_iovec helper
On Sun, Jun 12, 2022 at 01:57:52AM -0700, Joe Damato wrote:
> copyin_iovec is a helper which wraps copyin and selects the right copy
> method based on the iter_copy_type.
>
> Signed-off-by: Joe Damato <jdamato@fastly.com>
> ---
> lib/iov_iter.c | 19 ++++++++++++++-----
> 1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/lib/iov_iter.c b/lib/iov_iter.c
> index d32d7e5..6720cb2 100644
> --- a/lib/iov_iter.c
> +++ b/lib/iov_iter.c
> @@ -168,6 +168,15 @@ static int copyin(void *to, const void __user *from, size_t n)
> return n;
> }
>
> +static int copyin_iovec(void *to, const void __user *from, size_t n,
> + struct iov_iter *i)
> +{
> + if (unlikely(iov_iter_copy_is_nt(i)))
> + return __copy_from_user_nocache(to, from, n);
> + else
> + return copyin(to, from, n);
> +}

Just a sanity check - your testing is *not* with KASAN/KCSAN, right?

And BTW, why is that only on the userland side? If you are doing
that at all, it would make sense to cover the memcpy() side as
well...

\
 
 \ /
  Last update: 2022-06-13 06:26    [W:0.154 / U:0.416 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site