2018-12-14 22:38:45

by Alistair Strachan

[permalink] [raw]
Subject: [PATCH v2] x86: vdso: Pass --eh-frame-hdr to ld

Commit 379d98ddf413 ("x86: vdso: Use $LD instead of $CC to link")
accidentally broke unwinding from userspace, because ld would strip the
.eh_frame sections when linking.

Originally, the compiler would implicitly add --eh-frame-hdr when
invoking the linker, but when this Makefile was converted from invoking
ld via the compiler, to invoking it directly (like vmlinux does),
the flag was missed. (The EH_FRAME section is important for the VDSO
shared libraries, but not for vmlinux.)

Fix the problem by explicitly specifying --eh-frame-hdr, which restores
parity with the old method.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201741
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1659295
Reported-by: Florian Weimer <[email protected]>
Reported-by: Carlos O'Donell <[email protected]>
Reported-by: "H. J. Lu" <[email protected]>
Tested-by: Laura Abbott <[email protected]>
Fixes: 379d98ddf413 ("x86: vdso: Use $LD instead of $CC to link")
Cc: [email protected]
Cc: Andy Lutomirski <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: X86 ML <[email protected]>
Cc: Joel Fernandes <[email protected]>
Cc: [email protected]
Signed-off-by: Alistair Strachan <[email protected]>
---
v2: Updated commit message, no changes to the code
arch/x86/entry/vdso/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 141d415a8c80..c3d7ccd25381 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -171,7 +171,8 @@ quiet_cmd_vdso = VDSO $@
sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'

VDSO_LDFLAGS = -shared $(call ld-option, --hash-style=both) \
- $(call ld-option, --build-id) -Bsymbolic
+ $(call ld-option, --build-id) $(call ld-option, --eh-frame-hdr) \
+ -Bsymbolic
GCOV_PROFILE := n

#
--
2.20.0.405.gbc1bbc6f85-goog



Subject: [tip:x86/urgent] x86/vdso: Pass --eh-frame-hdr to the linker

Commit-ID: cd01544a268ad8ee5b1dfe42c4393f1095f86879
Gitweb: https://git.kernel.org/tip/cd01544a268ad8ee5b1dfe42c4393f1095f86879
Author: Alistair Strachan <[email protected]>
AuthorDate: Fri, 14 Dec 2018 14:36:37 -0800
Committer: Borislav Petkov <[email protected]>
CommitDate: Sat, 15 Dec 2018 11:37:51 +0100

x86/vdso: Pass --eh-frame-hdr to the linker

Commit

379d98ddf413 ("x86: vdso: Use $LD instead of $CC to link")

accidentally broke unwinding from userspace, because ld would strip the
.eh_frame sections when linking.

Originally, the compiler would implicitly add --eh-frame-hdr when
invoking the linker, but when this Makefile was converted from invoking
ld via the compiler, to invoking it directly (like vmlinux does),
the flag was missed. (The EH_FRAME section is important for the VDSO
shared libraries, but not for vmlinux.)

Fix the problem by explicitly specifying --eh-frame-hdr, which restores
parity with the old method.

See relevant bug reports for additional info:

https://bugzilla.kernel.org/show_bug.cgi?id=201741
https://bugzilla.redhat.com/show_bug.cgi?id=1659295

Fixes: 379d98ddf413 ("x86: vdso: Use $LD instead of $CC to link")
Reported-by: Florian Weimer <[email protected]>
Reported-by: Carlos O'Donell <[email protected]>
Reported-by: "H. J. Lu" <[email protected]>
Signed-off-by: Alistair Strachan <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Tested-by: Laura Abbott <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Carlos O'Donell <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Joel Fernandes <[email protected]>
Cc: [email protected]
Cc: Laura Abbott <[email protected]>
Cc: stable <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: X86 ML <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
---
arch/x86/entry/vdso/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 0624bf2266fd..5bfe2243a08f 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -171,7 +171,8 @@ quiet_cmd_vdso = VDSO $@
sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'

VDSO_LDFLAGS = -shared $(call ld-option, --hash-style=both) \
- $(call ld-option, --build-id) -Bsymbolic
+ $(call ld-option, --build-id) $(call ld-option, --eh-frame-hdr) \
+ -Bsymbolic
GCOV_PROFILE := n

#