* [PATCH v3 0/2] Prevent dynamic relocations in vDSO
@ 2024-10-16 8:36 Alexandre Ghiti
2024-10-16 8:36 ` [PATCH v3 1/2] riscv: vdso: Prevent the compiler from inserting calls to memset() Alexandre Ghiti
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Alexandre Ghiti @ 2024-10-16 8:36 UTC (permalink / raw)
To: Vladimir Isaev, Roman Artemev, Guo Ren, Paul Walmsley,
Palmer Dabbelt, Albert Ou, linux-riscv, linux-kernel
Cc: Alexandre Ghiti
Patch 2 uses a generic function to make sure the vDSO object does not
contain any dynamic relocations.
Patch 1 removes a dynamic relocation from vDSO in rv32 found with patch
2.
v2: https://lore.kernel.org/linux-riscv/20240705060902.113294-1-alexghiti@rivosinc.com/
v1: https://lore.kernel.org/linux-riscv/20240326113831.283025-1-alexghiti@rivosinc.com/
Changes in v3:
- Add RB and TB from Bjorn and Vladimir from v1
- Use -fno-builtin instead of the previous option that does not exist in llvm
(Palmer)
Changes in v2:
- Add patch 1 (Björn)
Alexandre Ghiti (2):
riscv: vdso: Prevent the compiler from inserting calls to memset()
riscv: Check that vdso does not contain any dynamic relocations
arch/riscv/kernel/vdso/Makefile | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/2] riscv: vdso: Prevent the compiler from inserting calls to memset()
2024-10-16 8:36 [PATCH v3 0/2] Prevent dynamic relocations in vDSO Alexandre Ghiti
@ 2024-10-16 8:36 ` Alexandre Ghiti
2024-10-17 5:50 ` Guo Ren
2024-10-16 8:36 ` [PATCH v3 2/2] riscv: Check that vdso does not contain any dynamic relocations Alexandre Ghiti
2024-10-17 16:30 ` [PATCH v3 0/2] Prevent dynamic relocations in vDSO patchwork-bot+linux-riscv
2 siblings, 1 reply; 6+ messages in thread
From: Alexandre Ghiti @ 2024-10-16 8:36 UTC (permalink / raw)
To: Vladimir Isaev, Roman Artemev, Guo Ren, Paul Walmsley,
Palmer Dabbelt, Albert Ou, linux-riscv, linux-kernel
Cc: Alexandre Ghiti, stable
The compiler is smart enough to insert a call to memset() in
riscv_vdso_get_cpus(), which generates a dynamic relocation.
So prevent this by using -fno-builtin option.
Fixes: e2c0cdfba7f6 ("RISC-V: User-facing API")
Cc: stable@vger.kernel.org
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
---
arch/riscv/kernel/vdso/Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
index 960feb1526ca..3f1c4b2d0b06 100644
--- a/arch/riscv/kernel/vdso/Makefile
+++ b/arch/riscv/kernel/vdso/Makefile
@@ -18,6 +18,7 @@ obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o
ccflags-y := -fno-stack-protector
ccflags-y += -DDISABLE_BRANCH_PROFILING
+ccflags-y += -fno-builtin
ifneq ($(c-gettimeofday-y),)
CFLAGS_vgettimeofday.o += -fPIC -include $(c-gettimeofday-y)
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 2/2] riscv: Check that vdso does not contain any dynamic relocations
2024-10-16 8:36 [PATCH v3 0/2] Prevent dynamic relocations in vDSO Alexandre Ghiti
2024-10-16 8:36 ` [PATCH v3 1/2] riscv: vdso: Prevent the compiler from inserting calls to memset() Alexandre Ghiti
@ 2024-10-16 8:36 ` Alexandre Ghiti
2024-10-17 5:54 ` Guo Ren
2024-10-17 16:30 ` [PATCH v3 0/2] Prevent dynamic relocations in vDSO patchwork-bot+linux-riscv
2 siblings, 1 reply; 6+ messages in thread
From: Alexandre Ghiti @ 2024-10-16 8:36 UTC (permalink / raw)
To: Vladimir Isaev, Roman Artemev, Guo Ren, Paul Walmsley,
Palmer Dabbelt, Albert Ou, linux-riscv, linux-kernel
Cc: Alexandre Ghiti, Björn Töpel
Like other architectures, use the common cmd_vdso_check to make sure of
that.
Reviewed-by: Björn Töpel <bjorn@rivosinc.com>
Tested-by: Vladimir Isaev <vladimir.isaev@syntacore.com>
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
---
arch/riscv/kernel/vdso/Makefile | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
index 3f1c4b2d0b06..9a1b555e8733 100644
--- a/arch/riscv/kernel/vdso/Makefile
+++ b/arch/riscv/kernel/vdso/Makefile
@@ -45,7 +45,7 @@ $(obj)/vdso.o: $(obj)/vdso.so
# link rule for the .so file, .lds has to be first
$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
- $(call if_changed,vdsold)
+ $(call if_changed,vdsold_and_check)
LDFLAGS_vdso.so.dbg = -shared -soname=linux-vdso.so.1 \
--build-id=sha1 --hash-style=both --eh-frame-hdr
@@ -65,7 +65,8 @@ include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
# actual build commands
# The DSO images are built using a special linker script
# Make sure only to export the intended __vdso_xxx symbol offsets.
-quiet_cmd_vdsold = VDSOLD $@
- cmd_vdsold = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \
+quiet_cmd_vdsold_and_check = VDSOLD $@
+ cmd_vdsold_and_check = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \
$(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
- rm $@.tmp
+ rm $@.tmp && \
+ $(cmd_vdso_check)
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/2] riscv: vdso: Prevent the compiler from inserting calls to memset()
2024-10-16 8:36 ` [PATCH v3 1/2] riscv: vdso: Prevent the compiler from inserting calls to memset() Alexandre Ghiti
@ 2024-10-17 5:50 ` Guo Ren
0 siblings, 0 replies; 6+ messages in thread
From: Guo Ren @ 2024-10-17 5:50 UTC (permalink / raw)
To: Alexandre Ghiti
Cc: Vladimir Isaev, Roman Artemev, Paul Walmsley, Palmer Dabbelt,
Albert Ou, linux-riscv, linux-kernel, stable
On Wed, Oct 16, 2024 at 4:37 PM Alexandre Ghiti <alexghiti@rivosinc.com> wrote:
>
> The compiler is smart enough to insert a call to memset() in
> riscv_vdso_get_cpus(), which generates a dynamic relocation.
>
> So prevent this by using -fno-builtin option.
>
> Fixes: e2c0cdfba7f6 ("RISC-V: User-facing API")
> Cc: stable@vger.kernel.org
> Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> ---
> arch/riscv/kernel/vdso/Makefile | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
> index 960feb1526ca..3f1c4b2d0b06 100644
> --- a/arch/riscv/kernel/vdso/Makefile
> +++ b/arch/riscv/kernel/vdso/Makefile
> @@ -18,6 +18,7 @@ obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o
>
> ccflags-y := -fno-stack-protector
> ccflags-y += -DDISABLE_BRANCH_PROFILING
> +ccflags-y += -fno-builtin
LGTM!
Reviewed-by: Guo Ren <guoren@kernel.org>
>
> ifneq ($(c-gettimeofday-y),)
> CFLAGS_vgettimeofday.o += -fPIC -include $(c-gettimeofday-y)
> --
> 2.39.2
>
--
Best Regards
Guo Ren
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 2/2] riscv: Check that vdso does not contain any dynamic relocations
2024-10-16 8:36 ` [PATCH v3 2/2] riscv: Check that vdso does not contain any dynamic relocations Alexandre Ghiti
@ 2024-10-17 5:54 ` Guo Ren
0 siblings, 0 replies; 6+ messages in thread
From: Guo Ren @ 2024-10-17 5:54 UTC (permalink / raw)
To: Alexandre Ghiti
Cc: Vladimir Isaev, Roman Artemev, Paul Walmsley, Palmer Dabbelt,
Albert Ou, linux-riscv, linux-kernel, Björn Töpel
On Wed, Oct 16, 2024 at 4:38 PM Alexandre Ghiti <alexghiti@rivosinc.com> wrote:
>
> Like other architectures, use the common cmd_vdso_check to make sure of
> that.
>
> Reviewed-by: Björn Töpel <bjorn@rivosinc.com>
> Tested-by: Vladimir Isaev <vladimir.isaev@syntacore.com>
> Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> ---
> arch/riscv/kernel/vdso/Makefile | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
> index 3f1c4b2d0b06..9a1b555e8733 100644
> --- a/arch/riscv/kernel/vdso/Makefile
> +++ b/arch/riscv/kernel/vdso/Makefile
> @@ -45,7 +45,7 @@ $(obj)/vdso.o: $(obj)/vdso.so
>
> # link rule for the .so file, .lds has to be first
> $(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
> - $(call if_changed,vdsold)
> + $(call if_changed,vdsold_and_check)
> LDFLAGS_vdso.so.dbg = -shared -soname=linux-vdso.so.1 \
> --build-id=sha1 --hash-style=both --eh-frame-hdr
>
> @@ -65,7 +65,8 @@ include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
> # actual build commands
> # The DSO images are built using a special linker script
> # Make sure only to export the intended __vdso_xxx symbol offsets.
> -quiet_cmd_vdsold = VDSOLD $@
> - cmd_vdsold = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \
> +quiet_cmd_vdsold_and_check = VDSOLD $@
> + cmd_vdsold_and_check = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \
> $(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
> - rm $@.tmp
> + rm $@.tmp && \
> + $(cmd_vdso_check)
Following other architectures to append a $(cmd_vdso_check) is okay.
Reviewed-by: Guo Ren <guoren@kernel.org>
> --
> 2.39.2
>
--
Best Regards
Guo Ren
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/2] Prevent dynamic relocations in vDSO
2024-10-16 8:36 [PATCH v3 0/2] Prevent dynamic relocations in vDSO Alexandre Ghiti
2024-10-16 8:36 ` [PATCH v3 1/2] riscv: vdso: Prevent the compiler from inserting calls to memset() Alexandre Ghiti
2024-10-16 8:36 ` [PATCH v3 2/2] riscv: Check that vdso does not contain any dynamic relocations Alexandre Ghiti
@ 2024-10-17 16:30 ` patchwork-bot+linux-riscv
2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+linux-riscv @ 2024-10-17 16:30 UTC (permalink / raw)
To: Alexandre Ghiti
Cc: linux-riscv, vladimir.isaev, roman.artemev, guoren,
paul.walmsley, palmer, aou, linux-kernel
Hello:
This series was applied to riscv/linux.git (fixes)
by Palmer Dabbelt <palmer@rivosinc.com>:
On Wed, 16 Oct 2024 10:36:23 +0200 you wrote:
> Patch 2 uses a generic function to make sure the vDSO object does not
> contain any dynamic relocations.
>
> Patch 1 removes a dynamic relocation from vDSO in rv32 found with patch
> 2.
>
> v2: https://lore.kernel.org/linux-riscv/20240705060902.113294-1-alexghiti@rivosinc.com/
> v1: https://lore.kernel.org/linux-riscv/20240326113831.283025-1-alexghiti@rivosinc.com/
>
> [...]
Here is the summary with links:
- [v3,1/2] riscv: vdso: Prevent the compiler from inserting calls to memset()
https://git.kernel.org/riscv/c/f431f67ff6c2
- [v3,2/2] riscv: Check that vdso does not contain any dynamic relocations
https://git.kernel.org/riscv/c/fcb5dcb789a2
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-10-17 16:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-16 8:36 [PATCH v3 0/2] Prevent dynamic relocations in vDSO Alexandre Ghiti
2024-10-16 8:36 ` [PATCH v3 1/2] riscv: vdso: Prevent the compiler from inserting calls to memset() Alexandre Ghiti
2024-10-17 5:50 ` Guo Ren
2024-10-16 8:36 ` [PATCH v3 2/2] riscv: Check that vdso does not contain any dynamic relocations Alexandre Ghiti
2024-10-17 5:54 ` Guo Ren
2024-10-17 16:30 ` [PATCH v3 0/2] Prevent dynamic relocations in vDSO patchwork-bot+linux-riscv
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®