Skip to content

Commit 8717b02

Browse files
H. Peter Anvinhansendc
authored andcommitted
x86/entry/vdso: Include GNU_PROPERTY and GNU_STACK PHDRs
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. Use symbolic constants for the PHDR permission flags. [ v4: drop unrelated formatting changes ] Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Link: https://patch.msgid.link/20251216212606.1325678-8-hpa@zytor.com
1 parent 8849616 commit 8717b02

1 file changed

Lines changed: 23 additions & 15 deletions

File tree

arch/x86/entry/vdso/common/vdso-layout.lds.S

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ SECTIONS
4747
*(.gnu.linkonce.b.*)
4848
} :text
4949

50-
/*
51-
* Discard .note.gnu.property sections which are unused and have
52-
* different alignment requirement from vDSO note sections.
53-
*/
54-
/DISCARD/ : {
50+
.note.gnu.property : {
5551
*(.note.gnu.property)
56-
}
57-
.note : { *(.note.*) } :text :note
58-
59-
.eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
60-
.eh_frame : { KEEP (*(.eh_frame)) } :text
52+
} :text :note :gnu_property
53+
.note : {
54+
*(.note*)
55+
} :text :note
6156

57+
.eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
58+
.eh_frame : {
59+
KEEP (*(.eh_frame))
60+
*(.eh_frame.*)
61+
} :text
6262

6363
/*
6464
* Text is well-separated from actual data: there's plenty of
@@ -87,15 +87,23 @@ SECTIONS
8787
* Very old versions of ld do not recognize this name token; use the constant.
8888
*/
8989
#define PT_GNU_EH_FRAME 0x6474e550
90+
#define PT_GNU_STACK 0x6474e551
91+
#define PT_GNU_PROPERTY 0x6474e553
9092

9193
/*
9294
* We must supply the ELF program headers explicitly to get just one
9395
* PT_LOAD segment, and set the flags explicitly to make segments read-only.
94-
*/
96+
*/
97+
#define PF_R FLAGS(4)
98+
#define PF_RW FLAGS(6)
99+
#define PF_RX FLAGS(5)
100+
95101
PHDRS
96102
{
97-
text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
98-
dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
99-
note PT_NOTE FLAGS(4); /* PF_R */
100-
eh_frame_hdr PT_GNU_EH_FRAME;
103+
text PT_LOAD PF_RX FILEHDR PHDRS;
104+
dynamic PT_DYNAMIC PF_R;
105+
note PT_NOTE PF_R;
106+
eh_frame_hdr PT_GNU_EH_FRAME PF_R;
107+
gnu_stack PT_GNU_STACK PF_RW;
108+
gnu_property PT_GNU_PROPERTY PF_R;
101109
}

0 commit comments

Comments
 (0)