Skip to contentSkip to conversation

sysctl: don't read uninit memory in deprecated_sysctl_warning()

PATCH In review Alexander Potapenko 2 participants 2 messages Jun 28, 2017 – Jun 29, 2017 Proc sysctl

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sysctl: don't read uninit memory in deprecated_sysctl_warning()

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.

---
 kernel/sysctl_binary.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sysctl_binary.c +1 -1
index ece4b177052b..38d6ba22a209 100644
@@ -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()) {
Signature · 1 line
2.13.2.725.g09c95d1e9-goog