From nobody Mon Feb 9 19:05:31 2026 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 787A7267AF2; Wed, 12 Nov 2025 04:38:49 +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=1762922333; cv=none; b=rAOZ0VSnvHEvpuOKQK9QyWjJqsTy0KYLWxxEWJ3rrvgCs+DJ7b+hzMYfJ1YPYUZ4P+zgfbTFlTVJFD5e75ujzdLdpznp92XJUpE356Kc98bOBg7WMcw5/uT/nCmdC1HHSQcgwAxh9dLyAeXL4MPoVLbqwliXfMQd2qkp7Y7rFPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762922333; c=relaxed/simple; bh=n8DS8/bVWfEAqP+RG4F4Zwx0jbai7PHujUHiYLIhE6k=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iROcXDYBVzy/3tZ5z4CQs2Rw12Ng5xI8B3nJfmQNWu2fTrQXX/kB0p4mTXTt446nS3mL0iOiN+JKF+D44Ss6fAG8uAiQx+IiXraGLRMoJ2pF4CWHyBy5BMAlvykdBJG1IRhGuCIBmvZAu5cilUIMu61+Tnf7GGBVHiz+9DyqiGU= 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=NY2cqwKa; 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="NY2cqwKa" Received: from mail.zytor.com (c-76-133-66-138.hsd1.ca.comcast.net [76.133.66.138]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 5AC4bYDS542538 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 11 Nov 2025 20:37:46 -0800 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 5AC4bYDS542538 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025102301; t=1762922267; bh=JZWb39kaxm/aTHHHAoGRq7ylnE7bG8wlHoUJFfzGXJY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NY2cqwKaIrKZUtfTvxfjn6R8wymEXPWHv7bYCi+aME4HmaudXcZTxAmPw5vWao3g7 LPA092rWorB2+oPLf8bRPnWf5jVZohiBbEFPMOzoUsWrk32k4PtN+0fvwXfzU6+U/u h6pVDUWk1TNQ02FdIyxmMiUTdM60BaRxbt4KgfjkkhgQgD4t9Ufb+CbC5h7sK/WdlY 4UmBUhsjz/0R9+ZJjl6AZpLqIZEcQd0M23JdbmIMP8PoXd/GqGdLG937KVnVjr4WId kJmFy4PbZrHDGH6h6bbnODmuUUz+EdIQI748dLPbJoE1xKdaCGb4TeT0yglAfgHCDn qsJkhlUpgl5eQ== From: "H. Peter Anvin" To: "H. Peter Anvin" , "Jason A. Donenfeld" , "Peter Zijlstra (Intel)" , "Theodore Ts'o" , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Xin Li , Andrew Cooper , Andy Lutomirski , Ard Biesheuvel , Borislav Petkov , Brian Gerst , Dave Hansen , Ingo Molnar , James Morse , Jarkko Sakkinen , Josh Poimboeuf , Kees Cook , Nam Cao , Oleg Nesterov , Perry Yuan , Thomas Gleixner , Thomas Huth , Uros Bizjak , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-sgx@vger.kernel.org, x86@kernel.org Subject: [PATCH v2 6/9] x86/entry/vdso: include GNU_PROPERTY and GNU_STACK PHDRs Date: Tue, 11 Nov 2025 20:37:24 -0800 Message-ID: <20251112043730.992152-7-hpa@zytor.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251112043730.992152-1-hpa@zytor.com> References: <20251112043730.992152-1-hpa@zytor.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently the vdso doesn't include .note.gnu.property or a GNU noexec stack annotation (the -z noexecstack in the linker script is ineffective because we specify PHDRs explicitly.) The motivation is that the dynamic linker currently do not check these. However, this is a weak excuse: the vdso*.so are also supposed to be usable at link libraries, and there is no reason why the dynamic linker might not want or need to check these in the future, so add them back in -- it is trivial enough. Signed-off-by: H. Peter Anvin (Intel) --- arch/x86/entry/vdso/common/vdso-layout.lds.S | 51 +++++++++++--------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/arch/x86/entry/vdso/common/vdso-layout.lds.S b/arch/x86/entry/= vdso/common/vdso-layout.lds.S index ec1ac191a057..696bacb99ed8 100644 --- a/arch/x86/entry/vdso/common/vdso-layout.lds.S +++ b/arch/x86/entry/vdso/common/vdso-layout.lds.S @@ -26,7 +26,7 @@ SECTIONS =20 . =3D SIZEOF_HEADERS; =20 - .hash : { *(.hash) } :text + .hash : { *(.hash) } :text .gnu.hash : { *(.gnu.hash) } .dynsym : { *(.dynsym) } .dynstr : { *(.dynstr) } @@ -34,7 +34,7 @@ SECTIONS .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } =20 - .dynamic : { *(.dynamic) } :text :dynamic + .dynamic : { *(.dynamic) } :text :dynamic =20 .rodata : { *(.rodata*) @@ -45,31 +45,28 @@ SECTIONS *(.bss*) *(.dynbss*) *(.gnu.linkonce.b.*) - } :text + } :text =20 - /* - * Discard .note.gnu.property sections which are unused and have - * different alignment requirement from vDSO note sections. - */ - /DISCARD/ : { + .note.gnu.property : { *(.note.gnu.property) - } - .note : { *(.note.*) } :text :note - - .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr - .eh_frame : { KEEP (*(.eh_frame)) } :text + } :text :note :gnu_property + .note : { + *(.note*) + } :text :note =20 + .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr + .eh_frame : { + KEEP (*(.eh_frame)) + *(.eh_frame.*) + } :text =20 /* * Text is well-separated from actual data: there's plenty of * stuff that isn't used at runtime in between. - */ - + */ .text : { *(.text*) - } :text =3D0x90909090, - - + } :text =3D0x90909090 =20 .altinstructions : { *(.altinstructions) } :text .altinstr_replacement : { *(.altinstr_replacement) } :text @@ -87,15 +84,23 @@ SECTIONS * Very old versions of ld do not recognize this name token; use the const= ant. */ #define PT_GNU_EH_FRAME 0x6474e550 +#define PT_GNU_STACK 0x6474e551 +#define PT_GNU_PROPERTY 0x6474e553 =20 /* * We must supply the ELF program headers explicitly to get just one * PT_LOAD segment, and set the flags explicitly to make segments read-onl= y. - */ +*/ +#define PF_R FLAGS(4) +#define PF_RW FLAGS(6) +#define PF_RX FLAGS(5) + PHDRS { - text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */ - dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ - note PT_NOTE FLAGS(4); /* PF_R */ - eh_frame_hdr PT_GNU_EH_FRAME; + text PT_LOAD PF_RX FILEHDR PHDRS; + dynamic PT_DYNAMIC PF_R; + note PT_NOTE PF_R; + eh_frame_hdr PT_GNU_EH_FRAME PF_R; + gnu_stack PT_GNU_STACK PF_RW; + gnu_property PT_GNU_PROPERTY PF_R; } --=20 2.51.1