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 4062C2D12EC for ; Sat, 27 Jun 2026 11:59:13 +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=1782561554; cv=none; b=bO/rZt+f032195YG0W2VivLQNLxLnt2et3p5tXOnMhVqlgngXsEFmw1Cq/7Dpa9hXrcrMXEK/qixlk3yoSjLlbfuad++BJtXKDMlhs3JhdcwF01VVnW/X9SFeU3dCtYbt6jiZs5xbAovv/pdMwWFD1mDpocXF3MH2c+YfIaKDHw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782561554; c=relaxed/simple; bh=Rj7gHHEaq1OZXfvrq1PJAw7w4i0DrksirWQawAb0e2E=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=AbK7fUfSfjq3APGq6hGes+S77qUpSw15KXxNfYuduwNDi9ubXcuUaNSTfo9mSB0uM+Fa/EwHzrOc1khXUGSHur/surcKwWdcsECnINxLARF55MORXGPw0AXpGMBtO//yV68m2JucNUFzxRQhgP+G9p/EHgDt/9qsJh+VgFXN7TU= 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=OJ2v7Saq; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Din2LXd2; 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="OJ2v7Saq"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Din2LXd2" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1782561551; 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=zz7muMR2y2m8wMPeJd2fbbBgpyba86ouaGupG4x7Onk=; b=OJ2v7SaqZ6p2uQKb1KB3sYtEkpDTUm1oJafzGknXxUnJmAU2jmE4dqxftkD5jQG9A1NYE0 LBexswRK7hivG/cQiCp8c3hLpKbcsDQYAPEghSu54+Pb2+gHmDA+J1yWUWWDgmZ+fn/o9o tS3m38Sh+2sLlF+PR9RpnSvsyfBR4/M+BIyZ0GqGELWJTOb7QrOx80V/ao20wrzflvClDv 562ptRRpSBRNkq+ZvwBNhTbN1q6RDFEZjypO9ii/LFNtvDdqmfpcRSmQM1IocBgg2pyXUi q5vqCDxK8Q4p9+Bkm+zGfMDIVEg0cEuGJyNbFiVro3+StiF3HNi1ITdqA4VkpQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1782561551; 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=zz7muMR2y2m8wMPeJd2fbbBgpyba86ouaGupG4x7Onk=; b=Din2LXd2lP45ltmSDRBkHblVW/HV823P+Pjn02dHUm/biMea0ZXle2IbTV3ECorgBK7zGc k0ZQMWGDG4hgJdBg== To: Jiakai Xu , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Albert Ou , Alexandre Ghiti , Chunyan Zhang , Jiakai Xu , Matthew Bystrin , Palmer Dabbelt , Paul Walmsley , Rui Qi , Samuel Holland , Jiakai Xu Subject: Re: [PATCH v3] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe() In-Reply-To: <20260625123906.211981-1-xujiakai2025@iscas.ac.cn> References: <20260625123906.211981-1-xujiakai2025@iscas.ac.cn> Date: Sat, 27 Jun 2026 13:59:10 +0200 Message-ID: <87zf0g42k1.fsf@yellow.woof> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Jiakai Xu writes: > +#ifdef CONFIG_IRQ_STACKS > +DECLARE_PER_CPU(ulong *, irq_stack_ptr); > +#endif Instead of this, shouldn't we #include ? > + if (sp >= (unsigned long)task_stack_page(task) && > + sp < (unsigned long)task_stack_page(task) + THREAD_SIZE) { > + high = (unsigned long)task_pt_regs(task); > + } else if (IS_ENABLED(CONFIG_IRQ_STACKS)) { > + high = (unsigned long)this_cpu_read(irq_stack_ptr) + > + IRQ_STACK_SIZE; I suspect this fails to build if CONFIG_IRQ_STACKS=n, which would be resolved if we do the suggested #include above. > + } else { > + high = (unsigned long)task_pt_regs(task); We only get to this branch if the stack pointer is broken, right? If so, I think printing a warning and returning is more appropriate. Nam