[v3] Linux: Switch back to assembly syscall wrapper for prctl (bug 29770)
Checks
Context |
Check |
Description |
redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Testing passed
|
redhat-pt-bot/TryBot-32bit |
success
|
Build for i686
|
linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Testing passed
|
Commit Message
Commit ff026950e280bc3e9487b41b460fb31bc5b57721 ("Add a C wrapper for
prctl [BZ #25896]") replaced the assembler wrapper with a C function.
However, on powerpc64le-linux-gnu, the C variadic function
implementation requires extra work in the caller to set up the
parameter save area. Calling a function that needs a parameter save
area without one (because the prototype used indicates the function is
not variadic) corrupts the caller's stack. The Linux manual pages
project documents prctl as a non-variadic function. This has resulted
in various projects over the years using non-variadic prototypes,
including the sanitizer libraries in LLVm and GCC (GCC PR 113728).
This commit switches back to the assembler implementation on most
targets and only keeps the C implementation for x86-64 x32.
Also add the __prctl_time64 alias from commit
b39ffab860cd743a82c91946619f1b8158b0b65e ("Linux: Add time64 alias for
prctl") to sysdeps/unix/sysv/linux/syscalls.list; it was not yet
present in commit ff026950e280bc3e9487b41b460fb31bc5b57721.
This restores the old ABI on powerpc64le-linux-gnu, thus fixing
bug 29770.
---
v3: Commit message updated.
sysdeps/unix/sysv/linux/syscalls.list | 1 +
sysdeps/unix/sysv/linux/{ => x86_64/x32}/prctl.c | 5 +----
2 files changed, 2 insertions(+), 4 deletions(-)
base-commit: 491e55beab7457ed310a4a47496f4a333c5d1032
Comments
Hi Florian,
On mer. 14 févr. 2024 16:55:10, Florian Weimer wrote:
> Commit ff026950e280bc3e9487b41b460fb31bc5b57721 ("Add a C wrapper for
> prctl [BZ #25896]") replaced the assembler wrapper with a C function.
> However, on powerpc64le-linux-gnu, the C variadic function
> implementation requires extra work in the caller to set up the
> parameter save area. Calling a function that needs a parameter save
> area without one (because the prototype used indicates the function is
> not variadic) corrupts the caller's stack. The Linux manual pages
> project documents prctl as a non-variadic function. This has resulted
> in various projects over the years using non-variadic prototypes,
> including the sanitizer libraries in LLVm and GCC (GCC PR 113728).
>
> This commit switches back to the assembler implementation on most
> targets and only keeps the C implementation for x86-64 x32.
>
> Also add the __prctl_time64 alias from commit
> b39ffab860cd743a82c91946619f1b8158b0b65e ("Linux: Add time64 alias for
> prctl") to sysdeps/unix/sysv/linux/syscalls.list; it was not yet
> present in commit ff026950e280bc3e9487b41b460fb31bc5b57721.
>
> This restores the old ABI on powerpc64le-linux-gnu, thus fixing
> bug 29770.
>
> ---
> v3: Commit message updated.
>
> sysdeps/unix/sysv/linux/syscalls.list | 1 +
> sysdeps/unix/sysv/linux/{ => x86_64/x32}/prctl.c | 5 +----
> 2 files changed, 2 insertions(+), 4 deletions(-)
LGTM, the extra info in the commit logs are much appreciated :)
Reviewed-By: Simon Chopin <simon.chopin@canonical.com>
>
> diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
> index 73e941ef89..9ac42c3436 100644
> --- a/sysdeps/unix/sysv/linux/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/syscalls.list
> @@ -46,6 +46,7 @@ open_tree EXTRA open_tree i:isU open_tree
> pipe2 - pipe2 i:fi __pipe2 pipe2
> pidfd_open EXTRA pidfd_open i:iU pidfd_open
> pidfd_getfd EXTRA pidfd_getfd i:iiU pidfd_getfd
> +prctl EXTRA prctl i:iiiii __prctl prctl __prctl_time64
> pivot_root EXTRA pivot_root i:ss pivot_root
> pidfd_send_signal EXTRA pidfd_send_signal i:iiPU pidfd_send_signal
> process_madvise EXTRA process_madvise i:iPniU process_madvise
> diff --git a/sysdeps/unix/sysv/linux/prctl.c b/sysdeps/unix/sysv/linux/x86_64/x32/prctl.c
> similarity index 93%
> rename from sysdeps/unix/sysv/linux/prctl.c
> rename to sysdeps/unix/sysv/linux/x86_64/x32/prctl.c
> index 52d234ea0d..4bf1b479a0 100644
> --- a/sysdeps/unix/sysv/linux/prctl.c
> +++ b/sysdeps/unix/sysv/linux/x86_64/x32/prctl.c
> @@ -1,4 +1,4 @@
> -/* prctl - Linux specific syscall.
> +/* prctl - Linux specific syscall. x86-64 x32 version.
> Copyright (C) 2020-2024 Free Software Foundation, Inc.
> This file is part of the GNU C Library.
>
> @@ -40,6 +40,3 @@ __prctl (int option, ...)
>
> libc_hidden_def (__prctl)
> weak_alias (__prctl, prctl)
> -#if __TIMESIZE != 64
> -weak_alias (__prctl, __prctl_time64)
> -#endif
>
> base-commit: 491e55beab7457ed310a4a47496f4a333c5d1032
>
@@ -46,6 +46,7 @@ open_tree EXTRA open_tree i:isU open_tree
pipe2 - pipe2 i:fi __pipe2 pipe2
pidfd_open EXTRA pidfd_open i:iU pidfd_open
pidfd_getfd EXTRA pidfd_getfd i:iiU pidfd_getfd
+prctl EXTRA prctl i:iiiii __prctl prctl __prctl_time64
pivot_root EXTRA pivot_root i:ss pivot_root
pidfd_send_signal EXTRA pidfd_send_signal i:iiPU pidfd_send_signal
process_madvise EXTRA process_madvise i:iPniU process_madvise
similarity index 93%
rename from sysdeps/unix/sysv/linux/prctl.c
rename to sysdeps/unix/sysv/linux/x86_64/x32/prctl.c
@@ -1,4 +1,4 @@
-/* prctl - Linux specific syscall.
+/* prctl - Linux specific syscall. x86-64 x32 version.
Copyright (C) 2020-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -40,6 +40,3 @@ __prctl (int option, ...)
libc_hidden_def (__prctl)
weak_alias (__prctl, prctl)
-#if __TIMESIZE != 64
-weak_alias (__prctl, __prctl_time64)
-#endif