Skip to contentSkip to conversation

s390/vdso: Fix GNU_EH_FRAME PHDR

PATCH Applied Jens Remus 2 participants 4 messages Jul 13 – Jul 20 s390

lore
Share & tools
lore

Jens Remus

author
#0 lore raw

v2 cover s390/vdso: Fix GNU_EH_FRAME PHDR

Patch 2 uses symbolic constants for the PHDR permission flags to improve readability and explicitly specifies the GNU_EH_FRAME PHDR to be read- only.

Changes to v2:
- Address review feedback.

Regards,
Jens

Jens Remus (2):
s390/vdso: Pass --eh-frame-hdr to the linker s390/vdso: Use symbolic constants for the PHDR permission flags

 arch/s390/kernel/vdso/Makefile   |  3 ++-
 arch/s390/kernel/vdso/vdso.lds.S | 11 +++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

base-commit: a13c140cc289c0b7b3770bce5b3ad42ab35074aa

Signature · 1 line
2.53.0
author
#1 lore raw

PATCH v2 1/2 s390/vdso: Pass --eh-frame-hdr to the linker

Commit 2b2a25845d53 ("s390/vdso: Use $(LD) instead of $(CC) to link vDSO") accidentally broke the GNU_EH_FRAME program table entry in the vDSO, causing it to be empty:

  $ readelf --program-headers arch/s390/kernel/vdso/vdso.so
  ...
  Program Headers:
    Type           Offset             VirtAddr           PhysAddr
                   FileSiz            MemSiz              Flags  Align
  ...
    GNU_EH_FRAME   0x0000000000000000 0x0000000000000000 0x0000000000000000
                   0x0000000000000000 0x0000000000000000         0x8
  ...

Originally, the compiler would implicitly add --eh-frame-hdr when invoking the linker, but when this Makefile was converted from invoking the linker via the compiler, to invoking it directly, the option was missed.

This is the s390 variant of x86 commit cd01544a268a ("x86/vdso: Pass --eh-frame-hdr to the linker").

Fixes 2b2a25845d53 ("s390/vdso: Use $(LD) instead of $(CC) to link vDSO")

---

Notes (jremus):
Changes in v2:
- Correct GNU_EH_FRAME PHDR name in commit message.

 arch/s390/kernel/vdso/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/s390/kernel/vdso/Makefile +2 -1
index fece5d975eaf..35c834b895ec 100644
@@ -30,7 +30,8 @@ KBUILD_CFLAGS_VDSO := $(filter-out -fno-asynchronous-unwind-tables,$(KBUILD_CFLA
 KBUILD_CFLAGS_VDSO += -fPIC -fno-common -fno-builtin -fasynchronous-unwind-tables
 KBUILD_CFLAGS_VDSO += -fno-stack-protector $(DISABLE_KSTACK_ERASE)
 ldflags-y := -shared -soname=linux-vdso.so.1 \
-	     --hash-style=both --build-id=sha1 -T
+	     --hash-style=both --build-id=sha1 \
+	     $(call ld-option, --eh-frame-hdr) -T
 
 $(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_VDSO)
 $(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_VDSO)
Signature · 1 line
2.53.0
author
#2 lore raw

PATCH v2 2/2 s390/vdso: Use symbolic constants for the PHDR permission flags

In reply to Jens Remus

While at it explicitly specify GNU_EH_FRAME PHDR to be read-only.

Inspired by x86 commit 8717b02b8c03 ("x86/entry/vdso: Include GNU_PROPERTY and GNU_STACK PHDRs").

---

Notes (jremus):
Changes in v2:
- Drop unused PF_RW. (Ilya)

 arch/s390/kernel/vdso/vdso.lds.S | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
arch/s390/kernel/vdso/vdso.lds.S +7 -4
index 7bec4de0e8e0..841daeec4be2 100644
@@ -82,12 +82,15 @@ SECTIONS
  * We must supply the ELF program headers explicitly to get just one
  * PT_LOAD segment, and set the flags explicitly to make segments read-only.
  */
+#define PF_R	FLAGS(4)
+#define PF_RX	FLAGS(5)
+
 PHDRS
 {
-	text		PT_LOAD FILEHDR PHDRS FLAGS(5);	/* 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;
 }
 
 /*
Signature · 1 line
2.53.0
maintainer Applied
#3 lore raw
In reply to Jens Remus
Quoted 11 lines · Jens Remus

Patch 2 uses symbolic constants for the PHDR permission flags to improve readability and explicitly specifies the GNU_EH_FRAME PHDR to be read- only.

Changes to v2:
- Address review feedback.

Regards,
Jens

Quoted 7 lines

Jens Remus (2):
s390/vdso: Pass --eh-frame-hdr to the linker s390/vdso: Use symbolic constants for the PHDR permission flags

 arch/s390/kernel/vdso/Makefile   |  3 ++-
 arch/s390/kernel/vdso/vdso.lds.S | 11 +++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

Applied, thank you!