From: Jann Horn Date: Fri, 11 May 2018 00:19:01 +0000 (+0200) Subject: compat: fix 4-byte infoleak via uninitialized struct field X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ef7c4825fe5fe9ed251bda8d4c04d47fe33c3afb;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git compat: fix 4-byte infoleak via uninitialized struct field commit 0a0b98734479aa5b3c671d5190e86273372cab95 upstream. Commit 3a4d44b61625 ("ntp: Move adjtimex related compat syscalls to native counterparts") removed the memset() in compat_get_timex(). Since then, the compat adjtimex syscall can invoke do_adjtimex() with an uninitialized ->tai. If do_adjtimex() doesn't write to ->tai (e.g. because the arguments are invalid), compat_put_timex() then copies the uninitialized ->tai field to userspace. Fix it by adding the memset() back. Fixes: 3a4d44b61625 ("ntp: Move adjtimex related compat syscalls to native counterparts") Signed-off-by: Jann Horn Acked-by: Kees Cook Acked-by: Al Viro Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- diff --git a/kernel/compat.c b/kernel/compat.c index 772e038d04d9..7e83733d4c95 100644 --- a/kernel/compat.c +++ b/kernel/compat.c @@ -34,6 +34,7 @@ int compat_get_timex(struct timex *txc, const struct compat_timex __user *utp) { struct compat_timex tx32; + memset(txc, 0, sizeof(struct timex)); if (copy_from_user(&tx32, utp, sizeof(struct compat_timex))) return -EFAULT;