linux-csky.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vdso: Improve cmd_vdso_check to check all dynamic relocations
@ 2022-08-30 19:37 Fangrui Song
  2022-09-10  7:53 ` Fangrui Song
  0 siblings, 1 reply; 13+ messages in thread
From: Fangrui Song @ 2022-08-30 19:37 UTC (permalink / raw)
  To: Vincenzo Frascino, Thomas Gleixner, linux-arm-kernel,
	linux-kernel, linux-csky, loongarch, linux-mips, linuxppc-dev,
	linux-riscv, linux-s390
  Cc: Fangrui Song

The actual intention is that no dynamic relocation exists. However, some
GNU ld ports produce unneeded R_*_NONE. (If a port is not care enough to
determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE
relocations. E.g. powerpc64le ld as of 2.38 has the issue with
defconfig.) R_*_NONE are generally no-op in the dynamic loaders. So just
ignore them.

With the change, we can remove ARCH_REL_TYPE_ABS. ARCH_REL_TYPE_ABS is a
bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are
not called "absolute relocations". (The patch is motivated by the arm64
port missing R_AARCH64_RELATIVE.)

While here, replace "egrep" with "grep" as "egrep" is deprecated in GNU
grep 3.7.

Signed-off-by: Fangrui Song <maskray@google.com>
---
 arch/arm/vdso/Makefile            |  3 ---
 arch/arm64/kernel/vdso/Makefile   |  3 ---
 arch/arm64/kernel/vdso32/Makefile |  3 ---
 arch/csky/kernel/vdso/Makefile    |  3 ---
 arch/loongarch/vdso/Makefile      |  3 ---
 arch/mips/vdso/Makefile           |  3 ---
 arch/powerpc/kernel/vdso/Makefile |  1 -
 arch/riscv/kernel/vdso/Makefile   |  3 ---
 arch/s390/kernel/vdso32/Makefile  |  2 --
 arch/s390/kernel/vdso64/Makefile  |  2 --
 arch/x86/entry/vdso/Makefile      |  4 ----
 lib/vdso/Makefile                 | 13 ++++---------
 12 files changed, 4 insertions(+), 39 deletions(-)

diff --git a/arch/arm/vdso/Makefile b/arch/arm/vdso/Makefile
index 8ca1c9f262a2..5ebd2e6f7d46 100644
--- a/arch/arm/vdso/Makefile
+++ b/arch/arm/vdso/Makefile
@@ -1,8 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
 
-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
-# the inclusion of generic Makefile.
-ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32
 include $(srctree)/lib/vdso/Makefile
 
 hostprogs := vdsomunge
diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile
index bafbf78fab77..66dc4f338a86 100644
--- a/arch/arm64/kernel/vdso/Makefile
+++ b/arch/arm64/kernel/vdso/Makefile
@@ -6,9 +6,6 @@
 # Heavily based on the vDSO Makefiles for other archs.
 #
 
-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
-# the inclusion of generic Makefile.
-ARCH_REL_TYPE_ABS := R_AARCH64_JUMP_SLOT|R_AARCH64_GLOB_DAT|R_AARCH64_ABS64
 include $(srctree)/lib/vdso/Makefile
 
 obj-vdso := vgettimeofday.o note.o sigreturn.o
diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index 36c8f66cad25..48d713d59ef2 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -3,9 +3,6 @@
 # Makefile for vdso32
 #
 
-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
-# the inclusion of generic Makefile.
-ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32
 include $(srctree)/lib/vdso/Makefile
 
 # Same as cc-*option, but using CC_COMPAT instead of CC
diff --git a/arch/csky/kernel/vdso/Makefile b/arch/csky/kernel/vdso/Makefile
index 0b6909f10667..86c8c4de1b0f 100644
--- a/arch/csky/kernel/vdso/Makefile
+++ b/arch/csky/kernel/vdso/Makefile
@@ -1,8 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
-# the inclusion of generic Makefile.
-ARCH_REL_TYPE_ABS := R_CKCORE_ADDR32|R_CKCORE_JUMP_SLOT
 include $(srctree)/lib/vdso/Makefile
 
 # Symbols present in the vdso
diff --git a/arch/loongarch/vdso/Makefile b/arch/loongarch/vdso/Makefile
index d89e2ac75f7b..1b2e0f149f55 100644
--- a/arch/loongarch/vdso/Makefile
+++ b/arch/loongarch/vdso/Makefile
@@ -1,9 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 # Objects to go into the VDSO.
 
-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
-# the inclusion of generic Makefile.
-ARCH_REL_TYPE_ABS := R_LARCH_32|R_LARCH_64|R_LARCH_MARK_LA|R_LARCH_JUMP_SLOT
 include $(srctree)/lib/vdso/Makefile
 
 obj-vdso-y := elf.o vgetcpu.o vgettimeofday.o sigreturn.o
diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile
index f72658b3a53f..cea97abffc03 100644
--- a/arch/mips/vdso/Makefile
+++ b/arch/mips/vdso/Makefile
@@ -4,9 +4,6 @@
 # Sanitizer runtimes are unavailable and cannot be linked here.
  KCSAN_SANITIZE			:= n
 
-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
-# the inclusion of generic Makefile.
-ARCH_REL_TYPE_ABS := R_MIPS_JUMP_SLOT|R_MIPS_GLOB_DAT
 include $(srctree)/lib/vdso/Makefile
 
 obj-vdso-y := elf.o vgettimeofday.o sigreturn.o
diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
index 096b0bf1335f..d3c5be32034d 100644
--- a/arch/powerpc/kernel/vdso/Makefile
+++ b/arch/powerpc/kernel/vdso/Makefile
@@ -2,7 +2,6 @@
 
 # List of files in the vdso, has to be asm only for now
 
-ARCH_REL_TYPE_ABS := R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_PPC_ADDR16|R_PPC_ADDR16_LO|R_PPC_ADDR16_HI|R_PPC_ADDR16_HA|R_PPC_ADDR14|R_PPC_ADDR14_BRTAKEN|R_PPC_ADDR14_BRNTAKEN|R_PPC_REL24
 include $(srctree)/lib/vdso/Makefile
 
 obj-vdso32 = sigtramp32-32.o gettimeofday-32.o datapage-32.o cacheflush-32.o note-32.o getcpu-32.o
diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
index f2e065671e4d..77d6bed3a700 100644
--- a/arch/riscv/kernel/vdso/Makefile
+++ b/arch/riscv/kernel/vdso/Makefile
@@ -1,9 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 # Copied from arch/tile/kernel/vdso/Makefile
 
-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
-# the inclusion of generic Makefile.
-ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOT
 include $(srctree)/lib/vdso/Makefile
 # Symbols present in the vdso
 vdso-syms  = rt_sigreturn
diff --git a/arch/s390/kernel/vdso32/Makefile b/arch/s390/kernel/vdso32/Makefile
index 245bddfe9bc0..e795fdbbf484 100644
--- a/arch/s390/kernel/vdso32/Makefile
+++ b/arch/s390/kernel/vdso32/Makefile
@@ -2,8 +2,6 @@
 # List of files in the vdso
 
 KCOV_INSTRUMENT := n
-ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE
-ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT
 
 include $(srctree)/lib/vdso/Makefile
 obj-vdso32 = vdso_user_wrapper-32.o note-32.o
diff --git a/arch/s390/kernel/vdso64/Makefile b/arch/s390/kernel/vdso64/Makefile
index 9e2b95a222a9..47dbbfdfad68 100644
--- a/arch/s390/kernel/vdso64/Makefile
+++ b/arch/s390/kernel/vdso64/Makefile
@@ -2,8 +2,6 @@
 # List of files in the vdso
 
 KCOV_INSTRUMENT := n
-ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE
-ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT
 
 include $(srctree)/lib/vdso/Makefile
 obj-vdso64 = vdso_user_wrapper.o note.o
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 12f6c4d714cd..a97f3630ca20 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -3,10 +3,6 @@
 # Building vDSO images for x86.
 #
 
-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
-# the inclusion of generic Makefile.
-ARCH_REL_TYPE_ABS := R_X86_64_JUMP_SLOT|R_X86_64_GLOB_DAT|R_X86_64_RELATIVE|
-ARCH_REL_TYPE_ABS += R_386_GLOB_DAT|R_386_JMP_SLOT|R_386_RELATIVE
 include $(srctree)/lib/vdso/Makefile
 
 # Sanitizer runtimes are unavailable and cannot be linked here.
diff --git a/lib/vdso/Makefile b/lib/vdso/Makefile
index c415a685d61b..9f031eafc465 100644
--- a/lib/vdso/Makefile
+++ b/lib/vdso/Makefile
@@ -5,18 +5,13 @@ GENERIC_VDSO_DIR := $(dir $(GENERIC_VDSO_MK_PATH))
 
 c-gettimeofday-$(CONFIG_GENERIC_GETTIMEOFDAY) := $(addprefix $(GENERIC_VDSO_DIR), gettimeofday.c)
 
-# This cmd checks that the vdso library does not contain absolute relocation
+# This cmd checks that the vdso library does not contain dynamic relocations.
 # It has to be called after the linking of the vdso library and requires it
 # as a parameter.
 #
-# $(ARCH_REL_TYPE_ABS) is defined in the arch specific makefile and corresponds
-# to the absolute relocation types printed by "objdump -R" and accepted by the
-# dynamic linker.
-ifndef ARCH_REL_TYPE_ABS
-$(error ARCH_REL_TYPE_ABS is not set)
-endif
-
+# As a workaround for some GNU ld ports which produce unneeded R_*_NONE
+# dynamic relocations, ignore R_*_NONE.
 quiet_cmd_vdso_check = VDSOCHK $@
-      cmd_vdso_check = if $(OBJDUMP) -R $@ | egrep -h "$(ARCH_REL_TYPE_ABS)"; \
+      cmd_vdso_check = if $(READELF) -rW $@ | grep -v _NONE | grep -q " R_\w*_"; \
 		       then (echo >&2 "$@: dynamic relocations are not supported"; \
 			     rm -f $@; /bin/false); fi
-- 
2.37.2.672.g94769d06f0-goog


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] vdso: Improve cmd_vdso_check to check all dynamic relocations
  2022-08-30 19:37 [PATCH] vdso: Improve cmd_vdso_check to check all dynamic relocations Fangrui Song
@ 2022-09-10  7:53 ` Fangrui Song
  2022-09-28  5:25   ` Fangrui Song
  0 siblings, 1 reply; 13+ messages in thread
From: Fangrui Song @ 2022-09-10  7:53 UTC (permalink / raw)
  To: Vincenzo Frascino, Thomas Gleixner, linux-arm-kernel,
	linux-kernel, linux-csky, loongarch, linux-mips, linuxppc-dev,
	linux-riscv, linux-s390

On 2022-08-30, Fangrui Song wrote:
>The actual intention is that no dynamic relocation exists. However, some
>GNU ld ports produce unneeded R_*_NONE. (If a port is not care enough to
>determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE
>relocations. E.g. powerpc64le ld as of 2.38 has the issue with
>defconfig.) R_*_NONE are generally no-op in the dynamic loaders. So just
>ignore them.
>
>With the change, we can remove ARCH_REL_TYPE_ABS. ARCH_REL_TYPE_ABS is a
>bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are
>not called "absolute relocations". (The patch is motivated by the arm64
>port missing R_AARCH64_RELATIVE.)
>
>While here, replace "egrep" with "grep" as "egrep" is deprecated in GNU
>grep 3.7.
>
>Signed-off-by: Fangrui Song <maskray@google.com>
>---
>[...]
>

Ping.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] vdso: Improve cmd_vdso_check to check all dynamic relocations
  2022-09-10  7:53 ` Fangrui Song
