linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] stacktrace: check whether task has a stack before saving it
@ 2023-10-30 17:58 Ronald Wahl
  2023-11-01 21:59 ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Ronald Wahl @ 2023-10-30 17:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Gleixner, 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.

Signed-off-by: Ronald Wahl <ronald.wahl@raritan.com>
---
 kernel/stacktrace.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
index 9ed5ce989415..38ae52349306 100644
--- a/kernel/stacktrace.c
+++ b/kernel/stacktrace.c
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] stacktrace: check whether task has a stack before saving it
  2023-10-30 17:58 [PATCH] stacktrace: check whether task has a stack before saving it Ronald Wahl
@ 2023-11-01 21:59 ` Linus Walleij
  2023-12-11 13:31   ` Ronald Wahl
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2023-11-01 21:59 UTC (permalink / raw)
  To: Ronald Wahl; +Cc: linux-kernel, Thomas Gleixner, Ronald Wahl

On Mon, Oct 30, 2023 at 6:59 PM Ronald Wahl <rwahl@gmx.de> wrote:

> 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.
>
> Signed-off-by: Ronald Wahl <ronald.wahl@raritan.com>

Looks correct to me:
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] stacktrace: check whether task has a stack before saving it
  2023-11-01 21:59 ` Linus Walleij
@ 2023-12-11 13:31   ` Ronald Wahl
  2023-12-11 23:52     ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Ronald Wahl @ 2023-12-11 13:31 UTC (permalink / raw)
  To: Linus Walleij, Ronald Wahl; +Cc: linux-kernel, Thomas Gleixner

On 01.11.23 22:59, Linus Walleij wrote:
> [You don't often get email from linus.walleij@linaro.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> On Mon, Oct 30, 2023 at 6:59 PM Ronald Wahl <rwahl@gmx.de> wrote:
>
>> 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.
>>
>> Signed-off-by: Ronald Wahl <ronald.wahl@raritan.com>
>
> Looks correct to me:
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] stacktrace: check whether task has a stack before saving it
  2023-12-11 13:31   ` Ronald Wahl
@ 2023-12-11 23:52     ` Linus Walleij
  0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2023-12-11 23:52 UTC (permalink / raw)
  To: Ronald Wahl; +Cc: Ronald Wahl, linux-kernel, Thomas Gleixner

On Mon, Dec 11, 2023 at 2:31 PM Ronald Wahl <ronald.wahl@raritan.com> wrote:

> On 01.11.23 22:59, Linus Walleij wrote:
> > [You don't often get email from linus.walleij@linaro.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> >
> > On Mon, Oct 30, 2023 at 6:59 PM Ronald Wahl <rwahl@gmx.de> wrote:
> >
> >> 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.
> >>
> >> Signed-off-by: Ronald Wahl <ronald.wahl@raritan.com>
> >
> > Looks correct to me:
> > Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
>
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-11 23:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-30 17:58 [PATCH] stacktrace: check whether task has a stack before saving it Ronald Wahl
2023-11-01 21:59 ` Linus Walleij
2023-12-11 13:31   ` Ronald Wahl
2023-12-11 23:52     ` Linus Walleij

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).