From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.zytor.com (terminus.zytor.com [198.137.202.136]) (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 CE95C234973 for ; Fri, 27 Feb 2026 01:03:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.136 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772154216; cv=none; b=Ee4y6NhNDzuMqmrQjThP6RsuFN1KsqwJkYput48vNLBGXU3gNNuU3IYZOvMnWbYgQVhjUyawpS0yOBhSD7rPXE5taRD03oYXiO41z/yF8llm2tHVJapU9EaI2OEqaJlfxwYK33xV/L0timq5zhPIIvD/Z2+bodg5w+/h0UlNBMI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772154216; c=relaxed/simple; bh=+KOYL2sT7iW/ZywMi1LO1Vd1s2PRwVALRPvbet3B70I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WZqWoEJ3ky0DmX4sEdkmIjaLtWijS/t6eZh6ULMFdOJhl9eRQEKGWFjw6/acxXpdmFDxuQo1SbaWICgsW/o1tSakGg23UQY9Ce/YHKUwJ07Qw2zy95FwA3JF9hOs77az76WkqKfjiA0pP9wo9hTtqUUkocrJmTLckuZs9gXwN2k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com; spf=pass smtp.mailfrom=zytor.com; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b=ACHNQnUL; arc=none smtp.client-ip=198.137.202.136 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zytor.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b="ACHNQnUL" Received: from mail.zytor.com ([IPv6:2601:646:8081:9481:5d8c:3981:b6c0:d3f8]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 61R13DAs492694 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 26 Feb 2026 17:03:14 -0800 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 61R13DAs492694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2026022301; t=1772154196; bh=lhW0f26SrQidS5GMBqh87TKQEcZ+r7vZ3ESMPEEwYac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ACHNQnULY08WeStxqDPI/w32Jcx1tqo7ZD942Ob1vwkJJVNMfLCNq0MejFJYbEiv7 SqSO9AQZXCEsrsn1VtR4gMeDa/j7rA7Wq5RNqovAQmoBT/PtjHs4kXglAcAMyHaZtn zxoOWfg3LOfSQSCOasxZ7jKRwidWzQjgpuhhqyUBJTTSw/rZfp4Gfw8+s+j3dns6Um lKgaB5XGq5+YLUQApOZbXR/8fZc+9lkD2xN2j3zTrF27HcM3XUyMHeq2zcGiqb9vLB AkUuLBEVCUhC1movpxKGvlYptnPTU1k3WwMT33sLwOZyn7vm9pUqjM6KH9I5sEK3+t 6T6jwOzf+cHMA== From: "H. Peter Anvin" To: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen Cc: "H. Peter Anvin" , x86@kernel.org, Nathan Chancellor , Xi Ruoyao , linux-kernel@vger.kernel.org Subject: [PATCH FIX v2 1/1] x86/entry/vdso32: Work around libgcc unwinder bug Date: Thu, 26 Feb 2026 17:03:07 -0800 Message-ID: <20260227010308.310342-1-hpa@zytor.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260227004533.288926-1-hpa@zytor.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The unwinder code in libgcc has a long standing bug which causes it to fail to pick up the signal frame CFI flag. This is a generic bug across all platforms. It affects the __kernel_sigreturn and __kernel_rt_sigreturn vdso entry points on i386. The x86-64 kernel doesn't provide a sigreturn stub, and so there is no kernel-provided code that is affected on x86-64. libgcc does have a legacy fallback path which happens to work as long as the bytes immediately before each of the sigreturn functions fall outside any function. This patch adds a nop before the ALIGN to each of the sigreturn stubs to ensure that this is, indeed, the case. The rest of the patch is just a comment which documents the invariants that need to be maintained for this legacy path to work correctly. This is a manifest bug: in the current vdso, __kernel_vsyscall is a multiple of 16 bytes long and thus __kernel_sigreturn does not have any padding in front of it. [ v2: minor comment fixes ] Reported-by: Xi Ruoyao Closes: https://lore.kernel.org/lkml/f3412cc3e8f66d1853cc9d572c0f2fab076872b1.camel@xry111.site Fixes: 884961618ee5 ("x86/entry/vdso32: Remove open-coded DWARF in sigreturn.S") Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124050 Signed-off-by: H. Peter Anvin (Intel) --- arch/x86/entry/vdso/vdso32/sigreturn.S | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/arch/x86/entry/vdso/vdso32/sigreturn.S b/arch/x86/entry/vdso/vdso32/sigreturn.S index b433353bc8e3..b33fcc501ba3 100644 --- a/arch/x86/entry/vdso/vdso32/sigreturn.S +++ b/arch/x86/entry/vdso/vdso32/sigreturn.S @@ -35,9 +35,38 @@ #endif .endm +/* + * WARNING: + * + * A bug in the libgcc unwinder as of at least gcc 15.2 (2026) means that + * the unwinder fails to recognize the signal frame flag. + * + * There is a hacky legacy fallback path in libgcc which ends up + * getting invoked instead. It happens to work as long as BOTH of the + * following conditions are true: + * + * 1. There is at least one byte before the each of the sigreturn + * functions which falls outside any function. This is enforced by + * an explicit nop instruction before the ALIGN. + * 2. The code sequences between the entry point up to and including + * the int $0x80 below need to match EXACTLY. Do not change them + * in any way. The exact byte sequences are: + * + * __kernel_sigreturn: + * 0: 58 pop %eax + * 1: b8 77 00 00 00 mov $0x77,%eax + * 6: cd 80 int $0x80 + * + * __kernel_rt_sigreturn: + * 0: b8 ad 00 00 00 mov $0xad,%eax + * 5: cd 80 int $0x80 + * + * For details, see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124050 + */ .text .globl __kernel_sigreturn .type __kernel_sigreturn,@function + nop /* libgcc hack: see comment above */ ALIGN __kernel_sigreturn: STARTPROC_SIGNAL_FRAME IA32_SIGFRAME_sigcontext @@ -52,6 +81,7 @@ SYM_INNER_LABEL(vdso32_sigreturn_landing_pad, SYM_L_GLOBAL) .globl __kernel_rt_sigreturn .type __kernel_rt_sigreturn,@function + nop /* libgcc hack: see comment above */ ALIGN __kernel_rt_sigreturn: STARTPROC_SIGNAL_FRAME IA32_RT_SIGFRAME_sigcontext -- 2.53.0