@ 2022-09-28  5:25   ` Fangrui Song
  2022-11-14 12:31     ` Christophe Leroy
  0 siblings, 1 reply; 13+ messages in thread
From: Fangrui Song @ 2022-09-28  5:25 UTC (permalink / raw)
  To: Vincenzo Frascino, Thomas Gleixner
  Cc: linux-arm-kernel, linux-kernel, linux-riscv, linux-mips,
	linux-csky, loongarch, linuxppc-dev, linux-s390

On Sat, Sep 10, 2022 at 12:53 AM Fangrui Song <maskray@google.com> wrote:
>
> On 2022-08-30, Fangrui Song wrote:
> >The actual intention is that no dynamic relocation exists. However, some
> >GNU ld ports produce unneeded R_*_NONE. (If a port is not care enough to
> >determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE
> >relocations. E.g. powerpc64le ld as of 2.38 has the issue with
> >defconfig.) R_*_NONE are generally no-op in the dynamic loaders. So just
> >ignore them.
> >
> >With the change, we can remove ARCH_REL_TYPE_ABS. ARCH_REL_TYPE_ABS is a
> >bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are
> >not called "absolute relocations". (The patch is motivated by the arm64
> >port missing R_AARCH64_RELATIVE.)
> >
> >While here, replace "egrep" with "grep" as "egrep" is deprecated in GNU
> >grep 3.7.
> >
> >Signed-off-by: Fangrui Song <maskray@google.com>
> >---
> >[...]
> >
>
> Ping.

Ping^2 :)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] vdso: Improve cmd_vdso_check to check all dynamic relocations
  2022-09-28  5:25   ` Fangrui Song
@ 2022-11-14 12:31     ` Christophe Leroy
  2022-11-15  0:46       ` Fangrui Song
  0 siblings, 1 reply; 13+ messages in thread
From: Christophe Leroy @ 2022-11-14 12:31 UTC (permalink / raw)
  To: Fangrui Song, Vincenzo Frascino, Thomas Gleixner, Andy Lutomirski
  Cc: linux-s390, linux-kernel, linux-csky, linux-mips, loongarch,
	linux-riscv, linuxppc-dev, linux-arm-kernel



Le 28/09/2022 à 07:25, Fangrui Song a écrit :
> On Sat, Sep 10, 2022 at 12:53 AM Fangrui Song <maskray@google.com> wrote:
>>
>> On 2022-08-30, Fangrui Song wrote:
>>> The actual intention is that no dynamic relocation exists. However, some
>>> GNU ld ports produce unneeded R_*_NONE. (If a port is not care enough to
>>> determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE
>>> relocations. E.g. powerpc64le ld as of 2.38 has the issue with
>>> defconfig.) R_*_NONE are generally no-op in the dynamic loaders. So just
>>> ignore them.
>>>
>>> With the change, we can remove ARCH_REL_TYPE_ABS. ARCH_REL_TYPE_ABS is a
>>> bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are
>>> not called "absolute relocations". (The patch is motivated by the arm64
>>> port missing R_AARCH64_RELATIVE.)
>>>
>>> While here, replace "egrep" with "grep" as "egrep" is deprecated in GNU
>>> grep 3.7.
>>>
>>> Signed-off-by: Fangrui Song <maskray@google.com>
>>> ---
>>> [...]
>>>
>>
>> Ping.
> 
> Ping^2 :)

Can you explain which ARCH_REL_TYPE_ABS can be removed with this change ?
How is the verification done if ARCH_REL_TYPE_ABS is removed ?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] vdso: Improve cmd_vdso_check to check all dynamic relocations
  2022-11-14 12:31     ` Christophe Leroy
@ 2022-11-15  0:46       ` Fangrui Song
  2022-12-04  4:50         ` Fangrui Song
  0 siblings, 1 reply; 13+ messages in thread
From: Fangrui Song @ 2022-11-15  0:46 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: Vincenzo Frascino, Thomas Gleixner, Andy Lutomirski, linux-s390,
	linux-kernel, linux-csky, linux-mips, loongarch, linux-riscv,
	linuxppc-dev, linux-arm-kernel

On 2022-11-14, Christophe Leroy wrote:
>
>
>Le 28/09/2022 à 07:25, Fangrui Song a écrit :
>> On Sat, Sep 10, 2022 at 12:53 AM Fangrui Song <maskray@google.com> wrote:
>>>
>>> On 2022-08-30, Fangrui Song wrote:
>>>> The actual intention is that no dynamic relocation exists. However, some
>>>> GNU ld ports produce unneeded R_*_NONE. (If a port is not care enough to
>>>> determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE
>>>> relocations. E.g. powerpc64le ld as of 2.38 has the issue with
>>>> defconfig.) R_*_NONE are generally no-op in the dynamic loaders. So just
>>>> ignore them.
>>>>
>>>> With the change, we can remove ARCH_REL_TYPE_ABS. ARCH_REL_TYPE_ABS is a
>>>> bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are
>>>> not called "absolute relocations". (The patch is motivated by the arm64
>>>> port missing R_AARCH64_RELATIVE.)
>>>>
>>>> While here, replace "egrep" with "grep" as "egrep" is deprecated in GNU
>>>> grep 3.7.
>>>>
>>>> Signed-off-by: Fangrui Song <maskray@google.com>
>>>> ---
>>>> [...]
>>>>
>>>
>>> Ping.
>>
>> Ping^2 :)
>
>Can you explain which ARCH_REL_TYPE_ABS can be removed with this change ?
>How is the verification done if ARCH_REL_TYPE_ABS is removed ?

All ARCH_REL_TYPE_ABS relocation types can be removed. As explained, the
real intention is to check no dynamic relocation, and this is done by
the new

   cmd_vdso_check = if $(READELF) -rW $@ | grep -v _NONE | grep -q "R_\w*_"; \

in this patch.

