mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Wang Qing' <wangqing@vivo.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] mm: Return -EFAULT if copy_to_user() fails
Date: Tue, 2 Mar 2021 14:59:17 +0000	[thread overview]
Message-ID: <b329897d699b483387acb43a4111e599@AcuMS.aculab.com> (raw)
In-Reply-To: <1614601963-25812-1-git-send-email-wangqing@vivo.com>

From: Wang Qing <wangqing@vivo.com>
> Sent: 01 March 2021 12:33
> 
> The copy_to_user() function returns the number of bytes remaining to be
> copied, but we want to return -EFAULT if the copy doesn't complete.
> 
> Signed-off-by: Wang Qing <wangqing@vivo.com>
> ---
>  mm/mempolicy.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index ab51132..a116e56
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -1667,7 +1667,7 @@ COMPAT_SYSCALL_DEFINE5(get_mempolicy, int __user *, policy,
>  	if (!err && nmask) {
>  		unsigned long copy_size;
>  		copy_size = min_t(unsigned long, sizeof(bm), alloc_size);
> -		err = copy_from_user(bm, nm, copy_size);
> +		err = copy_from_user(bm, nm, copy_size) ? -EFAULT : 0;
>  		/* ensure entire bitmap is zeroed */
>  		err |= clear_user(nmask, ALIGN(maxnode-1, 8) / 8);
>  		err |= compat_put_bitmap(nmask, bm, nr_bits);

Given the 'err |= xxx' that follow I suspect the error code
doesn't matter at all.

	David

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


      reply	other threads:[~2021-03-02 17:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-01 12:32 Wang Qing
2021-03-02 14:59 ` David Laight [this message]

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=b329897d699b483387acb43a4111e599@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=wangqing@vivo.com \
    /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®