From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEA082417D1 for ; Tue, 31 Mar 2026 06:52:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774939955; cv=none; b=t1f4etA8pWIMuXw2auGubXQicsKA+Ds04VcRYsXFvcbjRoMC2IJyd1fkTRqeNzrwn3bZpl+K8mTlgCJlP+iZ1t7PG0e5qItFac53wTZbX+RA8oDrU89Cmfx5bRb1jDo78h8KIFfeTNEkkWQUny/vztMIJ6UVvwTJmjjYP97GFd4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774939955; c=relaxed/simple; bh=GH97M7sBAx04XiUkECm2S4QbjWh7O1iWzv7oi+z86lE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Eb6oI17aXzyTVw3+Gr27aDJHBmhPXsPvRLLXfMbECxGKvxyo6tfz7qTb92l5gy9P4fZxg4QYt3LwFUR+4MsWRs4MiiKaw8l8Ker+hVYrMMOJSad5PGAWcp9nrnbBwQfao7LMOcr3k5D3puhEIIFuifduVxdj6uDdCYdZuSG3FMc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=zGE6Qx0t; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=A/UUV+K/; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="zGE6Qx0t"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="A/UUV+K/" Date: Tue, 31 Mar 2026 08:52:30 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1774939951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WRzQ001/0Pq8JokfofvbOrXrS0BTW6Otv5/ii6ct4x8=; b=zGE6Qx0t5BOuaQRBixJXmPd0DBbU8naeSDpdf7tTFjXhYQap+ieX/wG+1k2oN6haQPR+Hs 4ZOMrLu83pXoh4wy5WYUVmt0ZJyvN5t2IFBsbBo1ZmACmzCx54ecT2nwqNthYp1uMxoXoy AESzHojwKHIRaOommS5ptvAc0annBgquVaX3XTO+JJ/NBndJ3sfVVqg2eGQLr/bsKuUbbh nURU48tF6tP5VewVSOpA82mU0QWj46LYSnz1LhOK/gzwVPS3418rjlyHwdEpnuRyjFaCPa Z7PWYrmDDnT03dknqKP9ht6Iw0KttUOjNkLkA+fIzFqEph8f4mQNtEtL87Fxog== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1774939951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WRzQ001/0Pq8JokfofvbOrXrS0BTW6Otv5/ii6ct4x8=; b=A/UUV+K/GMIh5FeKetNWjeJM4ncVqapfloWDDmVe6jFvEqEQS7lfa53Kh3X3wXTkd1Ycin pQm1MGa3S7FB33AQ== From: "bigeasy@linutronix.de" To: Maninder Singh Cc: "Russell King (Oracle)" , "peterz@infradead.org" , "kees@kernel.org" , "ardb@kernel.org" , "keithpac@amazon.com" , "linusw@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: RE: [PATCH 1/1] arm: get task_stack reference before dump_backtrace Message-ID: <20260331065230.9T3e_rt-@linutronix.de> References: <20260305070527.719073-1-maninder1.s@samsung.com> <20260309055328epcms5p56d16f6cb1e3a5295987c935f35be1d2e@epcms5p5> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline 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