grep -v _NONE is to work around some GNU ld ports (and likely older releases
of some ports even if their latest versions are fixed) which produce
unneeded R_*_NONE dynamic relocations.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] vdso: Improve cmd_vdso_check to check all dynamic relocations
  2022-11-15  0:46       ` Fangrui Song
@ 2022-12-04  4:50         ` Fangrui Song
  2022-12-04 16:58           ` Christophe Leroy
  0 siblings, 1 reply; 13+ messages in thread
From: Fangrui Song @ 2022-12-04  4:50 UTC (permalink / raw)
  To: Christophe Leroy, Vincenzo Frascino, Andy Lutomirski
  Cc: Thomas Gleixner, linux-s390, linux-kernel, linux-csky,
	linux-mips, loongarch, linux-riscv, linuxppc-dev,
	linux-arm-kernel

On Mon, Nov 14, 2022 at 4:46 PM Fangrui Song <maskray@google.com> wrote:
>
> On 2022-11-14, Christophe Leroy wrote:
> >
> >
> >Le 28/09/2022 à 07:25, Fangrui Song a écrit :
> >> On Sat, Sep 10, 2022 at 12:53 AM Fangrui Song <maskray@google.com> wrote:
> >>>
> >>> On 2022-08-30, Fangrui Song wrote:
> >>>> The actual intention is that no dynamic relocation exists. However, some
> >>>> GNU ld ports produce unneeded R_*_NONE. (If a port is not care enough to
> >>>> determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE
> >>>> relocations. E.g. powerpc64le ld as of 2.38 has the issue with
> >>>> defconfig.) R_*_NONE are generally no-op in the dynamic loaders. So just
> >>>> ignore them.
> >>>>
> >>>> With the change, we can remove ARCH_REL_TYPE_ABS. ARCH_REL_TYPE_ABS is a
> >>>> bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are
> >>>> not called "absolute relocations". (The patch is motivated by the arm64
> >>>> port missing R_AARCH64_RELATIVE.)
> >>>>
> >>>> While here, replace "egrep" with "grep" as "egrep" is deprecated in GNU
> >>>> grep 3.7.
> >>>>
> >>>> Signed-off-by: Fangrui Song <maskray@google.com>
> >>>> ---
> >>>> [...]
> >>>>
> >>>
> >>> Ping.
> >>
> >> Ping^2 :)
> >
> >Can you explain which ARCH_REL_TYPE_ABS can be removed with this change ?
> >How is the verification done if ARCH_REL_TYPE_ABS is removed ?
>
> All ARCH_REL_TYPE_ABS relocation types can be removed. As explained, the
> real intention is to check no dynamic relocation, and this is done by
> the new
>
>    cmd_vdso_check = if $(READELF) -rW $@ | grep -v _NONE | grep -q "R_\w*_"; \
>
> in this patch.
>
> grep -v _NONE is to work around some GNU ld ports (and likely older releases
> of some ports even if their latest versions are fixed) which produce
> unneeded R_*_NONE dynamic relocations.

Ping :)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] vdso: Improve cmd_vdso_check to check all dynamic relocations
  2022-12-04  4:50         ` Fangrui Song
@ 2022-12-04 16:58           ` Christophe Leroy
  2022-12-18 18:31             ` Fangrui Song
  0 siblings, 1 reply; 13+ messages in thread
From: Christophe Leroy @ 2022-12-04 16:58 UTC (permalink / raw)
  To: Fangrui Song, Vincenzo Frascino, Andy Lutomirski
  Cc: Thomas Gleixner, linux-s390, linux-kernel, linux-csky,
	linux-mips, loongarch, linux-riscv, linuxppc-dev,
	linux-arm-kernel



Le 04/12/2022 à 05:50, Fangrui Song a écrit :
> On Mon, Nov 14, 2022 at 4:46 PM Fangrui Song <maskray@google.com> wrote:
>>
>> On 2022-11-14, Christophe Leroy wrote:
>>>
>>>
>>> Le 28/09/2022 à 07:25, Fangrui Song a écrit :
>>>> On Sat, Sep 10, 2022 at 12:53 AM Fangrui Song <maskray@google.com> wrote:
>>>>>
>>>>> On 2022-08-30, Fangrui Song wrote:
>>>>>> The actual intention is that no dynamic relocation exists. However, some
>>>>>> GNU ld ports produce unneeded R_*_NONE. (If a port is not care enough to
>>>>>> determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE
>>>>>> relocations. E.g. powerpc64le ld as of 2.38 has the issue with
>>>>>> defconfig.) R_*_NONE are generally no-op in the dynamic loaders. So just
>>>>>> ignore them.
>>>>>>
>>>>>> With the change, we can remove ARCH_REL_TYPE_ABS. ARCH_REL_TYPE_ABS is a
>>>>>> bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are
>>>>>> not called "absolute relocations". (The patch is motivated by the arm64
>>>>>> port missing R_AARCH64_RELATIVE.)
>>>>>>
>>>>>> While here, replace "egrep" with "grep" as "egrep" is deprecated in GNU
>>>>>> grep 3.7.
>>>>>>
>>>>>> Signed-off-by: Fangrui Song <maskray@google.com>
>>>>>> ---
>>>>>> [...]
>>>>>>
>>>>>
>>>>> Ping.
>>>>
>>>> Ping^2 :)
>>>
>>> Can you explain which ARCH_REL_TYPE_ABS can be removed with this change ?
>>> How is the verification done if ARCH_REL_TYPE_ABS is removed ?
>>
>> All ARCH_REL_TYPE_ABS relocation types can be removed. As explained, the
>> real intention is to check no dynamic relocation, and this is done by
>> the new

Well, there was a typo in my question, I wanted to ask 'why', not 'which'.

>>
>>     cmd_vdso_check = if $(READELF) -rW $@ | grep -v _NONE | grep -q "R_\w*_"; \
>>
>> in this patch.
>>
>> grep -v _NONE is to work around some GNU ld ports (and likely older releases
>> of some ports even if their latest versions are fixed) which produce
>> unneeded R_*_NONE dynamic relocations.
> 
> Ping :)

Ok, that seems to work on powerpc.

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] vdso: Improve cmd_vdso_check to check all dynamic relocations
  2022-12-04 16:58           ` Christophe Leroy
@ 2022-12-18 18:31             ` Fangrui Song
  2022-12-21 23:51               ` [PATCH v2] " Fangrui Song
  0 siblings, 1 reply; 13+ messages in thread
From: Fangrui Song @ 2022-12-18 18:31 UTC (permalink / raw)
  To: Christophe Leroy, Andy Lutomirski, Thomas Gleixner, Vincenzo Frascino
  Cc: linux-s390, linux-kernel, linux-csky, linux-mips, loongarch,
	linux-riscv, linuxppc-dev, linux-arm-kernel

On Sun, Dec 4, 2022 at 8:58 AM Christophe Leroy
<christophe.leroy@csgroup.eu> wrote:
>
>
>
> Le 04/12/2022 à 05:50, Fangrui Song a écrit :
> > On Mon, Nov 14, 2022 at 4:46 PM Fangrui Song <maskray@google.com> wrote:
> >>
> >> On 2022-11-14, Christophe Leroy wrote:
> >>>
> >>>
> >>> Le 28/09/2022 à 07:25, Fangrui Song a écrit :
> >>>> On Sat, Sep 10, 2022 at 12:53 AM Fangrui Song <maskray@google.com> wrote:
> >>>>>
> >>>>> On 2022-08-30, Fangrui Song wrote:
> >>>>>> The actual intention is that no dynamic relocation exists. However, some
> >>>>>> GNU ld ports produce unneeded R_*_NONE. (If a port is not care enough to
> >>>>>> determine the exact .rel[a].dyn size, the trailing zeros become R_*_NONE
> >>>>>> relocations. E.g. powerpc64le ld as of 2.38 has the issue with
> >>>>>> defconfig.) R_*_NONE are generally no-op in the dynamic loaders. So just
> >>>>>> ignore them.
> >>>>>>
> >>>>>> With the change, we can remove ARCH_REL_TYPE_ABS. ARCH_REL_TYPE_ABS is a
> >>>>>> bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are
> >>>>>> not called "absolute relocations". (The patch is motivated by the arm64
> >>>>>> port missing R_AARCH64_RELATIVE.)
> >>>>>>
> >>>>>> While here, replace "egrep" with "grep" as "egrep" is deprecated in GNU
> >>>>>> grep 3.7.
> >>>>>>
> >>>>>> Signed-off-by: Fangrui Song <maskray@google.com>
> >>>>>> ---
> >>>>>> [...]
> >>>>>>
> >>>>>
> >>>>> Ping.
> >>>>
> >>>> Ping^2 :)
> >>>
> >>> Can you explain which ARCH_REL_TYPE_ABS can be removed with this change ?
> >>> How is the verification done if ARCH_REL_TYPE_ABS is removed ?
> >>
> >> All ARCH_REL_TYPE_ABS relocation types can be removed. As explained, the
> >> real intention is to check no dynamic relocation, and this is done by
> >> the new
>
> Well, there was a typo in my question, I wanted to ask 'why', not 'which'.
>
> >>
> >>     cmd_vdso_check = if $(READELF) -rW $@ | grep -v _NONE | grep -q "R_\w*_"; \
> >>
> >> in this patch.
> >>
> >> grep -v _NONE is to work around some GNU ld ports (and likely older releases
> >> of some ports even if their latest versions are fixed) which produce
> >> unneeded R_*_NONE dynamic relocations.
> >
> > Ping :)
>
> Ok, that seems to work on powerpc.
>
> Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

Thanks. Can a maintainer pick up this commit?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2] vdso: Improve cmd_vdso_check to check all dynamic relocations
  2022-12-18 18:31             ` Fangrui Song
