mirror of https://lore.kernel.org/lkml/
 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	[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 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®