aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Perches <[email protected]>2019-12-04 16:50:53 -0800
committerLinus Torvalds <[email protected]>2019-12-04 19:44:12 -0800
commit5e1aada08cd19ea652b2d32a250501d09b02ff2e (patch)
treeb0722199d6d1f1b432a237e47f02cbb150f89dfa
parentef70eff9dea66f38f8c2c2dcc7fe4b7a2bbb4921 (diff)
kernel/sys.c: avoid copying possible padding bytes in copy_to_user
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. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Joe Perches <[email protected]> Cc: Dan Carpenter <[email protected]> Cc: Julia Lawall <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Kees Cook <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--kernel/sys.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/sys.c b/kernel/sys.c
index d3aef31e24dc..a9331f101883 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);