@ 2022-12-21 23:51               ` Fangrui Song
  2022-12-29 16:22                 ` Palmer Dabbelt
  2023-03-10 14:35                 ` Vincenzo Frascino
  0 siblings, 2 replies; 13+ messages in thread
From: Fangrui Song @ 2022-12-21 23:51 UTC (permalink / raw)
  To: Christophe Leroy, Andy Lutomirski, Thomas Gleixner,
	Vincenzo Frascino, Arnd Bergmann
  Cc: linux-s390, linux-kernel, linux-csky, linux-mips, loongarch,
	linux-riscv, linuxppc-dev, linux-arm-kernel

The actual intention is that no dynamic relocation exists. However, some
GNU ld ports produce unneeded R_*_NONE. (If a port fails to determine
the exact .rel[a].dyn size, the trailing zeros become R_*_NONE
relocations. E.g. ld's powerpc port recently fixed
https://sourceware.org/bugzilla/show_bug.cgi?id=29540) R_*_NONE are
generally no-op in the dynamic loaders. So just ignore them.

With the change, we can remove ARCH_REL_TYPE_ABS. ARCH_REL_TYPE_ABS is a
bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are
not called "absolute relocations". (The patch is motivated by the arm64
port missing R_AARCH64_RELATIVE.)

Signed-off-by: Fangrui Song <maskray@google.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
Change from v1:
* rebase after 8ac3b5cd3e0521d92f9755e90d140382fc292510 (lib/vdso: use "grep -E" instead of "egrep")
* change the commit message to mention an example GNU ld bug; no longer say the patch fixes a deprecated egrep use
---
  arch/arm/vdso/Makefile            |  3 ---
  arch/arm64/kernel/vdso/Makefile   |  3 ---
  arch/arm64/kernel/vdso32/Makefile |  3 ---
  arch/csky/kernel/vdso/Makefile    |  3 ---
  arch/loongarch/vdso/Makefile      |  3 ---
  arch/mips/vdso/Makefile           |  3 ---
  arch/powerpc/kernel/vdso/Makefile |  1 -
  arch/riscv/kernel/vdso/Makefile   |  3 ---
  arch/s390/kernel/vdso32/Makefile  |  2 --
  arch/s390/kernel/vdso64/Makefile  |  2 --
  arch/x86/entry/vdso/Makefile      |  4 ----
  lib/vdso/Makefile                 | 13 ++++---------
  12 files changed, 4 insertions(+), 39 deletions(-)

diff --git a/arch/arm/vdso/Makefile b/arch/arm/vdso/Makefile
index a7ec06ce3785..e58197bba776 100644
--- a/arch/arm/vdso/Makefile
+++ b/arch/arm/vdso/Makefile
@@ -1,8 +1,5 @@
  # SPDX-License-Identifier: GPL-2.0
  
-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
-# the inclusion of generic Makefile.
-ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32
  include $(srctree)/lib/vdso/Makefile
  
  hostprogs := vdsomunge
diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile
index beaf9586338f..1f2427b13410 100644
--- a/arch/arm64/kernel/vdso/Makefile
+++ b/arch/arm64/kernel/vdso/Makefile
@@ -6,9 +6,6 @@
  # Heavily based on the vDSO Makefiles for other archs.
  #
  
-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
-# the inclusion of generic Makefile.
-ARCH_REL_TYPE_ABS := R_AARCH64_JUMP_SLOT|R_AARCH64_GLOB_DAT|R_AARCH64_ABS64
  include $(srctree)/lib/vdso/Makefile
  
  obj-vdso := vgettimeofday.o note.o sigreturn.o
diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index f59bd1a4ead6..d014162c5c71 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -3,9 +3,6 @@
  # Makefile for vdso32
  #
  
-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
-# the inclusion of generic Makefile.
-ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32
  include $(srctree)/lib/vdso/Makefile
  
  # Same as cc-*option, but using CC_COMPAT instead of CC
diff --git a/arch/csky/kernel/vdso/Makefile b/arch/csky/kernel/vdso/Makefile
index 0b6909f10667..86c8c4de1b0f 100644
--- a/arch/csky/kernel/vdso/Makefile
+++ b/arch/csky/kernel/vdso/Makefile
@@ -1,8 +1,5 @@
  # SPDX-License-Identifier: GPL-2.0-only
  
-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
-# the inclusion of generic Makefile.
-ARCH_REL_TYPE_ABS := R_CKCORE_ADDR32|R_CKCORE_JUMP_SLOT
  include $(srctree)/lib/vdso/Makefile
  
  # Symbols present in the vdso
diff --git a/arch/loongarch/vdso/Makefile b/arch/loongarch/vdso/Makefile
index d89e2ac75f7b..1b2e0f149f55 100644
--- a/arch/loongarch/vdso/Makefile
+++ b/arch/loongarch/vdso/Makefile
@@ -1,9 +1,6 @@
  # SPDX-License-Identifier: GPL-2.0
  # Objects to go into the VDSO.
  
-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
-# the inclusion of generic Makefile.
-ARCH_REL_TYPE_ABS := R_LARCH_32|R_LARCH_64|R_LARCH_MARK_LA|R_LARCH_JUMP_SLOT
  include $(srctree)/lib/vdso/Makefile
  
  obj-vdso-y := elf.o vgetcpu.o vgettimeofday.o sigreturn.o
diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile
index 1f7d5c6c10b0..c060f3596304 100644
--- a/arch/mips/vdso/Makefile
+++ b/arch/mips/vdso/Makefile
@@ -4,9 +4,6 @@
  # Sanitizer runtimes are unavailable and cannot be linked here.
   KCSAN_SANITIZE			:= n
  
-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
-# the inclusion of generic Makefile.
-ARCH_REL_TYPE_ABS := R_MIPS_JUMP_SLOT|R_MIPS_GLOB_DAT
  include $(srctree)/lib/vdso/Makefile
  
  obj-vdso-y := elf.o vgettimeofday.o sigreturn.o
diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
index 6a977b0d8ffc..83c347e9136f 100644
--- a/arch/powerpc/kernel/vdso/Makefile
+++ b/arch/powerpc/kernel/vdso/Makefile
@@ -2,7 +2,6 @@
  
  # List of files in the vdso, has to be asm only for now
  
-ARCH_REL_TYPE_ABS := R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_PPC_ADDR16|R_PPC_ADDR16_LO|R_PPC_ADDR16_HI|R_PPC_ADDR16_HA|R_PPC_ADDR14|R_PPC_ADDR14_BRTAKEN|R_PPC_ADDR14_BRNTAKEN|R_PPC_REL24
  include $(srctree)/lib/vdso/Makefile
  
  obj-vdso32 = sigtramp32-32.o gettimeofday-32.o datapage-32.o cacheflush-32.o note-32.o getcpu-32.o
diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
index 06e6b27f3bcc..d85c37e11b21 100644
--- a/arch/riscv/kernel/vdso/Makefile
+++ b/arch/riscv/kernel/vdso/Makefile
@@ -1,9 +1,6 @@
  # SPDX-License-Identifier: GPL-2.0-only
  # Copied from arch/tile/kernel/vdso/Makefile
  
-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
-# the inclusion of generic Makefile.
-ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOT
  include $(srctree)/lib/vdso/Makefile
  # Symbols present in the vdso
  vdso-syms  = rt_sigreturn
diff --git a/arch/s390/kernel/vdso32/Makefile b/arch/s390/kernel/vdso32/Makefile
index 245bddfe9bc0..e795fdbbf484 100644
--- a/arch/s390/kernel/vdso32/Makefile
+++ b/arch/s390/kernel/vdso32/Makefile
@@ -2,8 +2,6 @@
  # List of files in the vdso
  
  KCOV_INSTRUMENT := n
-ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE
-ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT
  
  include $(srctree)/lib/vdso/Makefile
  obj-vdso32 = vdso_user_wrapper-32.o note-32.o
diff --git a/arch/s390/kernel/vdso64/Makefile b/arch/s390/kernel/vdso64/Makefile
index 9e2b95a222a9..47dbbfdfad68 100644
--- a/arch/s390/kernel/vdso64/Makefile
+++ b/arch/s390/kernel/vdso64/Makefile
@@ -2,8 +2,6 @@
  # List of files in the vdso
  
  KCOV_INSTRUMENT := n
-ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE
-ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT
  
  include $(srctree)/lib/vdso/Makefile
  obj-vdso64 = vdso_user_wrapper.o note.o
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 838613ac15b8..b292c24acb8e 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -3,10 +3,6 @@
  # Building vDSO images for x86.
  #
  
-# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
-# the inclusion of generic Makefile.
-ARCH_REL_TYPE_ABS := R_X86_64_JUMP_SLOT|R_X86_64_GLOB_DAT|R_X86_64_RELATIVE|
-ARCH_REL_TYPE_ABS += R_386_GLOB_DAT|R_386_JMP_SLOT|R_386_RELATIVE
  include $(srctree)/lib/vdso/Makefile
  
  # Sanitizer runtimes are unavailable and cannot be linked here.
diff --git a/lib/vdso/Makefile b/lib/vdso/Makefile
index e814061d6aa0..9f031eafc465 100644
--- a/lib/vdso/Makefile
+++ b/lib/vdso/Makefile
@@ -5,18 +5,13 @@ GENERIC_VDSO_DIR := $(dir $(GENERIC_VDSO_MK_PATH))
  
  c-gettimeofday-$(CONFIG_GENERIC_GETTIMEOFDAY) := $(addprefix $(GENERIC_VDSO_DIR), gettimeofday.c)
  
-# This cmd checks that the vdso library does not contain absolute relocation
+# This cmd checks that the vdso library does not contain dynamic relocations.
  # It has to be called after the linking of the vdso library and requires it
  # as a parameter.
  #
-# $(ARCH_REL_TYPE_ABS) is defined in the arch specific makefile and corresponds
-# to the absolute relocation types printed by "objdump -R" and accepted by the
-# dynamic linker.
-ifndef ARCH_REL_TYPE_ABS
-$(error ARCH_REL_TYPE_ABS is not set)
-endif
-
+# As a workaround for some GNU ld ports which produce unneeded R_*_NONE
+# dynamic relocations, ignore R_*_NONE.
  quiet_cmd_vdso_check = VDSOCHK $@
-      cmd_vdso_check = if $(OBJDUMP) -R $@ | grep -E -h "$(ARCH_REL_TYPE_ABS)"; \
+      cmd_vdso_check = if $(READELF) -rW $@ | grep -v _NONE | grep -q " R_\w*_"; \
  		       then (echo >&2 "$@: dynamic relocations are not supported"; \
  			     rm -f $@; /bin/false); fi
-- 
2.39.0.314.g84b9a713c41-goog


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v2] vdso: Improve cmd_vdso_check to check all dynamic relocations
  2022-12-21 23:51               ` [PATCH v2] " Fangrui Song
