From: John Stultz <jstultz@google.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: John Stultz <jstultz@google.com>,
Steven Rostedt <rostedt@goodmis.org>,
Alexander Potapenko <glider@google.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
kernel-team@android.com
Subject: [PATCH v3 2/2] lib: stackdepot: Avoid null pointer if stack_depot_save is called too early
Date: Wed, 18 Dec 2024 22:06:06 -0800 [thread overview]
Message-ID: <20241219060643.2360926-2-jstultz@google.com> (raw)
In-Reply-To: <20241219060643.2360926-1-jstultz@google.com>
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@goodmis.org>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: kernel-team@android.com
Signed-off-by: John Stultz <jstultz@google.com>
---
lib/stackdepot.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/stackdepot.c b/lib/stackdepot.c
index 245d5b4166999..1fe627584535d 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.1.613.gc27f4b7a9f-goog
next prev parent reply other threads:[~2024-12-19 6:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-19 6:06 [PATCH v3 1/2] lib: stacklog_debug: Introduce helper tool for collecting and displaying stacktraces John Stultz
2024-12-19 6:06 ` John Stultz [this message]
2024-12-19 14:22 ` Steven Rostedt
2025-01-02 22:18 ` John Stultz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241219060643.2360926-2-jstultz@google.com \
--to=jstultz@google.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=glider@google.com \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®