public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kernel: sys.c: Avoid copying possible padding bytes in copy_to_user
@ 2019-10-26 19:46 Joe Perches
  2019-10-27  5:47 ` Julia Lawall
  2019-10-28  7:18 ` Dan Carpenter
  0 siblings, 2 replies; 7+ messages in thread
From: Joe Perches @ 2019-10-26 19:46 UTC (permalink / raw)
  To: Andrew Morton; +Cc: LKML, Dan Carpenter, Julia Lawall, Thomas Gleixner

Initialization is not guaranteed to zero padding bytes so
use an explicit memset instead to avoid leaking any kernel
content in any possible padding bytes.

Signed-off-by: Joe Perches <joe@perches.com>
---
 kernel/sys.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/sys.c b/kernel/sys.c
index a611d1..3459a5 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1279,11 +1279,13 @@ SYSCALL_DEFINE1(uname, struct old_utsname __user *, name)
 
 SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
 {
-	struct oldold_utsname tmp = {};
+	struct oldold_utsname tmp;
 
 	if (!name)
 		return -EFAULT;
 
+	memset(&tmp, 0, sizeof(tmp));
+
 	down_read(&uts_sem);
 	memcpy(&tmp.sysname, &utsname()->sysname, __OLD_UTS_LEN);
 	memcpy(&tmp.nodename, &utsname()->nodename, __OLD_UTS_LEN);


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

end of thread, other threads:[~2019-10-28 18:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-26 19:46 [PATCH] kernel: sys.c: Avoid copying possible padding bytes in copy_to_user Joe Perches
2019-10-27  5:47 ` Julia Lawall
2019-10-27 22:47   ` Joe Perches
2019-10-28  7:30     ` Dan Carpenter
2019-10-28 18:58     ` Kees Cook
2019-10-28  7:18 ` Dan Carpenter
2019-10-28  8:08   ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox