Re: [PATCH v5 12/24] vdso: Add the vdsocheck tool

From: Mukesh Kumar Chaurasiya

Date: Thu Sep 10 2026 - 02:59:18 EST


On Tue, Sep 08, 2026 at 08:33:46AM +0200, Thomas Weißschuh wrote:
> All vDSO code needs to be completely position independent. Symbol
> references are marked as hidden so the compiler emits PC-relative
> relocations. However there are cases where the compiler may still
> emit absolute relocations, as they are valid in regular PIC DSO code.
> These would be resolved by the linker and will break at runtime.
> This has been observed on arm64, see commit 0c314cda9325 ("arm64: vdso:
> Work around invalid absolute relocations from GCC")
>
> Introduce a tool to check for absolute relocations during the build,
> as the current inline-shell logic is not expressive enough.
> The check is done on the object files as the relocations will not exist
> anymore in the final DSO. As there is no extension point for the
> compilation of each object file, perform the validation in vdso_check.
>
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>
> ---
> Makefile | 19 ++
> lib/vdso/Kconfig | 5 +
> lib/vdso/Makefile | 2 +
> lib/vdso/Makefile.include | 14 ++
> lib/vdso/check/.gitignore | 3 +
> lib/vdso/check/Makefile | 34 +++
> lib/vdso/check/elf.rs | 498 ++++++++++++++++++++++++++++++++++++++++++++
> lib/vdso/check/vdsocheck.rs | 154 ++++++++++++++
> 8 files changed, 729 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index 4ad67b737af7..e6e0dd7818ef 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1559,6 +1559,25 @@ vdso_install: export INSTALL_FILES = $(vdso-install-y)
> vdso_install:
> $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vdsoinst
>
> +# ---------------------------------------------------------------------------
> +# vDSO check
> +
> +ifdef CONFIG_RUST_IS_AVAILABLE
> +ifdef CONFIG_VDSO_CHECK
> +
> +# Build the checker early.
> +prepare: vdsocheck
> +
> +# If the architecture builds the vDSO early, make sure to be earlier.
> +PHONY += vdso_prepare
> +vdso_prepare: vdsocheck
> +
> +PHONY += vdsocheck
> +vdsocheck:
> + $(Q)$(MAKE) $(build)=lib/vdso/check $@
> +endif
> +endif
> +
> # ---------------------------------------------------------------------------
> # Tools
>
> diff --git a/lib/vdso/Kconfig b/lib/vdso/Kconfig
> index 597f5f0f9681..112b42a5aeb1 100644
> --- a/lib/vdso/Kconfig
> +++ b/lib/vdso/Kconfig
> @@ -23,3 +23,8 @@ config VDSO_GETRANDOM
> select VDSO_DATASTORE
> help
> Selected by architectures that support vDSO getrandom().
> +
> +config VDSO_CHECK
> + bool
> + help
> + Selected for architectures that are supported by the 'vdsocheck' progam.
s/progam/program

Regards,
Mukesh