From 44ecd67d10d0f79d659e4c4eb6ca83bd235acf71 Mon Sep 17 00:00:00 2001 From: Patsy Griffin Date: Wed, 28 Feb 2024 20:54:04 -0500 Subject: [PATCH] Switch back to assembly syscall wrapper for prctl (RHEL-23472) --- .glibc.metadata | 1 + glibc-RHEL-23472.patch | 140 +++++++++++++++++++++++++++++++++++++++++ glibc.spec | 6 +- 3 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 .glibc.metadata create mode 100644 glibc-RHEL-23472.patch diff --git a/.glibc.metadata b/.glibc.metadata new file mode 100644 index 0000000..ebacb12 --- /dev/null +++ b/.glibc.metadata @@ -0,0 +1 @@ +7c3b8890a6346793b6334cc5f2fea5d437d307b8 glibc-2.34.tar.xz diff --git a/glibc-RHEL-23472.patch b/glibc-RHEL-23472.patch new file mode 100644 index 0000000..95aae42 --- /dev/null +++ b/glibc-RHEL-23472.patch @@ -0,0 +1,140 @@ +commit 6a04404521ac4119ae36827eeb288ea84eee7cf6 +Author: Florian Weimer +Date: Sat Feb 17 09:17:04 2024 +0100 + + Linux: Switch back to assembly syscall wrapper for prctl (bug 29770) + + 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. + + Reviewed-By: Simon Chopin + + Resolved conflicts: + sysdeps/unix/sysv/linux/syscalls.list + sysdeps/unix/sysv/linux/x86_64/x32/prctl.c + +diff -Nrup a/sysdeps/unix/sysv/linux/prctl.c b/sysdeps/unix/sysv/linux/prctl.c +--- a/sysdeps/unix/sysv/linux/prctl.c 2021-08-01 21:33:43.000000000 -0400 ++++ b/sysdeps/unix/sysv/linux/prctl.c 1969-12-31 19:00:00.000000000 -0500 +@@ -1,45 +0,0 @@ +-/* prctl - Linux specific syscall. +- Copyright (C) 2020-2021 Free Software Foundation, Inc. +- This file is part of the GNU C Library. +- +- The GNU C Library is free software; you can redistribute it and/or +- modify it under the terms of the GNU Lesser General Public +- License as published by the Free Software Foundation; either +- version 2.1 of the License, or (at your option) any later version. +- +- The GNU C Library is distributed in the hope that it will be useful, +- but WITHOUT ANY WARRANTY; without even the implied warranty of +- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- Lesser General Public License for more details. +- +- You should have received a copy of the GNU Lesser General Public +- License along with the GNU C Library; if not, see +- . */ +- +-#include +-#include +-#include +- +-/* Unconditionally read all potential arguments. This may pass +- garbage values to the kernel, but avoids the need for teaching +- glibc the argument counts of individual options (including ones +- that are added to the kernel in the future). */ +- +-int +-__prctl (int option, ...) +-{ +- va_list arg; +- va_start (arg, option); +- unsigned long int arg2 = va_arg (arg, unsigned long int); +- unsigned long int arg3 = va_arg (arg, unsigned long int); +- unsigned long int arg4 = va_arg (arg, unsigned long int); +- unsigned long int arg5 = va_arg (arg, unsigned long int); +- va_end (arg); +- return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5); +-} +- +-libc_hidden_def (__prctl) +-weak_alias (__prctl, prctl) +-#if __TIMESIZE != 64 +-weak_alias (__prctl, __prctl_time64) +-#endif +diff -Nrup a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list +--- a/sysdeps/unix/sysv/linux/syscalls.list 2021-08-01 21:33:43.000000000 -0400 ++++ b/sysdeps/unix/sysv/linux/syscalls.list 2024-02-27 14:33:01.594782897 -0500 +@@ -41,6 +41,7 @@ munlockall - munlockall i: munlockall + nfsservctl EXTRA nfsservctl i:ipp __compat_nfsservctl nfsservctl@GLIBC_2.0:GLIBC_2.28 + pipe - pipe i:f __pipe pipe + pipe2 - pipe2 i:fi __pipe2 pipe2 ++prctl EXTRA prctl i:iiiii __prctl prctl __prctl_time64 + pivot_root EXTRA pivot_root i:ss pivot_root + query_module EXTRA query_module i:sipip __compat_query_module query_module@GLIBC_2.0:GLIBC_2.23 + quotactl EXTRA quotactl i:isip quotactl +diff -Nrup a/sysdeps/unix/sysv/linux/x86_64/x32/prctl.c b/sysdeps/unix/sysv/linux/x86_64/x32/prctl.c +--- a/sysdeps/unix/sysv/linux/x86_64/x32/prctl.c 1969-12-31 19:00:00.000000000 -0500 ++++ b/sysdeps/unix/sysv/linux/x86_64/x32/prctl.c 2024-02-27 14:35:03.388602623 -0500 +@@ -0,0 +1,42 @@ ++/* prctl - Linux specific syscall. x86-64 x32 version. ++ Copyright (C) 2020-2021 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ . */ ++ ++#include ++#include ++#include ++ ++/* Unconditionally read all potential arguments. This may pass ++ garbage values to the kernel, but avoids the need for teaching ++ glibc the argument counts of individual options (including ones ++ that are added to the kernel in the future). */ ++ ++int ++__prctl (int option, ...) ++{ ++ va_list arg; ++ va_start (arg, option); ++ unsigned long int arg2 = va_arg (arg, unsigned long int); ++ unsigned long int arg3 = va_arg (arg, unsigned long int); ++ unsigned long int arg4 = va_arg (arg, unsigned long int); ++ unsigned long int arg5 = va_arg (arg, unsigned long int); ++ va_end (arg); ++ return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5); ++} ++ ++libc_hidden_def (__prctl) ++weak_alias (__prctl, prctl) diff --git a/glibc.spec b/glibc.spec index a573345..b3384c9 100644 --- a/glibc.spec +++ b/glibc.spec @@ -155,7 +155,7 @@ end \ Summary: The GNU libc libraries Name: glibc Version: %{glibcversion} -Release: 100%{?dist} +Release: 101%{?dist} # In general, GPLv2+ is used by programs, LGPLv2+ is used for # libraries. @@ -808,6 +808,7 @@ Patch571: glibc-RHEL-16643-5.patch Patch572: glibc-RHEL-16643-6.patch Patch573: glibc-RHEL-19444.patch Patch574: glibc-RHEL-21556.patch +Patch575: glibc-RHEL-23472.patch ############################################################################## # Continued list of core "glibc" package information: @@ -2966,6 +2967,9 @@ update_gconv_modules_cache () %endif %changelog +* Tue Feb 27 2024 Patsy Griffin - 2.34-101 +- Switch back to assembly syscall wrapper for prctl (RHEL-23472) + * Wed Jan 24 2024 Patsy Griffin - 2.34-100 - manual: fix order of arguments of memalign and aligned_alloc (RHEL-21556)