@ 2022-12-29 16:22                 ` Palmer Dabbelt
  2023-01-27 23:19                   ` Fangrui Song
  2023-03-10 14:35                 ` Vincenzo Frascino
  1 sibling, 1 reply; 13+ messages in thread
From: Palmer Dabbelt @ 2022-12-29 16:22 UTC (permalink / raw)
  To: maskray
  Cc: christophe.leroy, luto, tglx, vincenzo.frascino, Arnd Bergmann,
	linux-s390, linux-kernel, linux-csky, linux-mips, loongarch,
	linux-riscv, linuxppc-dev, linux-arm-kernel

On Wed, 21 Dec 2022 15:51:47 PST (-0800), maskray@google.com wrote:
> The actual intention is that no dynamic relocation exists. However, some
> GNU ld ports produce unneeded R_*_NONE. (If a port fails to determine
> the exact .rel[a].dyn size, the trailing zeros become R_*_NONE
> relocations. E.g. ld's powerpc port recently fixed
> https://sourceware.org/bugzilla/show_bug.cgi?id=29540) R_*_NONE are
> generally no-op in the dynamic loaders. So just ignore them.
>
> With the change, we can remove ARCH_REL_TYPE_ABS. ARCH_REL_TYPE_ABS is a
> bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are
> not called "absolute relocations". (The patch is motivated by the arm64
> port missing R_AARCH64_RELATIVE.)
>
> Signed-off-by: Fangrui Song <maskray@google.com>
> Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
> Change from v1:
> * rebase after 8ac3b5cd3e0521d92f9755e90d140382fc292510 (lib/vdso: use "grep -E" instead of "egrep")
> * change the commit message to mention an example GNU ld bug; no longer say the patch fixes a deprecated egrep use
> ---
>   arch/arm/vdso/Makefile            |  3 ---
>   arch/arm64/kernel/vdso/Makefile   |  3 ---
>   arch/arm64/kernel/vdso32/Makefile |  3 ---
>   arch/csky/kernel/vdso/Makefile    |  3 ---
>   arch/loongarch/vdso/Makefile      |  3 ---
>   arch/mips/vdso/Makefile           |  3 ---
>   arch/powerpc/kernel/vdso/Makefile |  1 -
>   arch/riscv/kernel/vdso/Makefile   |  3 ---
>   arch/s390/kernel/vdso32/Makefile  |  2 --
>   arch/s390/kernel/vdso64/Makefile  |  2 --
>   arch/x86/entry/vdso/Makefile      |  4 ----
>   lib/vdso/Makefile                 | 13 ++++---------
>   12 files changed, 4 insertions(+), 39 deletions(-)

[snip]

> diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
> index 06e6b27f3bcc..d85c37e11b21 100644
> --- a/arch/riscv/kernel/vdso/Makefile
> +++ b/arch/riscv/kernel/vdso/Makefile
> @@ -1,9 +1,6 @@
>   # SPDX-License-Identifier: GPL-2.0-only
>   # Copied from arch/tile/kernel/vdso/Makefile
>
> -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
> -# the inclusion of generic Makefile.
> -ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOT
>   include $(srctree)/lib/vdso/Makefile
>   # Symbols present in the vdso
>   vdso-syms  = rt_sigreturn

Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V

Thanks!

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2] vdso: Improve cmd_vdso_check to check all dynamic relocations
  2022-12-29 16:22                 ` Palmer Dabbelt
