* [PATCH] mm: Return -EFAULT if copy_to_user() fails
@ 2021-03-01 12:32 Wang Qing
2021-03-02 14:59 ` David Laight
0 siblings, 1 reply; 2+ messages in thread
From: Wang Qing @ 2021-03-01 12:32 UTC (permalink / raw)
To: Andrew Morton, linux-mm, linux-kernel; +Cc: Wang Qing
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);
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [PATCH] mm: Return -EFAULT if copy_to_user() fails
2021-03-01 12:32 [PATCH] mm: Return -EFAULT if copy_to_user() fails Wang Qing
@ 2021-03-02 14:59 ` David Laight
0 siblings, 0 replies; 2+ messages in thread
From: David Laight @ 2021-03-02 14:59 UTC (permalink / raw)
To: 'Wang Qing', Andrew Morton, linux-mm, linux-kernel
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)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-02 17:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01 12:32 [PATCH] mm: Return -EFAULT if copy_to_user() fails Wang Qing
2021-03-02 14:59 ` David Laight
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.