compat: fix 4-byte infoleak via uninitialized struct field
authorJann Horn <jannh@google.com>
Fri, 11 May 2018 00:19:01 +0000 (02:19 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 May 2018 08:10:26 +0000 (10:10 +0200)
commitef7c4825fe5fe9ed251bda8d4c04d47fe33c3afb
tree24e3cb7999198d92daaa9e2a5b76bc47362777f7
parent50ed0188af8d1a40397ff5223e54e243ab763cad
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 <jannh@google.com>
Acked-by: Kees Cook <keescook@chromium.org>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/compat.c