@ 2023-01-27 23:19                   ` Fangrui Song
  0 siblings, 0 replies; 13+ messages in thread
From: Fangrui Song @ 2023-01-27 23:19 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: christophe.leroy, Palmer Dabbelt, luto, tglx, vincenzo.frascino,
	linux-s390, linux-kernel, linux-csky, linux-mips, loongarch,
	linux-riscv, linuxppc-dev, linux-arm-kernel

On Thu, Dec 29, 2022 at 11:22 AM Palmer Dabbelt <palmer@dabbelt.com> wrote:
>
> On Wed, 21 Dec 2022 15:51:47 PST (-0800), maskray@google.com wrote:
> > The actual intention is that no dynamic relocation exists. However, some
> > GNU ld ports produce unneeded R_*_NONE. (If a port fails to determine
> > the exact .rel[a].dyn size, the trailing zeros become R_*_NONE
> > relocations. E.g. ld's powerpc port recently fixed
> > https://sourceware.org/bugzilla/show_bug.cgi?id=29540) R_*_NONE are
> > generally no-op in the dynamic loaders. So just ignore them.
> >
> > With the change, we can remove ARCH_REL_TYPE_ABS. ARCH_REL_TYPE_ABS is a
> > bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are
> > not called "absolute relocations". (The patch is motivated by the arm64
> > port missing R_AARCH64_RELATIVE.)
> >
> > Signed-off-by: Fangrui Song <maskray@google.com>
> > Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> > ---
> > Change from v1:
> > * rebase after 8ac3b5cd3e0521d92f9755e90d140382fc292510 (lib/vdso: use "grep -E" instead of "egrep")
> > * change the commit message to mention an example GNU ld bug; no longer say the patch fixes a deprecated egrep use
> > ---
> >   arch/arm/vdso/Makefile            |  3 ---
> >   arch/arm64/kernel/vdso/Makefile   |  3 ---
> >   arch/arm64/kernel/vdso32/Makefile |  3 ---
> >   arch/csky/kernel/vdso/Makefile    |  3 ---
> >   arch/loongarch/vdso/Makefile      |  3 ---
> >   arch/mips/vdso/Makefile           |  3 ---
> >   arch/powerpc/kernel/vdso/Makefile |  1 -
> >   arch/riscv/kernel/vdso/Makefile   |  3 ---
> >   arch/s390/kernel/vdso32/Makefile  |  2 --
> >   arch/s390/kernel/vdso64/Makefile  |  2 --
> >   arch/x86/entry/vdso/Makefile      |  4 ----
> >   lib/vdso/Makefile                 | 13 ++++---------
> >   12 files changed, 4 insertions(+), 39 deletions(-)
>
> [snip]
>
> > diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
> > index 06e6b27f3bcc..d85c37e11b21 100644
> > --- a/arch/riscv/kernel/vdso/Makefile
> > +++ b/arch/riscv/kernel/vdso/Makefile
> > @@ -1,9 +1,6 @@
> >   # SPDX-License-Identifier: GPL-2.0-only
> >   # Copied from arch/tile/kernel/vdso/Makefile
> >
> > -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
> > -# the inclusion of generic Makefile.
> > -ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOT
> >   include $(srctree)/lib/vdso/Makefile
> >   # Symbols present in the vdso
> >   vdso-syms  = rt_sigreturn
>
> Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V
>
> Thanks!

Looks like this patch hasn't been picked yet...

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2] vdso: Improve cmd_vdso_check to check all dynamic relocations
  2022-12-21 23:51               ` [PATCH v2] " Fangrui Song
  2022-12-29 16:22                 ` Palmer Dabbelt
@ 2023-03-10 14:35                 ` Vincenzo Frascino
  2023-03-10 19:10                   ` Fangrui Song
  1 sibling, 1 reply; 13+ messages in thread
From: Vincenzo Frascino @ 2023-03-10 14:35 UTC (permalink / raw)
  To: Fangrui Song, Christophe Leroy, Andy Lutomirski, Thomas Gleixner,
	Arnd Bergmann
  Cc: linux-s390, linux-kernel, linux-csky, linux-mips, loongarch,
	linux-riscv, linuxppc-dev, linux-arm-kernel

Hi Fangrui,

Apologize for the delay, I totally missed that you had a new version of your
patch since it was threaded with the old one.

On 12/21/22 23:51, Fangrui Song wrote:
> The actual intention is that no dynamic relocation exists. However, some
> GNU ld ports produce unneeded R_*_NONE. (If a port fails to determine
> the exact .rel[a].dyn size, the trailing zeros become R_*_NONE
> relocations. E.g. ld's powerpc port recently fixed
> https://sourceware.org/bugzilla/show_bug.cgi?id=29540) R_*_NONE are
> generally no-op in the dynamic loaders. So just ignore them.
> 
> With the change, we can remove ARCH_REL_TYPE_ABS. ARCH_REL_TYPE_ABS is a
> bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are
> not called "absolute relocations". (The patch is motivated by the arm64
> port missing R_AARCH64_RELATIVE.)

It makes sense to update the name, it started as "absolute relocations" but then
it evolved into something else.

A part that, did you perform any testing with the generated vDSO libraries?

> 
> Signed-off-by: Fangrui Song <maskray@google.com>
> Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
> Change from v1:
> * rebase after 8ac3b5cd3e0521d92f9755e90d140382fc292510 (lib/vdso: use "grep -E"
> instead of "egrep")
> * change the commit message to mention an example GNU ld bug; no longer say the
> patch fixes a deprecated egrep use
> ---
>  arch/arm/vdso/Makefile            |  3 ---
>  arch/arm64/kernel/vdso/Makefile   |  3 ---
>  arch/arm64/kernel/vdso32/Makefile |  3 ---
>  arch/csky/kernel/vdso/Makefile    |  3 ---
>  arch/loongarch/vdso/Makefile      |  3 ---
>  arch/mips/vdso/Makefile           |  3 ---
>  arch/powerpc/kernel/vdso/Makefile |  1 -
>  arch/riscv/kernel/vdso/Makefile   |  3 ---
>  arch/s390/kernel/vdso32/Makefile  |  2 --
>  arch/s390/kernel/vdso64/Makefile  |  2 --
>  arch/x86/entry/vdso/Makefile      |  4 ----
>  lib/vdso/Makefile                 | 13 ++++---------
>  12 files changed, 4 insertions(+), 39 deletions(-)
> 
> diff --git a/arch/arm/vdso/Makefile b/arch/arm/vdso/Makefile
> index a7ec06ce3785..e58197bba776 100644
> --- a/arch/arm/vdso/Makefile
> +++ b/arch/arm/vdso/Makefile
> @@ -1,8 +1,5 @@
>  # SPDX-License-Identifier: GPL-2.0
>  
> -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
> -# the inclusion of generic Makefile.
> -ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32

I would still add a comment here to say why we are including the generic
Makefile to prevent that it gets accidentally removed (similar thing for every
architecture touched by this patch).

With that:

Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com> # for vDSO, aarch64
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com> # for aarch64

>  include $(srctree)/lib/vdso/Makefile
>  
>  hostprogs := vdsomunge
> diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile
> index beaf9586338f..1f2427b13410 100644
> --- a/arch/arm64/kernel/vdso/Makefile
> +++ b/arch/arm64/kernel/vdso/Makefile
> @@ -6,9 +6,6 @@
>  # Heavily based on the vDSO Makefiles for other archs.
>  #
>  
> -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
> -# the inclusion of generic Makefile.
> -ARCH_REL_TYPE_ABS := R_AARCH64_JUMP_SLOT|R_AARCH64_GLOB_DAT|R_AARCH64_ABS64
>  include $(srctree)/lib/vdso/Makefile
>  
>  obj-vdso := vgettimeofday.o note.o sigreturn.o
> diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
> index f59bd1a4ead6..d014162c5c71 100644
> --- a/arch/arm64/kernel/vdso32/Makefile
> +++ b/arch/arm64/kernel/vdso32/Makefile
> @@ -3,9 +3,6 @@
>  # Makefile for vdso32
>  #
>  
> -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
> -# the inclusion of generic Makefile.
> -ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32
>  include $(srctree)/lib/vdso/Makefile
>  
>  # Same as cc-*option, but using CC_COMPAT instead of CC
> diff --git a/arch/csky/kernel/vdso/Makefile b/arch/csky/kernel/vdso/Makefile
> index 0b6909f10667..86c8c4de1b0f 100644
> --- a/arch/csky/kernel/vdso/Makefile
> +++ b/arch/csky/kernel/vdso/Makefile
> @@ -1,8 +1,5 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
> -# the inclusion of generic Makefile.
> -ARCH_REL_TYPE_ABS := R_CKCORE_ADDR32|R_CKCORE_JUMP_SLOT
>  include $(srctree)/lib/vdso/Makefile
>  
>  # Symbols present in the vdso
> diff --git a/arch/loongarch/vdso/Makefile b/arch/loongarch/vdso/Makefile
> index d89e2ac75f7b..1b2e0f149f55 100644
> --- a/arch/loongarch/vdso/Makefile
> +++ b/arch/loongarch/vdso/Makefile
> @@ -1,9 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0
>  # Objects to go into the VDSO.
>  
> -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
> -# the inclusion of generic Makefile.
> -ARCH_REL_TYPE_ABS := R_LARCH_32|R_LARCH_64|R_LARCH_MARK_LA|R_LARCH_JUMP_SLOT
>  include $(srctree)/lib/vdso/Makefile
>  
>  obj-vdso-y := elf.o vgetcpu.o vgettimeofday.o sigreturn.o
> diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile
> index 1f7d5c6c10b0..c060f3596304 100644
> --- a/arch/mips/vdso/Makefile
> +++ b/arch/mips/vdso/Makefile
> @@ -4,9 +4,6 @@
>  # Sanitizer runtimes are unavailable and cannot be linked here.
>   KCSAN_SANITIZE            := n
>  
> -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
> -# the inclusion of generic Makefile.
> -ARCH_REL_TYPE_ABS := R_MIPS_JUMP_SLOT|R_MIPS_GLOB_DAT
>  include $(srctree)/lib/vdso/Makefile
>  
>  obj-vdso-y := elf.o vgettimeofday.o sigreturn.o
> diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
> index 6a977b0d8ffc..83c347e9136f 100644
> --- a/arch/powerpc/kernel/vdso/Makefile
> +++ b/arch/powerpc/kernel/vdso/Makefile
> @@ -2,7 +2,6 @@
>  
>  # List of files in the vdso, has to be asm only for now
>  
> -ARCH_REL_TYPE_ABS :=
> R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_PPC_ADDR16|R_PPC_ADDR16_LO|R_PPC_ADDR16_HI|R_PPC_ADDR16_HA|R_PPC_ADDR14|R_PPC_ADDR14_BRTAKEN|R_PPC_ADDR14_BRNTAKEN|R_PPC_REL24
>  include $(srctree)/lib/vdso/Makefile
>  
>  obj-vdso32 = sigtramp32-32.o gettimeofday-32.o datapage-32.o cacheflush-32.o
> note-32.o getcpu-32.o
> diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
> index 06e6b27f3bcc..d85c37e11b21 100644
> --- a/arch/riscv/kernel/vdso/Makefile
> +++ b/arch/riscv/kernel/vdso/Makefile
> @@ -1,9 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  # Copied from arch/tile/kernel/vdso/Makefile
>  
> -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
> -# the inclusion of generic Makefile.
> -ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOT
>  include $(srctree)/lib/vdso/Makefile
>  # Symbols present in the vdso
>  vdso-syms  = rt_sigreturn
> diff --git a/arch/s390/kernel/vdso32/Makefile b/arch/s390/kernel/vdso32/Makefile
> index 245bddfe9bc0..e795fdbbf484 100644
> --- a/arch/s390/kernel/vdso32/Makefile
> +++ b/arch/s390/kernel/vdso32/Makefile
> @@ -2,8 +2,6 @@
>  # List of files in the vdso
>  
>  KCOV_INSTRUMENT := n
> -ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE
> -ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT
>  
>  include $(srctree)/lib/vdso/Makefile
>  obj-vdso32 = vdso_user_wrapper-32.o note-32.o
> diff --git a/arch/s390/kernel/vdso64/Makefile b/arch/s390/kernel/vdso64/Makefile
> index 9e2b95a222a9..47dbbfdfad68 100644
> --- a/arch/s390/kernel/vdso64/Makefile
> +++ b/arch/s390/kernel/vdso64/Makefile
> @@ -2,8 +2,6 @@
>  # List of files in the vdso
>  
>  KCOV_INSTRUMENT := n
> -ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE
> -ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT
>  
>  include $(srctree)/lib/vdso/Makefile
>  obj-vdso64 = vdso_user_wrapper.o note.o
> diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
> index 838613ac15b8..b292c24acb8e 100644
> --- a/arch/x86/entry/vdso/Makefile
> +++ b/arch/x86/entry/vdso/Makefile
> @@ -3,10 +3,6 @@
>  # Building vDSO images for x86.
>  #
>  
> -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
> -# the inclusion of generic Makefile.
> -ARCH_REL_TYPE_ABS := R_X86_64_JUMP_SLOT|R_X86_64_GLOB_DAT|R_X86_64_RELATIVE|
> -ARCH_REL_TYPE_ABS += R_386_GLOB_DAT|R_386_JMP_SLOT|R_386_RELATIVE
>  include $(srctree)/lib/vdso/Makefile
>  
>  # Sanitizer runtimes are unavailable and cannot be linked here.
> diff --git a/lib/vdso/Makefile b/lib/vdso/Makefile
> index e814061d6aa0..9f031eafc465 100644
> --- a/lib/vdso/Makefile
> +++ b/lib/vdso/Makefile
> @@ -5,18 +5,13 @@ GENERIC_VDSO_DIR := $(dir $(GENERIC_VDSO_MK_PATH))
>  
>  c-gettimeofday-$(CONFIG_GENERIC_GETTIMEOFDAY) := $(addprefix
> $(GENERIC_VDSO_DIR), gettimeofday.c)
>  
> -# This cmd checks that the vdso library does not contain absolute relocation
> +# This cmd checks that the vdso library does not contain dynamic relocations.
>  # It has to be called after the linking of the vdso library and requires it
>  # as a parameter.
>  #
> -# $(ARCH_REL_TYPE_ABS) is defined in the arch specific makefile and corresponds
> -# to the absolute relocation types printed by "objdump -R" and accepted by the
> -# dynamic linker.
> -ifndef ARCH_REL_TYPE_ABS
> -$(error ARCH_REL_TYPE_ABS is not set)
> -endif
> -
> +# As a workaround for some GNU ld ports which produce unneeded R_*_NONE
> +# dynamic relocations, ignore R_*_NONE.
>  quiet_cmd_vdso_check = VDSOCHK $@
> -      cmd_vdso_check = if $(OBJDUMP) -R $@ | grep -E -h "$(ARCH_REL_TYPE_ABS)"; \
> +      cmd_vdso_check = if $(READELF) -rW $@ | grep -v _NONE | grep -q " R_\w*_"; \
>                 then (echo >&2 "$@: dynamic relocations are not supported"; \
>                   rm -f $@; /bin/false); fi

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2] vdso: Improve cmd_vdso_check to check all dynamic relocations
  2023-03-10 14:35                 ` Vincenzo Frascino
