public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: "bigeasy@linutronix.de" <bigeasy@linutronix.de>
To: Maninder Singh <maninder1.s@samsung.com>
Cc: "Russell King (Oracle)" <linux@armlinux.org.uk>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"kees@kernel.org" <kees@kernel.org>,
	"ardb@kernel.org" <ardb@kernel.org>,
	"keithpac@amazon.com" <keithpac@amazon.com>,
	"linusw@kernel.org" <linusw@kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: RE: [PATCH 1/1] arm: get task_stack reference before dump_backtrace
Date: Tue, 31 Mar 2026 08:52:30 +0200	[thread overview]
Message-ID: <20260331065230.9T3e_rt-@linutronix.de> (raw)
In-Reply-To: <20260309055328epcms5p56d16f6cb1e3a5295987c935f35be1d2e@epcms5p5>

On 2026-03-09 11:23:28 [+0530], Maninder Singh wrote:
> Hi,
Hi,

> >"otherwise if someone calls show_stack() for task" ... and the stack
> >trace given stops at show_stack() and doesn't show the "someone".
> >
> >I'd like to know _how_ this happens, and why ARM64 and now 32-bit ARM
> >are different from x86.
> 
> I tried to simulate same thing on x86_64, it is also crashing.
> 
> Just a dummy code to save task_struct to reproduce the race:
> 
> +       rcu_read_lock();
> +       for_each_process(p) {
> +               if (!strcmp(p->comm, "sleep")) {
> +                       check_task = p;
> +                       get_task_struct(p);
> +                       pr_emerg("get done for %s %d\n", p->comm, p->pid);
> +               }
> +       }
> +       rcu_read_unlock();
> 
> // in mean time here sleep binary will be exited.
> 
> +       show_stack(check_task,  NULL, KERN_EMERG);

The task's stack is released on its final schedule() invocation.
Therefore holding task_struct does not hold the stack of the task if it
is separated out of task_struct and can be gone if the tasks quits.

Therefore holding a reference to the stack while accessing it, like
during a backtrace, makes sense and is required if the task is not
current.

Let me add this to my list and tackle it later today for x86. Then we
get probably Russell on board for ARM.

> //OOPs

Sebastian


  parent reply	other threads:[~2026-03-31  6:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20260305070534epcas5p378bb22ef9f1a895d7736ed2272c19ec6@epcas5p3.samsung.com>
2026-03-05  7:05 ` [PATCH 1/1] arm: get task_stack reference before dump_backtrace Maninder Singh
2026-03-08 23:39   ` Linus Walleij
2026-03-08 23:52   ` Russell King (Oracle)
2026-03-09  5:53     ` Maninder Singh
2026-03-09  5:55       ` Maninder Singh
2026-03-31  6:52       ` bigeasy [this message]
2026-03-31 12:16         ` Maninder Singh
2026-03-31  2:59     ` Maninder Singh

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=20260331065230.9T3e_rt-@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=ardb@kernel.org \
    --cc=kees@kernel.org \
    --cc=keithpac@amazon.com \
    --cc=linusw@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=maninder1.s@samsung.com \
    --cc=peterz@infradead.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