Blob Blame History Raw
From: Jessica Yu <jeyu@suse.de>
Date: Mon, 15 Jun 2020 16:51:03 +0200
Subject: panic: do not print uninitialized taint_flags
Patch-mainline: Never, SUSE-specific
References: bsc#1172814

In print_tainted(), the taint_flags array is iterated over and a character
is printed depending on whether the taint bit is set (c_true and c_false).
However, since TAINT_NO_SUPPORT is at the end of the taint_flags array, the
uninitialized elements in-between are initialized to 0. Hence, the
character for TAINT_NO_SUPPORT does not get printed as the first 0 in
between serves as the null terminator for the taint string.

Fix that by skipping any uninitialized taint_flag structs in the
taint_flags array.

Suggested-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: Jessica Yu <jeyu@suse.de>
---
 kernel/panic.c | 3 +++
 1 file changed, 3 insertions(+)

--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -412,6 +412,9 @@ const char *print_tainted(void)
 		s = buf + sprintf(buf, "Tainted: ");
 		for (i = 0; i < TAINT_FLAGS_COUNT; i++) {
 			const struct taint_flag *t = &taint_flags[i];
+
+			if (!t->c_true)
+				continue;
 			*s++ = test_bit(i, &tainted_mask) ?
 					t->c_true : t->c_false;
 		}