@ 2023-03-10 19:10                   ` Fangrui Song
  0 siblings, 0 replies; 13+ messages in thread
From: Fangrui Song @ 2023-03-10 19:10 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: Christophe Leroy, Andy Lutomirski, Thomas Gleixner,
	Arnd Bergmann, linux-s390, linux-kernel, linux-csky, linux-mips,
	loongarch, linux-riscv, linuxppc-dev, linux-arm-kernel


On 2023-03-10, Vincenzo Frascino wrote:
>Hi Fangrui,
>
>Apologize for the delay, I totally missed that you had a new version of your
>patch since it was threaded with the old one.

Thank you! No worries.

>On 12/21/22 23:51, Fangrui Song wrote:
>> The actual intention is that no dynamic relocation exists. However, some
>> GNU ld ports produce unneeded R_*_NONE. (If a port fails to determine
>> the exact .rel[a].dyn size, the trailing zeros become R_*_NONE
>> relocations. E.g. ld's powerpc port recently fixed
>> https://sourceware.org/bugzilla/show_bug.cgi?id=29540) R_*_NONE are
>> generally no-op in the dynamic loaders. So just ignore them.
>>
>> With the change, we can remove ARCH_REL_TYPE_ABS. ARCH_REL_TYPE_ABS is a
>> bit misnomer as ports may check RELAVETIVE/GLOB_DAT/JUMP_SLOT which are
>> not called "absolute relocations". (The patch is motivated by the arm64
>> port missing R_AARCH64_RELATIVE.)
>
>It makes sense to update the name, it started as "absolute relocations" but then
>it evolved into something else.
>
>A part that, did you perform any testing with the generated vDSO libraries?

I checked that the built vdso did not change (the patch just changes
some post-link verification). 

To be more sure, I used commands like
https://github.com/ClangBuiltLinux/tc-build/blob/main/kernel/build.sh#L305
to build a kernel and commands like

     ~/Dev/ClangBuiltLinux/boot-utils/boot-qemu.py -a arm64 -k /tmp/linux/arm64

to run an image for a couple of architectures.

The initrd images run some init scripts along with

   # buildroot/overlay-poweroff/etc/init.d/S50yolo
   cat /proc/version
   poweroff

I think these have exercised vdso.

>>
>> Signed-off-by: Fangrui Song <maskray@google.com>
>> Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>> Change from v1:
>> * rebase after 8ac3b5cd3e0521d92f9755e90d140382fc292510 (lib/vdso: use "grep -E"
>> instead of "egrep")
>> * change the commit message to mention an example GNU ld bug; no longer say the
>> patch fixes a deprecated egrep use
>> ---
>>  arch/arm/vdso/Makefile            |  3 ---
>>  arch/arm64/kernel/vdso/Makefile   |  3 ---
>>  arch/arm64/kernel/vdso32/Makefile |  3 ---
>>  arch/csky/kernel/vdso/Makefile    |  3 ---
>>  arch/loongarch/vdso/Makefile      |  3 ---
>>  arch/mips/vdso/Makefile           |  3 ---
>>  arch/powerpc/kernel/vdso/Makefile |  1 -
>>  arch/riscv/kernel/vdso/Makefile   |  3 ---
>>  arch/s390/kernel/vdso32/Makefile  |  2 --
>>  arch/s390/kernel/vdso64/Makefile  |  2 --
>>  arch/x86/entry/vdso/Makefile      |  4 ----
>>  lib/vdso/Makefile                 | 13 ++++---------
>>  12 files changed, 4 insertions(+), 39 deletions(-)
>>
>> diff --git a/arch/arm/vdso/Makefile b/arch/arm/vdso/Makefile
>> index a7ec06ce3785..e58197bba776 100644
>> --- a/arch/arm/vdso/Makefile
>> +++ b/arch/arm/vdso/Makefile
>> @@ -1,8 +1,5 @@
>>  # SPDX-License-Identifier: GPL-2.0
>>  
>> -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
>> -# the inclusion of generic Makefile.
>> -ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32
>
>I would still add a comment here to say why we are including the generic
>Makefile to prevent that it gets accidentally removed (similar thing for every
>architecture touched by this patch).
>
>With that:
>
>Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com> # for vDSO, aarch64
>Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com> # for aarch64
>

Just sent v3
(https://lore.kernel.org/all/20230310190750.3323802-1-maskray@google.com/)
with the comment changes. Thanks!

>>  include $(srctree)/lib/vdso/Makefile
>>  
>>  hostprogs := vdsomunge
>> diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile
>> index beaf9586338f..1f2427b13410 100644
>> --- a/arch/arm64/kernel/vdso/Makefile
>> +++ b/arch/arm64/kernel/vdso/Makefile
>> @@ -6,9 +6,6 @@
>>  # Heavily based on the vDSO Makefiles for other archs.
>>  #
>>  
>> -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
>> -# the inclusion of generic Makefile.
>> -ARCH_REL_TYPE_ABS := R_AARCH64_JUMP_SLOT|R_AARCH64_GLOB_DAT|R_AARCH64_ABS64
>>  include $(srctree)/lib/vdso/Makefile
>>  
>>  obj-vdso := vgettimeofday.o note.o sigreturn.o
>> diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
>> index f59bd1a4ead6..d014162c5c71 100644
>> --- a/arch/arm64/kernel/vdso32/Makefile
>> +++ b/arch/arm64/kernel/vdso32/Makefile
>> @@ -3,9 +3,6 @@
>>  # Makefile for vdso32
>>  #
>>  
>> -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
>> -# the inclusion of generic Makefile.
>> -ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32
>>  include $(srctree)/lib/vdso/Makefile
>>  
>>  # Same as cc-*option, but using CC_COMPAT instead of CC
>> diff --git a/arch/csky/kernel/vdso/Makefile b/arch/csky/kernel/vdso/Makefile
>> index 0b6909f10667..86c8c4de1b0f 100644
>> --- a/arch/csky/kernel/vdso/Makefile
>> +++ b/arch/csky/kernel/vdso/Makefile
>> @@ -1,8 +1,5 @@
>>  # SPDX-License-Identifier: GPL-2.0-only
>>  
>> -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
>> -# the inclusion of generic Makefile.
>> -ARCH_REL_TYPE_ABS := R_CKCORE_ADDR32|R_CKCORE_JUMP_SLOT
>>  include $(srctree)/lib/vdso/Makefile
>>  
>>  # Symbols present in the vdso
>> diff --git a/arch/loongarch/vdso/Makefile b/arch/loongarch/vdso/Makefile
>> index d89e2ac75f7b..1b2e0f149f55 100644
>> --- a/arch/loongarch/vdso/Makefile
>> +++ b/arch/loongarch/vdso/Makefile
>> @@ -1,9 +1,6 @@
>>  # SPDX-License-Identifier: GPL-2.0
>>  # Objects to go into the VDSO.
>>  
>> -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
>> -# the inclusion of generic Makefile.
>> -ARCH_REL_TYPE_ABS := R_LARCH_32|R_LARCH_64|R_LARCH_MARK_LA|R_LARCH_JUMP_SLOT
>>  include $(srctree)/lib/vdso/Makefile
>>  
>>  obj-vdso-y := elf.o vgetcpu.o vgettimeofday.o sigreturn.o
>> diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile
>> index 1f7d5c6c10b0..c060f3596304 100644
>> --- a/arch/mips/vdso/Makefile
>> +++ b/arch/mips/vdso/Makefile
>> @@ -4,9 +4,6 @@
>>  # Sanitizer runtimes are unavailable and cannot be linked here.
>>   KCSAN_SANITIZE            := n
>>  
>> -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
>> -# the inclusion of generic Makefile.
>> -ARCH_REL_TYPE_ABS := R_MIPS_JUMP_SLOT|R_MIPS_GLOB_DAT
>>  include $(srctree)/lib/vdso/Makefile
>>  
>>  obj-vdso-y := elf.o vgettimeofday.o sigreturn.o
>> diff --git a/arch/powerpc/kernel/vdso/Makefile b/arch/powerpc/kernel/vdso/Makefile
>> index 6a977b0d8ffc..83c347e9136f 100644
>> --- a/arch/powerpc/kernel/vdso/Makefile
>> +++ b/arch/powerpc/kernel/vdso/Makefile
>> @@ -2,7 +2,6 @@
>>  
>>  # List of files in the vdso, has to be asm only for now
>>  
>> -ARCH_REL_TYPE_ABS :=
>> R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_PPC_ADDR16|R_PPC_ADDR16_LO|R_PPC_ADDR16_HI|R_PPC_ADDR16_HA|R_PPC_ADDR14|R_PPC_ADDR14_BRTAKEN|R_PPC_ADDR14_BRNTAKEN|R_PPC_REL24
>>  include $(srctree)/lib/vdso/Makefile
>>  
>>  obj-vdso32 = sigtramp32-32.o gettimeofday-32.o datapage-32.o cacheflush-32.o
>> note-32.o getcpu-32.o
>> diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
>> index 06e6b27f3bcc..d85c37e11b21 100644
>> --- a/arch/riscv/kernel/vdso/Makefile
>> +++ b/arch/riscv/kernel/vdso/Makefile
>> @@ -1,9 +1,6 @@
>>  # SPDX-License-Identifier: GPL-2.0-only
>>  # Copied from arch/tile/kernel/vdso/Makefile
>>  
>> -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
>> -# the inclusion of generic Makefile.
>> -ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOT
>>  include $(srctree)/lib/vdso/Makefile
>>  # Symbols present in the vdso
>>  vdso-syms  = rt_sigreturn
>> diff --git a/arch/s390/kernel/vdso32/Makefile b/arch/s390/kernel/vdso32/Makefile
>> index 245bddfe9bc0..e795fdbbf484 100644
>> --- a/arch/s390/kernel/vdso32/Makefile
>> +++ b/arch/s390/kernel/vdso32/Makefile
>> @@ -2,8 +2,6 @@
>>  # List of files in the vdso
>>  
>>  KCOV_INSTRUMENT := n
>> -ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE
>> -ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT
>>  
>>  include $(srctree)/lib/vdso/Makefile
>>  obj-vdso32 = vdso_user_wrapper-32.o note-32.o
>> diff --git a/arch/s390/kernel/vdso64/Makefile b/arch/s390/kernel/vdso64/Makefile
>> index 9e2b95a222a9..47dbbfdfad68 100644
>> --- a/arch/s390/kernel/vdso64/Makefile
>> +++ b/arch/s390/kernel/vdso64/Makefile
>> @@ -2,8 +2,6 @@
>>  # List of files in the vdso
>>  
>>  KCOV_INSTRUMENT := n
>> -ARCH_REL_TYPE_ABS := R_390_COPY|R_390_GLOB_DAT|R_390_JMP_SLOT|R_390_RELATIVE
>> -ARCH_REL_TYPE_ABS += R_390_GOT|R_390_PLT
>>  
>>  include $(srctree)/lib/vdso/Makefile
>>  obj-vdso64 = vdso_user_wrapper.o note.o
>> diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
>> index 838613ac15b8..b292c24acb8e 100644
>> --- a/arch/x86/entry/vdso/Makefile
>> +++ b/arch/x86/entry/vdso/Makefile
>> @@ -3,10 +3,6 @@
>>  # Building vDSO images for x86.
>>  #
>>  
>> -# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
>> -# the inclusion of generic Makefile.
>> -ARCH_REL_TYPE_ABS := R_X86_64_JUMP_SLOT|R_X86_64_GLOB_DAT|R_X86_64_RELATIVE|
>> -ARCH_REL_TYPE_ABS += R_386_GLOB_DAT|R_386_JMP_SLOT|R_386_RELATIVE
>>  include $(srctree)/lib/vdso/Makefile
>>  
>>  # Sanitizer runtimes are unavailable and cannot be linked here.
>> diff --git a/lib/vdso/Makefile b/lib/vdso/Makefile
>> index e814061d6aa0..9f031eafc465 100644
>> --- a/lib/vdso/Makefile
>> +++ b/lib/vdso/Makefile
>> @@ -5,18 +5,13 @@ GENERIC_VDSO_DIR := $(dir $(GENERIC_VDSO_MK_PATH))
>>  
>>  c-gettimeofday-$(CONFIG_GENERIC_GETTIMEOFDAY) := $(addprefix
>> $(GENERIC_VDSO_DIR), gettimeofday.c)
>>  
>> -# This cmd checks that the vdso library does not contain absolute relocation
>> +# This cmd checks that the vdso library does not contain dynamic relocations.
>>  # It has to be called after the linking of the vdso library and requires it
>>  # as a parameter.
>>  #
>> -# $(ARCH_REL_TYPE_ABS) is defined in the arch specific makefile and corresponds
>> -# to the absolute relocation types printed by "objdump -R" and accepted by the
>> -# dynamic linker.
>> -ifndef ARCH_REL_TYPE_ABS
>> -$(error ARCH_REL_TYPE_ABS is not set)
>> -endif
>> -
>> +# As a workaround for some GNU ld ports which produce unneeded R_*_NONE
>> +# dynamic relocations, ignore R_*_NONE.
>>  quiet_cmd_vdso_check = VDSOCHK $@
>> -      cmd_vdso_check = if $(OBJDUMP) -R $@ | grep -E -h "$(ARCH_REL_TYPE_ABS)"; \
>> +      cmd_vdso_check = if $(READELF) -rW $@ | grep -v _NONE | grep -q " R_\w*_"; \
>>                 then (echo >&2 "$@: dynamic relocations are not supported"; \
>>                   rm -f $@; /bin/false); fi
>
>-- 
>Regards,
>Vincenzo

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-03-10 19:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-30 19:37 [PATCH] vdso: Improve cmd_vdso_check to check all dynamic relocations Fangrui Song
2022-09-10  7:53 ` Fangrui Song
2022-09-28  5:25   ` Fangrui Song
2022-11-14 12:31     ` Christophe Leroy
2022-11-15  0:46       ` Fangrui Song
2022-12-04  4:50         ` Fangrui Song
2022-12-04 16:58           ` Christophe Leroy
2022-12-18 18:31             ` Fangrui Song
2022-12-21 23:51               ` [PATCH v2] " Fangrui Song
2022-12-29 16:22                 ` Palmer Dabbelt
2023-01-27 23:19                   ` Fangrui Song
2023-03-10 14:35                 ` Vincenzo Frascino
2023-03-10 19:10                   ` Fangrui Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).