[PATCH v2] riscv: vdso.lds.S: Do not export __vdso_getrandom when building a 32-bit vDSO
Xi Ruoyao
xry111 at xry111.site
Thu May 1 02:23:14 PDT 2025
On Wed, 2025-04-23 at 13:03 -0700, Nathan Chancellor wrote:
> ld.lld defaults to '--no-undefined-version', which causes the compat
> vDSO for 64-bit builds and the regular vDSO for 32-bit builds to break
> after wiring up the vDSO getrandom() call because __vdso_getrandom is
> unconditionally exported, even though it is not always present.
>
> ld.lld: error: version script assignment of 'LINUX_4.15' to symbol '__vdso_getrandom' failed: symbol not defined
>
> Move the export of __vdso_getrandom() under an ifdef to only include it
> when CONFIG_VDSO_GETRANDOM is defined (to exclude 32-bit builds) and
> COMPAT_VDSO is not defined (to exclude the 32-bit vDSO on 64-bit builds)
> to resolve the error.
>
> Fixes: 89079520cef6 ("RISC-V: vDSO: Wire up getrandom() vDSO implementation")
> Reported-by: Linux Kernel Functional Testing <lkft at linaro.org>
> Closes: https://lore.kernel.org/CA+G9fYtN2ie+YtK3H9mrQ5QqrSCFGGjVbtJcfiYX0oHMVWMn9w@mail.gmail.com/
> Signed-off-by: Nathan Chancellor <nathan at kernel.org>
Reviewed-by: Xi Ruoyao <xry111 at xry111.site>
I didn't expect my patch to make it way into -next as it already failed
the CI. I was just too busy on $other_stuff and thinking "hey let me
rework the patch when I get some time" :(.
> ---
> Changes in v2:
> - Include a check for CONFIG_VDSO_GETRANDOM to fix breakage on
> rv32_defconfig. Include the tags for the report that helped highlight
> this issue.
> - Link to v1: https://lore.kernel.org/r/20250423-riscv-fix-compat_vdso-lld-v1-1-820de5cad605@kernel.org
> ---
> arch/riscv/kernel/vdso/vdso.lds.S | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/riscv/kernel/vdso/vdso.lds.S b/arch/riscv/kernel/vdso/vdso.lds.S
> index abc69cda0445..7c15b0f4ee3b 100644
> --- a/arch/riscv/kernel/vdso/vdso.lds.S
> +++ b/arch/riscv/kernel/vdso/vdso.lds.S
> @@ -80,7 +80,9 @@ VERSION
> #ifndef COMPAT_VDSO
> __vdso_riscv_hwprobe;
> #endif
> +#if defined(CONFIG_VDSO_GETRANDOM) && !defined(COMPAT_VDSO)
> __vdso_getrandom;
> +#endif
> local: *;
> };
> }
>
> ---
> base-commit: bafa451a96d0f1404aa1a5a267f78767a55fac71
> change-id: 20250423-riscv-fix-compat_vdso-lld-e1b80b324d97
>
> Best regards,
--
Xi Ruoyao <xry111 at xry111.site>
School of Aerospace Science and Technology, Xidian University
More information about the linux-riscv
mailing list