mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Aleksey Senin' <aleksey-linux-kernel@senin.name>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: Using memcpy instead of copy_to_user. xprtrdma code.
Date: Tue, 25 Jan 2022 22:21:31 +0000	[thread overview]
Message-ID: <55b4da35b6e44bf48306280d900e0fa8@AcuMS.aculab.com> (raw)
In-Reply-To: <CAM=k+5qEfxHOFkiXfobJERr=gMQ9jgcxgpydnkJx3ed3uPPsQg@mail.gmail.com>

From: Aleksey Senin <aleksey-linux-kernel@senin.name>
> Sent: 25 January 2022 18:04
> 
> 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

Read the commit message.

> 
> Commit itself:
> 32927393dc1ccd60fb2bdc05b9e8e88753761469

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

  reply	other threads:[~2022-01-25 22:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-25 18:03 Aleksey Senin
2022-01-25 22:21 ` David Laight [this message]
2022-01-25 23:56   ` Aleksey Senin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55b4da35b6e44bf48306280d900e0fa8@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=aleksey-linux-kernel@senin.name \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®