From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from hall.aurel32.net (hall.aurel32.net [195.154.119.183]) (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 E1C7D3A7198 for ; Tue, 23 Jun 2026 20:41:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.154.119.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782247317; cv=none; b=R7MyNFjjo6pa0I5ZTpmMzFPsv3t09bRhHnrW6LzhH7/6NWntOjuuuVNOCV77BXQhfeFUSoLHLGr3/jlFS5GSQ9Wkg5b86yHEd2gC/SEoBwryOGDY+epXHRlNVx/4tdBZ6fxq3PjDZ8YVZ9ejpaC2mozlTAo6KF+Ag1Uf2Q2Yhng= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782247317; c=relaxed/simple; bh=4Aeu5J+g0DeCz0l1tdUtfHpU6QtyksM99hZHL0Qfd/c=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=rcEdPAH2mGX8gApKiL6Tr4diCKQeXS+lh60USJJVATJiT2D3dlHAsRL4o70lKwuE0r3+uuSYQ/Eo8bbGIUXffdKWtFjRoB5Wa4SRgb+6D6xTBEjv5zOcshaY+vvUbHkXsja0U5HQ/J25YWdJVUR9wyWmd3uDYQer1ftGb9VDg5A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=aurel32.net; spf=pass smtp.mailfrom=aurel32.net; dkim=pass (2048-bit key) header.d=aurel32.net header.i=@aurel32.net header.b=hbLsGJ1U; arc=none smtp.client-ip=195.154.119.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=aurel32.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aurel32.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=aurel32.net header.i=@aurel32.net header.b="hbLsGJ1U" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=aurel32.net ; s=202004.hall; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date: Subject:Cc:To:From:Content-Type:From:Reply-To:Subject:Content-ID: Content-Description:In-Reply-To:References:X-Debbugs-Cc; bh=lv+vJNREaOn5aOwVpMHt0ri4HzzK+1NBESAp8W9uIc0=; b=hbLsGJ1Uai+53IxWB2xlba58YQ egjXjBPOFpsDBpCTUsEm9AVsydad5+xV06z7fa32GagL6xa9fNN0/0ZTJa9ccBYpVUsx75krbUQgH DVi6uGeKWYXr5HjFju5g/ZOoohs+5funzP0Cb3BsV627wJzVsgipR7LqdbPEzXnhh4N8rTQQIUcA7 HymHlvizR9M/ltcgNaBKVTKek96HxnI5oyTrgy9tfDnUZhobVeQ7y2trf8S7wac6v2bG1PhOLcP3y 5pO41rZA5kW50M+rBpBArnizxdjAHOGmLErAv+yFUnb92qB+eaq9dVJ1wKLi7JuHEnYNjYS48YyZZ DJ6dnkKg==; Received: from authenticated user by hall.aurel32.net with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wc7wD-00000004gJ2-3vII; Tue, 23 Jun 2026 22:41:41 +0200 From: Aurelien Jarno To: linux-kernel@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Jim Shu , Zong Li , Deepak Gupta Cc: Aurelien Jarno , Joel Stanley , linux-riscv@lists.infradead.org (open list:RISC-V ARCHITECTURE) Subject: [PATCH] arch/riscv: vdso: remove CFI landing pad from rt_sigreturn Date: Tue, 23 Jun 2026 22:40:57 +0200 Message-ID: <20260623204058.498120-1-aurelien@aurel32.net> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When CONFIG_RISCV_USER_CFI is enabled, the CFI version of the vDSO, has a CFI landing pad instruction at the start of __vdso_rt_sigreturn. This breaks libgcc's unwinding code which matches on the first two instructions. Other unwinders that rely on similar instruction matching may also be affected. Since __vdso_rt_sigreturn is reached as part of signal-return handling rather than via an indirect call/jump from userspace, it does not need a CFI landing pad. Remove it and restore the instruction sequence expected by existing unwinding code. This matches what was done on arm64 in commit 9a964285572b ("arm64: vdso: Don't prefix sigreturn trampoline with a BTI C instruction") for a similar issue. Fixes: 37f57bd3faea ("arch/riscv: compile vdso with landing pad and shadow stack note") Co-authored-by: Joel Stanley Signed-off-by: Aurelien Jarno --- arch/riscv/kernel/vdso/rt_sigreturn.S | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/riscv/kernel/vdso/rt_sigreturn.S b/arch/riscv/kernel/vdso/rt_sigreturn.S index e82987dc37394..f6b053d3bb798 100644 --- a/arch/riscv/kernel/vdso/rt_sigreturn.S +++ b/arch/riscv/kernel/vdso/rt_sigreturn.S @@ -7,11 +7,18 @@ #include #include +/* WARNING: Do NOT add a CFI landing pad at the start of this function. + * Unwinders such as libgcc identify the sigreturn trampoline by matching the + * instruction sequence. Adding a landing pad here would break unwinding from + * signal handlers. + * + * This trampoline is used only for signal return and not via an indirect + * call/jump from userspace, so adding CFI landing pad is unnecessary. + */ .text SYM_FUNC_START(__vdso_rt_sigreturn) .cfi_startproc .cfi_signal_frame - vdso_lpad li a7, __NR_rt_sigreturn ecall .cfi_endproc -- 2.53.0