All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kernel: Return -EFAULT if copy_to_user() fails
@ 2021-03-01 11:28 Wang Qing
  2021-03-01 11:32 ` Christian Brauner
  0 siblings, 1 reply; 2+ messages in thread
From: Wang Qing @ 2021-03-01 11:28 UTC (permalink / raw)
  To: Christian Brauner, Andrew Morton, Thomas Gleixner, Thomas Cedeno,
	Nicolas Viennot, Michel Lespinasse, Rasmus Villemoes, Al Viro,
	Gabriel Krisman Bertazi, 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>
---
 kernel/sys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sys.c b/kernel/sys.c
index 8bb46e5..d97a84a
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1247,7 +1247,7 @@ static int override_release(char __user *release, size_t len)
 		copy = scnprintf(buf, copy, "2.6.%u%s", v, rest);
 		ret = copy_to_user(release, buf, copy + 1);
 	}
-	return ret;
+	return ret ? -EFAULT : 0;
 }
 
 SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] kernel: Return -EFAULT if copy_to_user() fails
  2021-03-01 11:28 [PATCH] kernel: Return -EFAULT if copy_to_user() fails Wang Qing
@ 2021-03-01 11:32 ` Christian Brauner
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Brauner @ 2021-03-01 11:32 UTC (permalink / raw)
  To: Wang Qing
  Cc: Andrew Morton, Thomas Gleixner, Thomas Cedeno, Nicolas Viennot,
	Michel Lespinasse, Rasmus Villemoes, Al Viro,
	Gabriel Krisman Bertazi, linux-kernel

On Mon, Mar 01, 2021 at 07:28:11PM +0800, Wang Qing wrote:
> 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>
> ---

Hey Wang,

Thanks for the patch. It looks like override_release() is called in
three places and all three places return -EFAULT correctly. They simply
treat any as EFAULT. So not sure this change buys us anything.

Christian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-01 11:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01 11:28 [PATCH] kernel: Return -EFAULT if copy_to_user() fails Wang Qing
2021-03-01 11:32 ` Christian Brauner

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.