Skip to contentSkip to conversation

stacktrace: check whether task has a stack before saving it

PATCH Superseded Ronald Wahl 3 participants 4 messages Oct 30, 2023 – Dec 11, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 stacktrace: check whether task has a stack before saving it

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.

---
 kernel/stacktrace.c | 3 +++
 1 file changed, 3 insertions(+)
kernel/stacktrace.c +3 -0
index 9ed5ce989415..38ae52349306 100644
@@ -298,6 +298,9 @@ 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);
 	return trace.nr_entries;
 }

--
2.41.0

Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Ronald Wahl

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.

Looks correct to me:

Yours,
Linus Walleij

#2 lore raw
Quoted 8 lines · Linus Walleij

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Quoted 4 lines · Ronald Wahl

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.

Quoted 8 lines
Quoted 5 lines

Commit 214d8ca6ee85 ("stacktrace: Provide common infrastructure") introduced this check for platforms that define CONFIG_ARCH_STACKWALK but ARM32 is not one of them.

Looks correct to me:

Unfortunately it causes a memory leak because I forgot to call put_task_stack(task) now. Should I post v2 or a separate patch?

- ron

________________________________

Ce message, ainsi que tous les fichiers joints à ce message, peuvent contenir des informations sensibles et/ ou confidentielles ne devant pas être divulguées. Si vous n'êtes pas le destinataire de ce message (ou que vous recevez ce message par erreur), nous vous remercions de le notifier immédiatement à son expéditeur, et de détruire ce message. Toute copie, divulgation, modification, utilisation ou diffusion, non autorisée, directe ou indirecte, de tout ou partie de ce message, est strictement interdite.

This e-mail, and any document attached hereby, may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized, direct or indirect, copying, disclosure, distribution or other use of the material or parts thereof is strictly forbidden.

#3 lore raw
Quoted 13 lines · Ronald Wahl
Quoted 12 lines · Linus Walleij

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Quoted 8 lines · Ronald Wahl

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.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Looks correct to me:

Unfortunately it causes a memory leak because I forgot to call put_task_stack(task) now. Should I post v2 or a separate patch?

Post a v2 I didn't see that anyone applied it?

Yours,
Linus Walleij