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 B8D763CF213 for ; Thu, 2 Jul 2026 08:05:55 +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=1782979556; cv=none; b=lPQRffghvee3URDTUnnT10zZaZWokEIElcJR7oDn9cQYzt0T7bj/XOY/N4qF/CYai0dRrqoU9J4BybI0O6M3FiZ8oEPQfjNrgn8D893Aw5IvmU/GRRpnqt68AVTCJ7bX0ds5uFZUZ/HBQzxNN7j9wzOs0iHvSTL+zwIJGK69FKc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782979556; c=relaxed/simple; bh=EflMTjDnwMRFIoJlU4B8R/yxW1joWqzbEbwl1mYhKd0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=Wkk7dj5goif9LO/xH68REMNqPiD0f6zF22LNeY1h5tC7jndLhJ222YZzD5+9KLbxPxnTus4qi8rgfle8a5Ecyefpj5uYFnVaDWUj9W3Ikd9GHBr3Iz8WvzUUzOibVhQxb9oM+jbpu/1JCeFBkAExIj7LK5bVXJlNrRE38SPwbIA= 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=j2AJN2M3; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=anAp3VxZ; 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="j2AJN2M3"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="anAp3VxZ" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1782979553; 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=apPfLj+gjuzmcrLfZV7sgRMeKt4CRcU2qNQMbTTFI9U=; b=j2AJN2M3bKrt/J26eTY3rOSeGSjeFRbqlq7tSXIxoOQNIF6FsAQXYkaQGO4X3RO/IhSOWc 79ylhfi33BYdjD2jNMAY+doU1cD42JEyxujjDRvF0JM/+W3h5bcmjLqXX2o+TbpfNO6/N3 GKCLJcmguuoi3qCysFiBGY2WAMhswhBNSFlqHHAgEh9BbFbUwVKWw8tT/edfojB8BExllL PtGPXvI2e0M4DaOfWg+NbOHSNS0WdNzyOzS8KyWMGe0KWqhZl6r2bEXFBqFFLFySkspRsL firnjo/5y2JOwtbhR2bv7vN84bLO0zV1LFgcS7cfi0dyfibYDccZk2QULruL+A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1782979553; 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=apPfLj+gjuzmcrLfZV7sgRMeKt4CRcU2qNQMbTTFI9U=; b=anAp3VxZ8/TKdcujyX1qfRn0SKjeCQmsUPw+RQnPm6A3UWauqfE3VHUWYz3RZvy4cokTBS FQdxDHNBFHjfr4Cw== 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 Subject: Re: [PATCH v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe() In-Reply-To: <20260630090535.4103888-1-xujiakai2025@iscas.ac.cn> References: <20260630090535.4103888-1-xujiakai2025@iscas.ac.cn> Date: Thu, 02 Jul 2026 10:05:52 +0200 Message-ID: <87ik6xvmsf.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: > + 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 (task != current) { > + pr_warn("%s: sp (%lx) is not in task stack of %s\n", > + __func__, sp, task->comm); > + return; > + } > +#ifdef CONFIG_VMAP_STACK > + else { > + unsigned long ovf_base = > + (unsigned long)this_cpu_ptr(overflow_stack); > + > + if (sp >= ovf_base && sp < ovf_base + OVERFLOW_STACK_SIZE) > + high = ovf_base + OVERFLOW_STACK_SIZE; > + } > +#endif Looks functionally correct to me. But this #ifdef goes against the kernel's coding style. See: https://docs.kernel.org/process/coding-style.html Can we else if (IS_ENABLED(CONFIG_VMAP_STACK)) just like the irq stack thing? > + if (IS_ENABLED(CONFIG_IRQ_STACKS) && !high) { > + unsigned long irq_base = > + (unsigned long)this_cpu_read(irq_stack_ptr); > + > + if (sp >= irq_base && sp < irq_base + IRQ_STACK_SIZE) > + high = irq_base + IRQ_STACK_SIZE; > + }