Skip to content

Commit 9380fa6

Browse files
j00rutorvalds
authored andcommitted
kernel/sysctl_binary.c: check name array length in deprecated_sysctl_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/20170524122139.21333-1-mjurczyk@google.com Signed-off-by: Mateusz Jurczyk <mjurczyk@google.com> Acked-by: Kees Cook <keescook@chromium.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Matthew Whitehead <tedheadster@gmail.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Alexander Potapenko <glider@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 7c43a65 commit 9380fa6

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎kernel/sysctl_binary.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ static void deprecated_sysctl_warning(const int *name, int nlen)
13461346
* CTL_KERN/KERN_VERSION is used by older glibc and cannot
13471347
* ever go away.
13481348
*/
1349-
if (name[0] == CTL_KERN && name[1] == KERN_VERSION)
1349+
if (nlen >= 2 && name[0] == CTL_KERN && name[1] == KERN_VERSION)
13501350
return;
13511351

13521352
if (printk_ratelimit()) {

0 commit comments

Comments
 (0)