Jessica Yu ed3a67
From: Jessica Yu <jeyu@suse.de>
Jessica Yu ed3a67
Date: Mon, 15 Jun 2020 16:51:03 +0200
Jessica Yu ed3a67
Subject: panic: do not print uninitialized taint_flags
Jessica Yu ed3a67
Patch-mainline: Never, SUSE-specific
Jessica Yu ed3a67
References: bsc#1172814
Jessica Yu ed3a67
Jessica Yu ed3a67
In print_tainted(), the taint_flags array is iterated over and a character
Jessica Yu ed3a67
is printed depending on whether the taint bit is set (c_true and c_false).
Jessica Yu ed3a67
However, since TAINT_NO_SUPPORT is at the end of the taint_flags array, the
Jessica Yu ed3a67
uninitialized elements in-between are initialized to 0. Hence, the
Jessica Yu ed3a67
character for TAINT_NO_SUPPORT does not get printed as the first 0 in
Jessica Yu ed3a67
between serves as the null terminator for the taint string.
Jessica Yu ed3a67
Jessica Yu ed3a67
Fix that by skipping any uninitialized taint_flag structs in the
Jessica Yu ed3a67
taint_flags array.
Jessica Yu ed3a67
Jessica Yu ed3a67
Suggested-by: Michal Kubecek <mkubecek@suse.cz>
Jessica Yu ed3a67
Signed-off-by: Jessica Yu <jeyu@suse.de>
Jessica Yu ed3a67
---
Jessica Yu ed3a67
 kernel/panic.c | 3 +++
Jessica Yu ed3a67
 1 file changed, 3 insertions(+)
Jessica Yu ed3a67
Jessica Yu ed3a67
--- a/kernel/panic.c
Jessica Yu ed3a67
+++ b/kernel/panic.c
Jessica Yu ed3a67
@@ -412,6 +412,9 @@ const char *print_tainted(void)
Jessica Yu ed3a67
 		s = buf + sprintf(buf, "Tainted: ");
Jessica Yu ed3a67
 		for (i = 0; i < TAINT_FLAGS_COUNT; i++) {
Jessica Yu ed3a67
 			const struct taint_flag *t = &taint_flags[i];
Jessica Yu ed3a67
+
Jessica Yu ed3a67
+			if (!t->c_true)
Jessica Yu ed3a67
+				continue;
Jessica Yu ed3a67
 			*s++ = test_bit(i, &tainted_mask) ?
Jessica Yu ed3a67
 					t->c_true : t->c_false;
Jessica Yu ed3a67
 		}