[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241116002322.1035417-2-jstultz@google.com>
Date: Fri, 15 Nov 2024 16:23:07 -0800
From: John Stultz <jstultz@...gle.com>
To: LKML <linux-kernel@...r.kernel.org>
Cc: John Stultz <jstultz@...gle.com>, Steven Rostedt <rostedt@...dmis.org>,
Alexander Potapenko <glider@...gle.com>, Andrey Konovalov <andreyknvl@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>, kernel-team@...roid.com
Subject: [PATCH v2 2/2] lib: stackdepot: Avoid null pointer if
stack_depot_save is called too early
If stack_depot_save is called before stackdepot has initialized
a null reference to the stack_table might be used, crashing the
system.
Instead, check stack_table has been initialized before going
further.
Cc: Steven Rostedt <rostedt@...dmis.org>
Cc: Alexander Potapenko <glider@...gle.com>
Cc: Andrey Konovalov <andreyknvl@...il.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: kernel-team@...roid.com
Signed-off-by: John Stultz <jstultz@...gle.com>
---
lib/stackdepot.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/stackdepot.c b/lib/stackdepot.c
index 5ed34cc963fc..09780c835362 100644
--- a/lib/stackdepot.c
+++ b/lib/stackdepot.c
@@ -611,6 +611,9 @@ depot_stack_handle_t stack_depot_save_flags(unsigned long *entries,
if (unlikely(nr_entries == 0) || stack_depot_disabled)
return 0;
+ if (!stack_table)
+ return 0;
+
hash = hash_stack(entries, nr_entries);
bucket = &stack_table[hash & stack_hash_mask];
--
2.47.0.338.g60cca15819-goog
Powered by blists - more mailing lists