From 5a4b17b19eded72fed54a984a73de3a95de51fd1 Mon Sep 17 00:00:00 2001
From: Jessica Yu <jeyu@suse.de>
Date: Mon, 15 Jun 2020 16:51:03 +0200
Subject: [PATCH] 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(+)
diff --git a/kernel/panic.c b/kernel/panic.c
index 7c6416ce56dc..a6b3ffe4e58c 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -395,6 +395,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;
}
--
2.16.4