From nobody Mon Jun 15 05:20:03 2026 Received: from va-1-111.ptr.blmpb.com (va-1-111.ptr.blmpb.com [209.127.230.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C612C298CAF for ; Wed, 8 Apr 2026 09:31:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.127.230.111 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775640686; cv=none; b=Dwhjsj/QelB15V8n+fASSWWSU1cQshR3lCKH4JVODUHCO1n7iX2tmIdiiVvdD+GHp9hm3vOochPP8+rsc/I39Z4RyTDEO3tL8iilVcjYP7j6lsS3y1Q1wn3kRUepOwuPWKx18L2YChwylDtiK/HJ8M5hjyok3Tw9qr48R9O8JzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775640686; c=relaxed/simple; bh=rAlsmpAa8GLxB7KXhhFPAOYcWcuGX0vtYAdsEccvESs=; h=Mime-Version:To:From:Subject:Message-Id:Cc:Date:Content-Type; b=tKyTANLWcDu89IdXv+HrQYofEkKJU5hggpwLN1rCHlzGM3hEKCDuKAitSBEerDw7VmUXoDEYY9Q3aGkZYES5h9K5Kc8RokVQgvw9stSjxzg4RlZ7Y+x8fJ7lOlpYehbpWB9zyHdQtkxcuOD+O7/zH0XNSt0WhJB868yyt1RG+BU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=cfhQ9O/j; arc=none smtp.client-ip=209.127.230.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="cfhQ9O/j" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1775640677; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=JKdvdbWvQjaY2kCvzSIVoR8XPkLrhKuJXTb+nrkhdZ0=; b=cfhQ9O/jUJ57HGeUKjDfGEZb/1kxji6Mi/j5lJl7YuZeuYXSp64gl+Y6kiTCAvrJ9VHp/a EYhmRrnyzeURLW2DZLdN5K5vSZEnEIcfL+lU0lh8Bh+VYbOL2Bm1JDIyHp9IHPzWMSw8id pv3+quKXkSoKc8kWeAeapNCnb3WXaK4oONSwx5YG5sVumNzijLlvqoXKk/PLIezbdIaG4J WHDFwyBTbIAWk9tx9Hr1++QPZjENSWSiOS9PmjRGsEVhxOcyjcPaBzWhXjN4tDVJlrYHTq yjr4mWL3rWuJwM05UrtQ101PvTa6FMunlmMxDXKKgx2OQBebRdArBPIX5eKeLg== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.52.0 X-Original-From: Rui Qi Content-Transfer-Encoding: quoted-printable To: , , , , , From: "Rui Qi" Subject: [PATCH] riscv: Fix ftrace_graph_ret_addr() to use the correct task pointer Message-Id: <20260408092915.46408-1-qirui.001@bytedance.com> X-Lms-Return-Path: Cc: , , "Rui Qi" Date: Wed, 8 Apr 2026 17:29:15 +0800 Content-Type: text/plain; charset="utf-8" The walk_stackframe() function is used to unwind the stack of a given task. When function graph tracing is enabled, ftrace_graph_ret_addr() is called to resolve the original return address if it was modified by the tracer. The current code incorrectly passes 'current' instead of 'task' to ftrace_graph_ret_addr(). This causes incorrect return address resolution when unwinding a stack of a different task (e.g., when the task is blocked in __switch_to). Fix this by passing 'task' instead of 'current' to match the behavior of other architectures (arm64, loongarch, powerpc, s390, x86). Signed-off-by: Rui Qi --- arch/riscv/kernel/stacktrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c index b41b6255751c..2692d3a06afa 100644 --- a/arch/riscv/kernel/stacktrace.c +++ b/arch/riscv/kernel/stacktrace.c @@ -87,7 +87,7 @@ void notrace walk_stackframe(struct task_struct *task, st= ruct pt_regs *regs, } else { fp =3D READ_ONCE_TASK_STACK(task, frame->fp); pc =3D READ_ONCE_TASK_STACK(task, frame->ra); - pc =3D ftrace_graph_ret_addr(current, &graph_idx, pc, + pc =3D ftrace_graph_ret_addr(task, &graph_idx, pc, &frame->ra); if (pc >=3D (unsigned long)handle_exception && pc < (unsigned long)&ret_from_exception_end) { --=20 2.20.1