diff options
author | Joe Perches <joe@perches.com> | 2019-12-04 16:50:53 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-10-01 13:14:29 +0200 |
commit | 489cee9124d53ce20fb3f989449efa2aa51a4b18 (patch) | |
tree | 2a9618fd57d6443480fd330a1e768d6825e7a7fa | |
parent | 6ce5dd69dc104b426c76664035b24987b74ae431 (diff) | |
download | linux-stable-489cee9124d53ce20fb3f989449efa2aa51a4b18.tar.gz linux-stable-489cee9124d53ce20fb3f989449efa2aa51a4b18.tar.bz2 linux-stable-489cee9124d53ce20fb3f989449efa2aa51a4b18.zip |
kernel/sys.c: avoid copying possible padding bytes in copy_to_user
[ Upstream commit 5e1aada08cd19ea652b2d32a250501d09b02ff2e ]
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/dfa331c00881d61c8ee51577a082d8bebd61805c.camel@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Cc: Dan Carpenter <error27@gmail.com>
Cc: Julia Lawall <julia.lawall@lip6.fr>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | kernel/sys.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index 096932a45046..baf60a3aa34b 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1275,11 +1275,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); |