From: Sasha Levin Date: Tue, 14 May 2019 18:25:04 +0000 (-0400) Subject: fixes for 4.9 X-Git-Tag: v3.18.140~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=12552247a540c75f21d3a84e7c459598d4606dc0;p=thirdparty%2Fkernel%2Fstable-queue.git fixes for 4.9 Signed-off-by: Sasha Levin --- diff --git a/queue-4.9/revert-x86-vdso-drop-implicit-common-page-size-linke.patch b/queue-4.9/revert-x86-vdso-drop-implicit-common-page-size-linke.patch new file mode 100644 index 00000000000..2ad078db92a --- /dev/null +++ b/queue-4.9/revert-x86-vdso-drop-implicit-common-page-size-linke.patch @@ -0,0 +1,40 @@ +From 9c28ba88a67d922b065f2ff1b1ed7e323bbe18b7 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 14 May 2019 14:18:47 -0400 +Subject: Revert "x86/vdso: Drop implicit common-page-size linker flag" + +This reverts commit 408d67a0fecf4cfe7869f518211ae278ee44376e. + +The commit message in the 4.9 stable tree did not have a reference to +the upstream commit id. + +Signed-off-by: Sasha Levin +--- + arch/x86/entry/vdso/Makefile | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile +index 0d3ebdfa07396..cec8cb28eabae 100644 +--- a/arch/x86/entry/vdso/Makefile ++++ b/arch/x86/entry/vdso/Makefile +@@ -48,7 +48,7 @@ targets += $(vdso_img_sodbg) + export CPPFLAGS_vdso.lds += -P -C + + VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 --no-undefined \ +- -z max-page-size=4096 ++ -z max-page-size=4096 -z common-page-size=4096 + + $(obj)/vdso64.so.dbg: $(src)/vdso.lds $(vobjs) FORCE + $(call if_changed,vdso) +@@ -95,7 +95,7 @@ CFLAGS_REMOVE_vvar.o = -pg + + CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds) + VDSO_LDFLAGS_vdsox32.lds = -m elf32_x86_64 -soname linux-vdso.so.1 \ +- -z max-page-size=4096 ++ -z max-page-size=4096 -z common-page-size=4096 + + # 64-bit objects to re-brand as x32 + vobjs64-for-x32 := $(filter-out $(vobjs-nox32),$(vobjs-y)) +-- +2.20.1 + diff --git a/queue-4.9/revert-x86-vdso-use-ld-instead-of-cc-to-link.patch b/queue-4.9/revert-x86-vdso-use-ld-instead-of-cc-to-link.patch new file mode 100644 index 00000000000..037029903d1 --- /dev/null +++ b/queue-4.9/revert-x86-vdso-use-ld-instead-of-cc-to-link.patch @@ -0,0 +1,75 @@ +From 00bdbe4f9d2427a1102b175fb52e80ff995eaf33 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 14 May 2019 14:20:34 -0400 +Subject: Revert "x86: vdso: Use $LD instead of $CC to link" + +This reverts commit 94c0c4f033eee2304a98cf30a141f9dae35d3a62. + +The commit message in the 4.9 stable tree did not have a reference to +the upstream commit id. + +Signed-off-by: Sasha Levin +--- + arch/x86/entry/vdso/Makefile | 22 +++++++++++++--------- + 1 file changed, 13 insertions(+), 9 deletions(-) + +diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile +index 2ae92c6b1de6d..d5409660f5de6 100644 +--- a/arch/x86/entry/vdso/Makefile ++++ b/arch/x86/entry/vdso/Makefile +@@ -47,8 +47,10 @@ targets += $(vdso_img_sodbg) + + export CPPFLAGS_vdso.lds += -P -C + +-VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 --no-undefined \ +- -z max-page-size=4096 -z common-page-size=4096 ++VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \ ++ -Wl,--no-undefined \ ++ -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 \ ++ $(DISABLE_LTO) + + $(obj)/vdso64.so.dbg: $(src)/vdso.lds $(vobjs) FORCE + $(call if_changed,vdso) +@@ -94,8 +96,10 @@ CFLAGS_REMOVE_vvar.o = -pg + # + + CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds) +-VDSO_LDFLAGS_vdsox32.lds = -m elf32_x86_64 -soname linux-vdso.so.1 \ +- -z max-page-size=4096 -z common-page-size=4096 ++VDSO_LDFLAGS_vdsox32.lds = -Wl,-m,elf32_x86_64 \ ++ -Wl,-soname=linux-vdso.so.1 \ ++ -Wl,-z,max-page-size=4096 \ ++ -Wl,-z,common-page-size=4096 + + # 64-bit objects to re-brand as x32 + vobjs64-for-x32 := $(filter-out $(vobjs-nox32),$(vobjs-y)) +@@ -123,7 +127,7 @@ $(obj)/vdsox32.so.dbg: $(src)/vdsox32.lds $(vobjx32s) FORCE + $(call if_changed,vdso) + + CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds) +-VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1 ++VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-m,elf_i386 -Wl,-soname=linux-gate.so.1 + + # This makes sure the $(obj) subdirectory exists even though vdso32/ + # is not a kbuild sub-make subdirectory. +@@ -161,13 +165,13 @@ $(obj)/vdso32.so.dbg: FORCE \ + # The DSO images are built using a special linker script. + # + quiet_cmd_vdso = VDSO $@ +- cmd_vdso = $(LD) -nostdlib -o $@ \ ++ cmd_vdso = $(CC) -nostdlib -o $@ \ + $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \ +- -T $(filter %.lds,$^) $(filter %.o,$^) && \ ++ -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \ + sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@' + +-VDSO_LDFLAGS = -shared $(call ld-option, --hash-style=both) \ +- $(call ld-option, --build-id) -Bsymbolic ++VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=both) \ ++ $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS) + GCOV_PROFILE := n + + # +-- +2.20.1 + diff --git a/queue-4.9/series b/queue-4.9/series index 3c1e65742fe..18edea997b7 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -29,6 +29,10 @@ spi-st-st95hf-nfc-declare-missing-of-table.patch input-synaptics-rmi4-fix-possible-double-free.patch cw1200-fix-missing-unlock-on-error-in-cw1200_hw_scan.patch alsa-pcm-remove-sndrv_pcm_ioctl1_info-internal-command.patch -x86-vdso-pass-eh-frame-hdr-to-the-linker.patch rtlwifi-rtl8723ae-fix-missing-break-in-switch-statement.patch don-t-jump-to-compute_result-state-from-check_result-state.patch +revert-x86-vdso-drop-implicit-common-page-size-linke.patch +revert-x86-vdso-use-ld-instead-of-cc-to-link.patch +x86-vdso-use-ld-instead-of-cc-to-link.patch-23362 +x86-vdso-drop-implicit-common-page-size-linker-flag.patch +x86-vdso-pass-eh-frame-hdr-to-the-linker.patch diff --git a/queue-4.9/x86-vdso-drop-implicit-common-page-size-linker-flag.patch b/queue-4.9/x86-vdso-drop-implicit-common-page-size-linker-flag.patch new file mode 100644 index 00000000000..92bf83cf1f9 --- /dev/null +++ b/queue-4.9/x86-vdso-drop-implicit-common-page-size-linker-flag.patch @@ -0,0 +1,59 @@ +From 9660799313e4ce001ba1c489a34daa9d409df8ae Mon Sep 17 00:00:00 2001 +From: Nick Desaulniers +Date: Thu, 6 Dec 2018 11:12:31 -0800 +Subject: x86/vdso: Drop implicit common-page-size linker flag + +commit ac3e233d29f7f77f28243af0132057d378d3ea58 upstream. + +GNU linker's -z common-page-size's default value is based on the target +architecture. arch/x86/entry/vdso/Makefile sets it to the architecture +default, which is implicit and redundant. Drop it. + +Fixes: 2aae950b21e4 ("x86_64: Add vDSO for x86-64 with gettimeofday/clock_gettime/getcpu") +Reported-by: Dmitry Golovin +Reported-by: Bill Wendling +Suggested-by: Dmitry Golovin +Suggested-by: Rui Ueyama +Signed-off-by: Nick Desaulniers +Signed-off-by: Borislav Petkov +Acked-by: Andy Lutomirski +Cc: Andi Kleen +Cc: Fangrui Song +Cc: "H. Peter Anvin" +Cc: Ingo Molnar +Cc: Thomas Gleixner +Cc: x86-ml +Link: https://lkml.kernel.org/r/20181206191231.192355-1-ndesaulniers@google.com +Link: https://bugs.llvm.org/show_bug.cgi?id=38774 +Link: https://github.com/ClangBuiltLinux/linux/issues/31 +Signed-off-by: Nathan Chancellor +Signed-off-by: Sasha Levin +--- + arch/x86/entry/vdso/Makefile | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile +index 2ae92c6b1de6d..756dc9432d152 100644 +--- a/arch/x86/entry/vdso/Makefile ++++ b/arch/x86/entry/vdso/Makefile +@@ -48,7 +48,7 @@ targets += $(vdso_img_sodbg) + export CPPFLAGS_vdso.lds += -P -C + + VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 --no-undefined \ +- -z max-page-size=4096 -z common-page-size=4096 ++ -z max-page-size=4096 + + $(obj)/vdso64.so.dbg: $(src)/vdso.lds $(vobjs) FORCE + $(call if_changed,vdso) +@@ -95,7 +95,7 @@ CFLAGS_REMOVE_vvar.o = -pg + + CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds) + VDSO_LDFLAGS_vdsox32.lds = -m elf32_x86_64 -soname linux-vdso.so.1 \ +- -z max-page-size=4096 -z common-page-size=4096 ++ -z max-page-size=4096 + + # 64-bit objects to re-brand as x32 + vobjs64-for-x32 := $(filter-out $(vobjs-nox32),$(vobjs-y)) +-- +2.20.1 + diff --git a/queue-4.9/x86-vdso-use-ld-instead-of-cc-to-link.patch-23362 b/queue-4.9/x86-vdso-use-ld-instead-of-cc-to-link.patch-23362 new file mode 100644 index 00000000000..8be062955fb --- /dev/null +++ b/queue-4.9/x86-vdso-use-ld-instead-of-cc-to-link.patch-23362 @@ -0,0 +1,111 @@ +From ed73f65b29894c9d152ffd39538541d53d89abe1 Mon Sep 17 00:00:00 2001 +From: Alistair Strachan +Date: Fri, 3 Aug 2018 10:39:31 -0700 +Subject: x86: vdso: Use $LD instead of $CC to link + +commit 379d98ddf41344273d9718556f761420f4dc80b3 upstream. + +The vdso{32,64}.so can fail to link with CC=clang when clang tries to find +a suitable GCC toolchain to link these libraries with. + +/usr/bin/ld: arch/x86/entry/vdso/vclock_gettime.o: + access beyond end of merged section (782) + +This happens because the host environment leaked into the cross compiler +environment due to the way clang searches for suitable GCC toolchains. + +Clang is a retargetable compiler, and each invocation of it must provide +--target= --gcc-toolchain= to allow it to find the +correct binutils for cross compilation. These flags had been added to +KBUILD_CFLAGS, but the vdso code uses CC and not KBUILD_CFLAGS (for various +reasons) which breaks clang's ability to find the correct linker when cross +compiling. + +Most of the time this goes unnoticed because the host linker is new enough +to work anyway, or is incompatible and skipped, but this cannot be reliably +assumed. + +This change alters the vdso makefile to just use LD directly, which +bypasses clang and thus the searching problem. The makefile will just use +${CROSS_COMPILE}ld instead, which is always what we want. This matches the +method used to link vmlinux. + +This drops references to DISABLE_LTO; this option doesn't seem to be set +anywhere, and not knowing what its possible values are, it's not clear how +to convert it from CC to LD flag. + +Signed-off-by: Alistair Strachan +Signed-off-by: Thomas Gleixner +Acked-by: Andy Lutomirski +Cc: "H. Peter Anvin" +Cc: Greg Kroah-Hartman +Cc: kernel-team@android.com +Cc: joel@joelfernandes.org +Cc: Andi Kleen +Link: https://lkml.kernel.org/r/20180803173931.117515-1-astrachan@google.com +Signed-off-by: Nathan Chancellor +Signed-off-by: Sasha Levin +--- + arch/x86/entry/vdso/Makefile | 22 +++++++++------------- + 1 file changed, 9 insertions(+), 13 deletions(-) + +diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile +index d5409660f5de6..2ae92c6b1de6d 100644 +--- a/arch/x86/entry/vdso/Makefile ++++ b/arch/x86/entry/vdso/Makefile +@@ -47,10 +47,8 @@ targets += $(vdso_img_sodbg) + + export CPPFLAGS_vdso.lds += -P -C + +-VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \ +- -Wl,--no-undefined \ +- -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 \ +- $(DISABLE_LTO) ++VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -soname linux-vdso.so.1 --no-undefined \ ++ -z max-page-size=4096 -z common-page-size=4096 + + $(obj)/vdso64.so.dbg: $(src)/vdso.lds $(vobjs) FORCE + $(call if_changed,vdso) +@@ -96,10 +94,8 @@ CFLAGS_REMOVE_vvar.o = -pg + # + + CPPFLAGS_vdsox32.lds = $(CPPFLAGS_vdso.lds) +-VDSO_LDFLAGS_vdsox32.lds = -Wl,-m,elf32_x86_64 \ +- -Wl,-soname=linux-vdso.so.1 \ +- -Wl,-z,max-page-size=4096 \ +- -Wl,-z,common-page-size=4096 ++VDSO_LDFLAGS_vdsox32.lds = -m elf32_x86_64 -soname linux-vdso.so.1 \ ++ -z max-page-size=4096 -z common-page-size=4096 + + # 64-bit objects to re-brand as x32 + vobjs64-for-x32 := $(filter-out $(vobjs-nox32),$(vobjs-y)) +@@ -127,7 +123,7 @@ $(obj)/vdsox32.so.dbg: $(src)/vdsox32.lds $(vobjx32s) FORCE + $(call if_changed,vdso) + + CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds) +-VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-m,elf_i386 -Wl,-soname=linux-gate.so.1 ++VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1 + + # This makes sure the $(obj) subdirectory exists even though vdso32/ + # is not a kbuild sub-make subdirectory. +@@ -165,13 +161,13 @@ $(obj)/vdso32.so.dbg: FORCE \ + # The DSO images are built using a special linker script. + # + quiet_cmd_vdso = VDSO $@ +- cmd_vdso = $(CC) -nostdlib -o $@ \ ++ cmd_vdso = $(LD) -nostdlib -o $@ \ + $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \ +- -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \ ++ -T $(filter %.lds,$^) $(filter %.o,$^) && \ + sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@' + +-VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=both) \ +- $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS) ++VDSO_LDFLAGS = -shared $(call ld-option, --hash-style=both) \ ++ $(call ld-option, --build-id) -Bsymbolic + GCOV_PROFILE := n + + # +-- +2.20.1 +