lkml.org 
[lkml]   [2022]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectUsing memcpy instead of copy_to_user. xprtrdma code.
This specific patch -  - implements using memcpy instead of
copy_to_user. Why is it considered to be safe in this specific case?
All readings about how to copy data are mentioning to use
copy_to_user/copy_from_user. Why use direct copy here? What prevents
the kernel from failure if the page is not present or doesn't have
required access rights?

@@ -103,8 +102,8 @@ static int read_reset_stat(struct ctl_table
*table, int write,
len -= *ppos;
if (len > *lenp)
len = *lenp;
- if (len && copy_to_user(buffer, str_buf, len))
- return -EFAULT;
+ if (len)
+ memcpy(buffer, str_buf, len);

Reference to the specific patch in the services of commits:
https://lkml.org/lkml/2020/4/17/60

Commit itself:
32927393dc1ccd60fb2bdc05b9e8e88753761469

\
 
 \ /
  Last update: 2022-01-25 19:06    [W:0.048 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site