mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sysctl: don't read uninit memory in deprecated_sysctl_warning()
@ 2017-06-28 15:00 Alexander Potapenko
  2017-06-29 22:32 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Potapenko @ 2017-06-28 15:00 UTC (permalink / raw)
  To: dvyukov, kcc, davem, akpm; +Cc: linux-kernel

Don't attempt to read the first two elements of name[] unless they
were actually copied from the userspace.

This bug has been detected by KMSAN.

Signed-off-by: Alexander Potapenko <glider@google.com>
---
 kernel/sysctl_binary.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
index ece4b177052b..38d6ba22a209 100644
--- a/kernel/sysctl_binary.c
+++ b/kernel/sysctl_binary.c
@@ -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()) {
-- 
2.13.2.725.g09c95d1e9-goog

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-29 22:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-28 15:00 [PATCH] sysctl: don't read uninit memory in deprecated_sysctl_warning() Alexander Potapenko
2017-06-29 22:32 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®