Skip to content

Commit

Permalink
kernel/sysctl_binary.c: check name array length in deprecated_sysctl_…
Browse files Browse the repository at this point in the history
…warning()

Prevent use of uninitialized memory (originating from the stack frame of
do_sysctl()) by verifying that the name array is filled with sufficient
input data before comparing its specific entries with integer constants.

Through timing measurement or analyzing the kernel debug logs, a
user-mode program could potentially infer the results of comparisons
against the uninitialized memory, and acquire some (very limited)
information about the state of the kernel stack.  The change also
eliminates possible future warnings by tools such as KMSAN and other
code checkers / instrumentations.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Mateusz Jurczyk <[email protected]>
Acked-by: Kees Cook <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Matthew Whitehead <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Tetsuo Handa <[email protected]>
Cc: Alexander Potapenko <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
j00ru authored and torvalds committed Jul 12, 2017
1 parent 7c43a65 commit 9380fa6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/sysctl_binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ static void deprecated_sysctl_warning(const int *name, int nlen)
* CTL_KERN/KERN_VERSION is used by older glibc and cannot
* ever go away.
*/
if (name[0] == CTL_KERN && name[1] == KERN_VERSION)
if (nlen >= 2 && name[0] == CTL_KERN && name[1] == KERN_VERSION)
return;

if (printk_ratelimit()) {
Expand Down

0 comments on commit 9380fa6

Please sign in to comment.