From: Ronald Wahl <rwahl@gmx.de>
To: rwahl@gmx.de
Cc: linux-kernel@vger.kernel.org,
Ronald Wahl <ronald.wahl@raritan.com>,
Thomas Gleixner <tglx@linutronix.de>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
linux-arch@vger.kernel.org
Subject: [PATCH v2] stacktrace: check whether task has a stack before saving it
Date: Tue, 12 Dec 2023 19:55:18 +0100 [thread overview]
Message-ID: <20231212185518.196361-1-rwahl@gmx.de> (raw)
From: Ronald Wahl <ronald.wahl@raritan.com>
I encountered a crash on ARM32 when trying to dump the stack of some
zombie process. This is caused by a missing check whether the task
actually has a valid stack. This commit adds this check.
Commit 214d8ca6ee85 ("stacktrace: Provide common infrastructure")
introduced this check for platforms that define CONFIG_ARCH_STACKWALK
but ARM32 is not one of them.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-arch@vger.kernel.org
Signed-off-by: Ronald Wahl <ronald.wahl@raritan.com>
---
V2: - added missing put_task_stack(task) to avoid memory leak
kernel/stacktrace.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
index 9ed5ce989415..0bb67bd633c6 100644
--- a/kernel/stacktrace.c
+++ b/kernel/stacktrace.c
@@ -298,7 +298,11 @@ unsigned int stack_trace_save_tsk(struct task_struct *task,
.skip = skipnr + (current == task),
};
+ if (!try_get_task_stack(task))
+ return 0;
+
save_stack_trace_tsk(task, &trace);
+ put_task_stack(task);
return trace.nr_entries;
}
--
2.43.0
reply other threads:[~2023-12-12 18:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20231212185518.196361-1-rwahl@gmx.de \
--to=rwahl@gmx.de \
--cc=jpoimboe@redhat.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=ronald.wahl@raritan.com \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).