diff --git a/euc-kr-overrun.patch b/euc-kr-overrun.patch index 993f1a8..ffc993d 100644 --- a/euc-kr-overrun.patch +++ b/euc-kr-overrun.patch @@ -20,23 +20,24 @@ the buffer end. 4 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 iconvdata/bug-iconv13.c -Index: glibc-2.30/iconvdata/Makefile +Index: glibc-2.32/iconvdata/Makefile =================================================================== ---- glibc-2.30.orig/iconvdata/Makefile -+++ glibc-2.30/iconvdata/Makefile -@@ -73,7 +73,7 @@ modules.so := $(addsuffix .so, $(modules +--- glibc-2.32.orig/iconvdata/Makefile ++++ glibc-2.32/iconvdata/Makefile +@@ -73,7 +73,8 @@ modules.so := $(addsuffix .so, $(modules ifeq (yes,$(build-shared)) tests = bug-iconv1 bug-iconv2 tst-loading tst-e2big tst-iconv4 bug-iconv4 \ tst-iconv6 bug-iconv5 bug-iconv6 tst-iconv7 bug-iconv8 bug-iconv9 \ -- bug-iconv10 bug-iconv11 bug-iconv12 -+ bug-iconv10 bug-iconv11 bug-iconv12 bug-iconv13 +- bug-iconv10 bug-iconv11 bug-iconv12 tst-iconv-big5-hkscs-to-2ucs4 ++ bug-iconv10 bug-iconv11 bug-iconv12 tst-iconv-big5-hkscs-to-2ucs4 \ ++ bug-iconv13 ifeq ($(have-thread-library),yes) tests += bug-iconv3 endif -Index: glibc-2.30/iconvdata/bug-iconv13.c +Index: glibc-2.32/iconvdata/bug-iconv13.c =================================================================== --- /dev/null -+++ glibc-2.30/iconvdata/bug-iconv13.c ++++ glibc-2.32/iconvdata/bug-iconv13.c @@ -0,0 +1,53 @@ +/* bug 24973: Test EUC-KR module + Copyright (C) 2019 Free Software Foundation, Inc. @@ -91,10 +92,10 @@ Index: glibc-2.30/iconvdata/bug-iconv13.c +} + +#include -Index: glibc-2.30/iconvdata/euc-kr.c +Index: glibc-2.32/iconvdata/euc-kr.c =================================================================== ---- glibc-2.30.orig/iconvdata/euc-kr.c -+++ glibc-2.30/iconvdata/euc-kr.c +--- glibc-2.32.orig/iconvdata/euc-kr.c ++++ glibc-2.32/iconvdata/euc-kr.c @@ -80,11 +80,7 @@ euckr_from_ucs4 (uint32_t ch, unsigned c \ if (ch <= 0x9f) \ @@ -108,10 +109,10 @@ Index: glibc-2.30/iconvdata/euc-kr.c { \ /* This is illegal. */ \ STANDARD_FROM_LOOP_ERR_HANDLER (1); \ -Index: glibc-2.30/iconvdata/ksc5601.h +Index: glibc-2.32/iconvdata/ksc5601.h =================================================================== ---- glibc-2.30.orig/iconvdata/ksc5601.h -+++ glibc-2.30/iconvdata/ksc5601.h +--- glibc-2.32.orig/iconvdata/ksc5601.h ++++ glibc-2.32/iconvdata/ksc5601.h @@ -50,15 +50,15 @@ ksc5601_to_ucs4 (const unsigned char **s unsigned char ch2; int idx; diff --git a/fix-locking-in-_IO_cleanup.patch b/fix-locking-in-_IO_cleanup.patch index 5e2c956..97d1cf7 100644 --- a/fix-locking-in-_IO_cleanup.patch +++ b/fix-locking-in-_IO_cleanup.patch @@ -5,10 +5,10 @@ the stdio streams anywhere. This fixes a conformance issue and potential heap corruption during exit. The test nptl/tst-stdio1 is removed as that was expecting the problematic behaviour. -Index: glibc-2.31/libio/genops.c +Index: glibc-2.32/libio/genops.c =================================================================== ---- glibc-2.31.orig/libio/genops.c -+++ glibc-2.31/libio/genops.c +--- glibc-2.32.orig/libio/genops.c ++++ glibc-2.32/libio/genops.c @@ -682,7 +682,7 @@ _IO_adjust_column (unsigned start, const libc_hidden_def (_IO_adjust_column) @@ -114,10 +114,10 @@ Index: glibc-2.31/libio/genops.c /* We currently don't have a reliable mechanism for making sure that C++ static destructors are executed in the correct order. -Index: glibc-2.31/libio/libioP.h +Index: glibc-2.32/libio/libioP.h =================================================================== ---- glibc-2.31.orig/libio/libioP.h -+++ glibc-2.31/libio/libioP.h +--- glibc-2.32.orig/libio/libioP.h ++++ glibc-2.32/libio/libioP.h @@ -487,7 +487,6 @@ extern int _IO_new_do_write (FILE *, con extern int _IO_old_do_write (FILE *, const char *, size_t); extern int _IO_wdo_write (FILE *, const wchar_t *, size_t); @@ -126,22 +126,22 @@ Index: glibc-2.31/libio/libioP.h extern int _IO_flush_all (void); libc_hidden_proto (_IO_flush_all) extern int _IO_cleanup (void); -Index: glibc-2.31/nptl/Makefile +Index: glibc-2.32/sysdeps/pthread/Makefile =================================================================== ---- glibc-2.31.orig/nptl/Makefile -+++ glibc-2.31/nptl/Makefile -@@ -295,7 +295,7 @@ tests = tst-attr1 tst-attr2 tst-attr3 ts - tst-signal6 \ - tst-exec1 tst-exec2 tst-exec3 tst-exec4 tst-exec5 \ - tst-exit1 tst-exit2 tst-exit3 \ -- tst-stdio1 tst-stdio2 \ -+ tst-stdio2 \ - tst-stack1 tst-stack2 tst-stack3 tst-stack4 tst-pthread-getattr \ - tst-pthread-attr-affinity tst-pthread-mutexattr \ - tst-unload \ -Index: glibc-2.31/nptl/tst-stdio1.c +--- glibc-2.32.orig/sysdeps/pthread/Makefile ++++ glibc-2.32/sysdeps/pthread/Makefile +@@ -99,7 +99,7 @@ tests += tst-cnd-basic tst-mtx-trylock t + tst-signal4 tst-signal5 tst-signal6 tst-signal8 \ + tst-spin1 tst-spin2 tst-spin3 tst-spin4 \ + tst-stack1 \ +- tst-stdio1 tst-stdio2 \ ++ tst-stdio2 \ + tst-pt-sysconf \ + tst-pt-tls1 tst-pt-tls2 \ + tst-tsd1 tst-tsd2 tst-tsd5 tst-tsd6 \ +Index: glibc-2.32/sysdeps/pthread/tst-stdio1.c =================================================================== ---- glibc-2.31.orig/nptl/tst-stdio1.c +--- glibc-2.32.orig/sysdeps/pthread/tst-stdio1.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (C) 2002-2020 Free Software Foundation, Inc. diff --git a/glibc-2.31.tar.xz b/glibc-2.31.tar.xz deleted file mode 100644 index dcee34e..0000000 --- a/glibc-2.31.tar.xz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9246fe44f68feeec8c666bb87973d590ce0137cca145df014c72ec95be9ffd17 -size 16676764 diff --git a/glibc-2.31.tar.xz.sig b/glibc-2.31.tar.xz.sig deleted file mode 100644 index f0e3c50..0000000 --- a/glibc-2.31.tar.xz.sig +++ /dev/null @@ -1,11 +0,0 @@ ------BEGIN PGP SIGNATURE----- - -iQEzBAABCAAdFiEEvHxzcmN+wQxX16plecQ9+/HPIYcFAl41bZQACgkQecQ9+/HP -IYfUQgf/d5dAUK871suOXNfFcw67sHEPsnLami/WPXyyw/pXDjuLZYLNTGOmpQol -VdV38p1BxaJs0A5EBSVm32xhgMR2Jum6qKu/mpEnfy5ac1lGiTxO1pVMDDXjdPaK -S8+nJXTf3MVYUCmu4W426DdRkdsBmP0KlKo8ZFBlhAJoPXeikJMGOf/uUR5VimNE -VY2EPDHEaqrBco/lm3LqZ6RWu7+B7K5GXR2EMLBDLIKirYd17nIqzjhFjv0pcS/e -UE2K0vxA5ip59ep4xxRmDu8bOshlZlfhHGuAiD+B2iwxwWFv6D75IyrtqB5KHWtD -/crvu7njsCsgWJKNA83pkt19nj9mxQ== -=TAIE ------END PGP SIGNATURE----- diff --git a/glibc-2.32.tar.xz b/glibc-2.32.tar.xz new file mode 100644 index 0000000..5f5fbda --- /dev/null +++ b/glibc-2.32.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1627ea54f5a1a8467032563393e0901077626dc66f37f10ee6363bb722222836 +size 16744512 diff --git a/glibc-2.32.tar.xz.sig b/glibc-2.32.tar.xz.sig new file mode 100644 index 0000000..fe02c44 --- /dev/null +++ b/glibc-2.32.tar.xz.sig @@ -0,0 +1,16 @@ +-----BEGIN PGP SIGNATURE----- + +iQIzBAABCAAdFiEEcnNUKzmWLfeymZMUFnkrTqJTQPgFAl8rekMACgkQFnkrTqJT +QPhHYhAAkiVohx/PgarNM+CWOjVAfI/vjvZ9ETUNvSpdKDkTKqScwJyRMxSHGHqW +ri1WBv+NRq5HHwpceEHw3PrAT22sDMHEiB9A7Aeu4Yf1TimZ9+tvZdzUPQBnbbZT +3vE5LZmCepoX+kRWKpUPS8hGwwlZQbR/OKgAwOa/mHnK1A5ySvRryELPoBhlSpL2 +PyDUmnwvfNPkF3RsLf1GGAKUrgQqg9dYbJwRUaukOn0+VKiLmVLsYZIdBdYt589M +Cfj7IUdNfY1wb0CpZJWZZGRtkopxYvRDeb6g7LCoe16zUAzEUhXdumlxeXYSh7Ge +ouqdln7a0GHtQS90sdrFeHgqqhbCfxn4bvKs9Ny33T1I4Al4mI5PiPiryjsPpdjH +TA5uNKAyFRmy5WuPCFTirRGy6EldrAQ1o/2icbqHhknzz+/9ctUr0mVW3supCmSZ +DoLp5SG3CjGY9phTZcobBlIFuaFTEU8jV80LiK5glc/GTHa4czPxnc0MXaxy8WWF +taZZZ67IAbY/EfuVfQC1NPTHOmrEszfxKQ8CYKisfGP/XYNfYLyjdf7JyyjkKHEH +xt904YYMsi6aw2lsq39Ajb3Ub3BZ63QEYPuD9yp0BizwTaQTnX5rtXROqxDkwdSi +hauXkCvU1ubuBJ3s+u9ljxveWV6TGHfDgqkxmJj2SpYgBYwBcXw= +=vBEx +-----END PGP SIGNATURE----- diff --git a/glibc-bindresvport-blacklist.diff b/glibc-bindresvport-blacklist.diff index 93d7252..da3524b 100644 --- a/glibc-bindresvport-blacklist.diff +++ b/glibc-bindresvport-blacklist.diff @@ -1,7 +1,7 @@ -Index: glibc-2.27/sunrpc/bindrsvprt.c +Index: glibc-2.32/inet/bindresvport.c =================================================================== ---- glibc-2.27.orig/sunrpc/bindrsvprt.c -+++ glibc-2.27/sunrpc/bindrsvprt.c +--- glibc-2.32.orig/inet/bindresvport.c ++++ glibc-2.32/inet/bindresvport.c @@ -29,6 +29,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ diff --git a/glibc.changes b/glibc.changes index 24fbf3f..8047811 100644 --- a/glibc.changes +++ b/glibc.changes @@ -1,3 +1,73 @@ +------------------------------------------------------------------- +Tue Sep 8 08:00:33 UTC 2020 - Andreas Schwab + +- Keep nsswitch.conf in /etc for SLES15 +- syslog-locking.patch: Correct locking and cancellation cleanup in syslog + functions (bsc#1172085, BZ #26100) +- ifunc-fma4.patch: x86-64: Fix FMA4 detection in ifunc (BZ #26534) + +------------------------------------------------------------------- +Thu Aug 6 08:08:04 UTC 2020 - Andreas Schwab + +- Update to glibc 2.32 + * Unicode 13.0.0 Support + * New locale added: ckb_IQ + * The GNU C Library now loads audit modules listed in the DT_AUDIT and + DT_DEPAUDIT dynamic section entries of the main executable + * powerpc64le supports IEEE128 long double libm/libc redirects when + using the -mabi=ieeelongdouble to compile C code on supported GCC + toolchains + * To help detect buffer overflows and other out-of-bounds accesses + several APIs have been annotated with GCC 'access' attribute + * On Linux, functions the pthread_attr_setsigmask_np and + pthread_attr_getsigmask_np have been added + * The GNU C Library now provides the header file + which declares the variable __libc_single_threaded + * The functions sigabbrev_np and sigdescr_np have been added + * The functions strerrorname_np and strerrordesc_np have been added + * AArch64 now supports standard branch protection security hardening + in glibc when it is built with a GCC that is configured with + --enable-standard-branch-protection (or if -mbranch-protection=standard + flag is passed when building both GCC target libraries and glibc, + in either case a custom GCC is needed) + * The deprecated header and the sysctl function have been + removed + * The sstk function is no longer available to newly linked binaries + * The legacy signal handling functions siginterrupt, sigpause, sighold, + sigrelse, sigignore and sigset, and the sigmask macro have been + deprecated + * ldconfig now defaults to the new format for ld.so.cache + * The deprecated arrays sys_siglist, _sys_siglist, and sys_sigabbrev + are no longer available to newly linked binaries, and their declarations + have been removed from + * The deprecated symbols sys_errlist, _sys_errlist, sys_nerr, and _sys_nerr + are no longer available to newly linked binaries, and their declarations + have been removed from from + * Both strerror and strerror_l now share the same internal buffer in the + calling thread, meaning that the returned string pointer may be invalided + or contents might be overwritten on subsequent calls in the same thread or + if the thread is terminated + * Using weak references to libpthread functions such as pthread_create + or pthread_key_create to detect the singled-threaded nature of a + program is an obsolescent feature + * The "files" NSS module no longer supports the "key" database (used for + secure RPC) + * The __morecore and __after_morecore_hook malloc hooks and the default + implementation __default_morecore have been deprecated + * The hesiod NSS module has been deprecated and will be removed in a + future version of glibc + * CVE-2016-10228: An infinite loop has been fixed in the iconv program when + invoked with the -c option and when processing invalid multi-byte input + sequences + * CVE-2020-10029: Trigonometric functions on x86 targets suffered from stack + corruption when they were passed a pseudo-zero argument + * CVE-2020-1752: A use-after-free vulnerability in the glob function when + expanding ~user has been fixed. + * CVE-2020-6096: A signed comparison vulnerability in the ARMv7 memcpy and + memmove functions has been fixed +- riscv-syscall-clobber.patch, ldbl-96-rem-pio2l.patch, + long-double-alias.patch: Removed + ------------------------------------------------------------------- Tue Jun 23 08:32:23 UTC 2020 - Andreas Schwab diff --git a/glibc.spec b/glibc.spec index 78e66c2..73a179d 100644 --- a/glibc.spec +++ b/glibc.spec @@ -131,7 +131,7 @@ BuildArch: i686 %define powerpc_optimize_cpu_power6 0 %define powerpc_optimize_cpu_power7 0 %define powerpc_optimize_cpu_cell 0 -%endif # ppc, ppc64 +%endif # glibc requires at least kernel 3.2 %define enablekernel 3.2 # some architectures need a newer kernel @@ -148,7 +148,7 @@ BuildArch: i686 %define enablekernel 4.15 %endif -Version: 2.31 +Version: 2.32 Release: 0 %if !%{build_snapshot} %define git_id 0a8262a1b2 @@ -259,12 +259,10 @@ Patch306: glibc-fix-double-loopback.diff ### # Patches from upstream ### -# PATCH-FIX-UPSTREAM riscv: Avoid clobbering register parameters in syscall -Patch1000: riscv-syscall-clobber.patch -# PATCH-FIX-UPSTREAM Avoid ldbl-96 stack corruption from range reduction of pseudo-zero (CVE-2020-10029, BZ #25487) -Patch1001: ldbl-96-rem-pio2l.patch -# PATCH-FIX-UPSTREAM Fix build with GCC 10 when long double = double -Patch1002: long-double-alias.patch +# PATCH-FIX-UPSTREAM Correct locking and cancellation cleanup in syslog functions (BZ #26100) +Patch1000: syslog-locking.patch +# PATCH-FIX-UPSTREAM x86-64: Fix FMA4 detection in ifunc (BZ #26534) +Patch1001: ifunc-fma4.patch ### # Patches awaiting upstream approval @@ -454,7 +452,7 @@ are not essential but recommend to use. makedb: A program to create a database for nss %lang_package -%endif # main +%endif %prep %setup -n glibc-%{version} -q -a 4 @@ -479,7 +477,6 @@ makedb: A program to create a database for nss %patch1000 -p1 %patch1001 -p1 -%patch1002 -p1 %patch2000 -p1 %patch2001 -p1 @@ -689,8 +686,8 @@ configure_and_build_glibc() { %if %{powerpc_optimize_cpu_cell} configure_and_build_glibc ppc-cell-be "$BuildFlags -mcpu=cell" %endif - %endif # %{build_variants} -%endif # optimize_power + %endif +%endif # # Build html documentation @@ -811,7 +808,7 @@ cc-base/elf/ldconfig -vn $destdir cc-base/elf/ldconfig -vn %{buildroot}/%{_lib}/power6x fi %endif -%endif # optimize_power +%endif # Install locales %if %{build_locales} @@ -842,7 +839,11 @@ rm -rf %{buildroot}%{_datadir}/locale/*/ # Miscelanna: install -m 644 %{SOURCE7} %{buildroot}/etc +%if %suse_version > 1500 install -D -m 644 %{SOURCE5} %{buildroot}%{_prefix}/etc/nsswitch.conf +%else +install -m 644 %{SOURCE5} %{buildroot}/etc +%endif mkdir -p %{buildroot}/etc/default install -m 644 nis/nss %{buildroot}/etc/default/ @@ -933,7 +934,7 @@ rm -rf %{buildroot}%{_libdir}/audit rm -rf %{buildroot}%{_infodir} %{buildroot}%{_prefix}/share/i18n rm -f %{buildroot}%{_bindir}/makedb %{buildroot}/var/lib/misc/Makefile rm -f %{buildroot}%{_sbindir}/nscd -%endif # i686 +%endif %ifnarch i686 # /var/lib/misc is incompatible with transactional updates (bsc#1138726) @@ -942,7 +943,7 @@ mv %{buildroot}/var/lib/misc/Makefile %{buildroot}%{_prefix}/share/misc/Makefile ln -s %{_prefix}/share/misc/Makefile.makedb %{buildroot}/var/lib/misc/Makefile %endif -%endif # !utils +%endif # LSB %ifarch %ix86 @@ -964,7 +965,7 @@ ln -sf /%{_lib}/ld.so.1 $RPM_BUILD_ROOT/%{_lib}/ld-lsb-s390.so.3 ln -sf /%{_lib}/ld64.so.1 $RPM_BUILD_ROOT/%{_lib}/ld-lsb-s390x.so.3 %endif -%else # !main +%else %if %{build_utils} @@ -982,9 +983,9 @@ rm -rf %{buildroot}/sbin %{buildroot}%{_includedir} rm %{buildroot}/%{_lib}/lp64d %{buildroot}%{_libdir}/lp64d %endif -%endif # utils +%endif -%endif # !main +%endif %if %{build_main} @@ -1090,8 +1091,12 @@ exit 0 %config /etc/ld.so.conf %attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /etc/ld.so.cache %config(noreplace) /etc/rpc +%if %suse_version > 1500 %attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /etc/nsswitch.conf %{_prefix}/etc/nsswitch.conf +%else +%verify(not md5 size mtime) %config(noreplace) /etc/nsswitch.conf +%endif %attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /etc/gai.conf %doc posix/gai.conf %config(noreplace) /etc/default/nss @@ -1211,7 +1216,7 @@ exit 0 %if %{powerpc_optimize_cpu_cell} %{optimized_libs ppc-cell-be} %endif -%endif # optimize_power +%endif %dir %attr(0700,root,root) /var/cache/ldconfig /sbin/ldconfig %{_bindir}/gencat @@ -1319,7 +1324,7 @@ exit 0 %attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/lib/nscd/hosts %attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/lib/nscd/services %attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/lib/nscd/netgroup -%endif # !i686 +%endif %if %{build_profile} %files profile @@ -1346,9 +1351,9 @@ exit 0 /var/lib/misc/Makefile %files lang -f libc.lang -%endif # !i686 +%endif -%endif # main +%endif %if %{build_utils} %files -n glibc-utils @@ -1364,6 +1369,6 @@ exit 0 %{_bindir}/sotruss %{_bindir}/xtrace %{_bindir}/pldd -%endif # utils +%endif %changelog diff --git a/ifunc-fma4.patch b/ifunc-fma4.patch new file mode 100644 index 0000000..1590cfe --- /dev/null +++ b/ifunc-fma4.patch @@ -0,0 +1,28 @@ +From 23af890b3f04e80da783ba64e6b6d94822e01d54 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ond=C5=99ej=20Ho=C5=A1ek?= +Date: Wed, 26 Aug 2020 04:26:50 +0200 +Subject: [PATCH] x86-64: Fix FMA4 detection in ifunc [BZ #26534] + +A typo in commit 107e6a3c2212ba7a3a4ec7cae8d82d73f7c95d0b causes the +FMA4 code path to be taken on systems that support FMA, even if they do +not support FMA4. Fix this to detect FMA4. +--- + sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h b/sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h +index 7659758972..e5fd5ac9cb 100644 +--- a/sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h ++++ b/sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h +@@ -32,7 +32,7 @@ IFUNC_SELECTOR (void) + && CPU_FEATURE_USABLE_P (cpu_features, AVX2)) + return OPTIMIZE (fma); + +- if (CPU_FEATURE_USABLE_P (cpu_features, FMA)) ++ if (CPU_FEATURE_USABLE_P (cpu_features, FMA4)) + return OPTIMIZE (fma4); + + return OPTIMIZE (sse2); +-- +2.28.0 + diff --git a/ldbl-96-rem-pio2l.patch b/ldbl-96-rem-pio2l.patch deleted file mode 100644 index 68dd6c2..0000000 --- a/ldbl-96-rem-pio2l.patch +++ /dev/null @@ -1,123 +0,0 @@ -From 9f997ceca28f0634ad78a1ca95b84265f7801ff4 Mon Sep 17 00:00:00 2001 -From: Joseph Myers -Date: Wed, 12 Feb 2020 23:31:56 +0000 -Subject: [PATCH] Avoid ldbl-96 stack corruption from range reduction of - pseudo-zero (bug 25487). - -Bug 25487 reports stack corruption in ldbl-96 sinl on a pseudo-zero -argument (an representation where all the significand bits, including -the explicit high bit, are zero, but the exponent is not zero, which -is not a valid representation for the long double type). - -Although this is not a valid long double representation, existing -practice in this area (see bug 4586, originally marked invalid but -subsequently fixed) is that we still seek to avoid invalid memory -accesses as a result, in case of programs that treat arbitrary binary -data as long double representations, although the invalid -representations of the ldbl-96 format do not need to be consistently -handled the same as any particular valid representation. - -This patch makes the range reduction detect pseudo-zero and unnormal -representations that would otherwise go to __kernel_rem_pio2, and -returns a NaN for them instead of continuing with the range reduction -process. (Pseudo-zero and unnormal representations whose unbiased -exponent is less than -1 have already been safely returned from the -function before this point without going through the rest of range -reduction.) Pseudo-zero representations would previously result in -the value passed to __kernel_rem_pio2 being all-zero, which is -definitely unsafe; unnormal representations would previously result in -a value passed whose high bit is zero, which might well be unsafe -since that is not a form of input expected by __kernel_rem_pio2. - -Tested for x86_64. - -(cherry picked from commit 9333498794cde1d5cca518badf79533a24114b6f) ---- - NEWS | 5 +++ - sysdeps/ieee754/ldbl-96/Makefile | 3 +- - sysdeps/ieee754/ldbl-96/e_rem_pio2l.c | 12 +++++++ - sysdeps/ieee754/ldbl-96/test-sinl-pseudo.c | 41 ++++++++++++++++++++++ - 4 files changed, 60 insertions(+), 1 deletion(-) - create mode 100644 sysdeps/ieee754/ldbl-96/test-sinl-pseudo.c - -Index: glibc-2.31/sysdeps/ieee754/ldbl-96/Makefile -=================================================================== ---- glibc-2.31.orig/sysdeps/ieee754/ldbl-96/Makefile -+++ glibc-2.31/sysdeps/ieee754/ldbl-96/Makefile -@@ -17,5 +17,6 @@ - # . - - ifeq ($(subdir),math) --tests += test-canonical-ldbl-96 test-totalorderl-ldbl-96 -+tests += test-canonical-ldbl-96 test-totalorderl-ldbl-96 test-sinl-pseudo -+CFLAGS-test-sinl-pseudo.c += -fstack-protector-all - endif -Index: glibc-2.31/sysdeps/ieee754/ldbl-96/e_rem_pio2l.c -=================================================================== ---- glibc-2.31.orig/sysdeps/ieee754/ldbl-96/e_rem_pio2l.c -+++ glibc-2.31/sysdeps/ieee754/ldbl-96/e_rem_pio2l.c -@@ -210,6 +210,18 @@ __ieee754_rem_pio2l (long double x, long - return 0; - } - -+ if ((i0 & 0x80000000) == 0) -+ { -+ /* Pseudo-zero and unnormal representations are not valid -+ representations of long double. We need to avoid stack -+ corruption in __kernel_rem_pio2, which expects input in a -+ particular normal form, but those representations do not need -+ to be consistently handled like any particular floating-point -+ value. */ -+ y[1] = y[0] = __builtin_nanl (""); -+ return 0; -+ } -+ - /* Split the 64 bits of the mantissa into three 24-bit integers - stored in a double array. */ - exp = j0 - 23; -Index: glibc-2.31/sysdeps/ieee754/ldbl-96/test-sinl-pseudo.c -=================================================================== ---- /dev/null -+++ glibc-2.31/sysdeps/ieee754/ldbl-96/test-sinl-pseudo.c -@@ -0,0 +1,41 @@ -+/* Test sinl for pseudo-zeros and unnormals for ldbl-96 (bug 25487). -+ Copyright (C) 2020 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 -+ -+static int -+do_test (void) -+{ -+ for (int i = 0; i < 64; i++) -+ { -+ uint64_t sig = i == 63 ? 0 : 1ULL << i; -+ long double ld; -+ SET_LDOUBLE_WORDS (ld, 0x4141, -+ sig >> 32, sig & 0xffffffffULL); -+ /* The requirement is that no stack overflow occurs when the -+ pseudo-zero or unnormal goes through range reduction. */ -+ volatile long double ldr; -+ ldr = sinl (ld); -+ (void) ldr; -+ } -+ return 0; -+} -+ -+#include diff --git a/long-double-alias.patch b/long-double-alias.patch deleted file mode 100644 index 94e0292..0000000 --- a/long-double-alias.patch +++ /dev/null @@ -1,166 +0,0 @@ -From 49348beafe9ba150c9bd48595b3f372299bddbb0 Mon Sep 17 00:00:00 2001 -From: Joseph Myers -Date: Tue, 17 Mar 2020 22:57:42 +0000 -Subject: [PATCH] Fix build with GCC 10 when long double = double. - -On platforms where long double has the same ABI as double, glibc -defines long double functions as aliases for the corresponding double -functions. The declarations of those functions in are -disabled to avoid problems with aliases having incompatible types, but -GCC 10 now gives errors for incompatible types when the long double -function is known to GCC as a built-in function, not just when there -is an incompatible header declaration. - -This patch fixes those errors by using appropriate --fno-builtin- options to compile the double functions. The -list of CFLAGS-* settings is an appropriately adapted version of that -in sysdeps/ieee754/ldbl-opt/Makefile used there for building nldbl-*.c -files; in particular, the options are used even if GCC does not -currently have a built-in function of a given function, so that adding -such a built-in function in future will not break the glibc build. -Thus, various of the CFLAGS-* settings are only for future-proofing -and may not currently be needed (and it's possible some could be -irrelevant for other reasons). - -Tested with build-many-glibcs.py for arm-linux-gnueabi (compilers and -glibcs builds), where it fixes the build that previously failed. ---- - math/Makefile | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 122 insertions(+) - -diff --git a/math/Makefile b/math/Makefile -index 84a8b94c74..0a5a40430e 100644 ---- a/math/Makefile -+++ b/math/Makefile -@@ -650,6 +650,128 @@ ifneq ($(long-double-fcts),yes) - # We won't compile the `long double' code at all. Tell the `double' code - # to define aliases for the `FUNCl' names. - math-CPPFLAGS += -DNO_LONG_DOUBLE -+# GCC 10 diagnoses aliases with types conflicting with built-in -+# functions. -+CFLAGS-w_acos.c += -fno-builtin-acosl -+CFLAGS-w_acosh.c += -fno-builtin-acoshl -+CFLAGS-w_asin.c += -fno-builtin-asinl -+CFLAGS-s_asinh.c += -fno-builtin-asinhl -+CFLAGS-s_atan.c += -fno-builtin-atanl -+CFLAGS-w_atan2.c += -fno-builtin-atan2l -+CFLAGS-w_atanh.c += -fno-builtin-atanhl -+CFLAGS-s_cabs.c += -fno-builtin-cabsl -+CFLAGS-s_cacos.c += -fno-builtin-cacosl -+CFLAGS-s_cacosh.c += -fno-builtin-cacoshl -+CFLAGS-s_canonicalize.c += -fno-builtin-canonicalizel -+CFLAGS-s_carg.c += -fno-builtin-cargl -+CFLAGS-s_casin.c += -fno-builtin-casinl -+CFLAGS-s_casinh.c += -fno-builtin-casinhl -+CFLAGS-s_catan.c += -fno-builtin-catanl -+CFLAGS-s_catanh.c += -fno-builtin-catanhl -+CFLAGS-s_cbrt.c += -fno-builtin-cbrtl -+CFLAGS-s_ccos.c += -fno-builtin-ccosl -+CFLAGS-s_ccosh.c += -fno-builtin-ccoshl -+CFLAGS-s_ceil.c += -fno-builtin-ceill -+CFLAGS-s_cexp.c += -fno-builtin-cexpl -+CFLAGS-s_cimag.c += -fno-builtin-cimagl -+CFLAGS-s_clog.c += -fno-builtin-clogl -+CFLAGS-s_clog10.c += -fno-builtin-clog10l -+CFLAGS-s_conj.c += -fno-builtin-conjl -+CFLAGS-s_copysign.c += -fno-builtin-copysignl -+CFLAGS-s_cos.c += -fno-builtin-cosl -+CFLAGS-w_cosh.c += -fno-builtin-coshl -+CFLAGS-s_cpow.c += -fno-builtin-cpowl -+CFLAGS-s_cproj.c += -fno-builtin-cprojl -+CFLAGS-s_creal.c += -fno-builtin-creall -+CFLAGS-s_csin.c += -fno-builtin-csinl -+CFLAGS-s_csinh.c += -fno-builtin-csinhl -+CFLAGS-s_csqrt.c += -fno-builtin-csqrtl -+CFLAGS-s_ctan.c += -fno-builtin-ctanl -+CFLAGS-s_ctanh.c += -fno-builtin-ctanhl -+CFLAGS-s_dadd.c += -fno-builtin-daddl -+CFLAGS-s_ddiv.c += -fno-builtin-ddivl -+CFLAGS-s_dmul.c += -fno-builtin-dmull -+CFLAGS-s_dsub.c += -fno-builtin-dsubl -+CFLAGS-s_erf.c += -fno-builtin-erfl -+CFLAGS-s_erfc.c += -fno-builtin-erfcl -+CFLAGS-e_exp.c += -fno-builtin-expl -+CFLAGS-w_exp10.c += -fno-builtin-exp10l -+CFLAGS-e_exp2.c += -fno-builtin-exp2l -+CFLAGS-s_expm1.c += -fno-builtin-expm1l -+CFLAGS-s_fabs.c += -fno-builtin-fabsl -+CFLAGS-s_fadd.c += -fno-builtin-faddl -+CFLAGS-s_fdim.c += -fno-builtin-fdiml -+CFLAGS-s_fdiv.c += -fno-builtin-fdivl -+CFLAGS-s_finite.c += -fno-builtin-finitel -+CFLAGS-s_floor.c += -fno-builtin-floorl -+CFLAGS-s_fma.c += -fno-builtin-fmal -+CFLAGS-s_fmax.c += -fno-builtin-fmaxl -+CFLAGS-s_fmaxmag.c += -fno-builtin-fmaxmagl -+CFLAGS-s_fmin.c += -fno-builtin-fminl -+CFLAGS-s_fminmag.c += -fno-builtin-fminmagl -+CFLAGS-w_fmod.c += -fno-builtin-fmodl -+CFLAGS-s_fmul.c += -fno-builtin-fmull -+CFLAGS-s_frexp.c += -fno-builtin-frexpl -+CFLAGS-s_fromfp.c += -fno-builtin-fromfpl -+CFLAGS-s_fromfpx.c += -fno-builtin-fromfpxl -+CFLAGS-s_fsub.c += -fno-builtin-fsubl -+CFLAGS-s_gamma.c += -fno-builtin-gammal -+CFLAGS-s_getpayload.c += -fno-builtin-getpayloadl -+CFLAGS-w_hypot.c += -fno-builtin-hypotl -+CFLAGS-w_ilogb.c += -fno-builtin-ilogbl -+CFLAGS-s_isinf.c += -fno-builtin-isinfl -+CFLAGS-s_isnan.c += -fno-builtin-isnanl -+CFLAGS-w_j0.c += -fno-builtin-j0l -+CFLAGS-w_j1.c += -fno-builtin-j1l -+CFLAGS-w_jn.c += -fno-builtin-jnl -+CFLAGS-s_ldexp.c += -fno-builtin-ldexpl -+CFLAGS-w_lgamma.c += -fno-builtin-lgammal -+CFLAGS-w_lgamma_r.c += -fno-builtin-lgammal_r -+CFLAGS-w_llogb.c += -fno-builtin-llogbl -+CFLAGS-s_llrint.c += -fno-builtin-llrintl -+CFLAGS-s_llround.c += -fno-builtin-llroundl -+CFLAGS-e_log.c += -fno-builtin-logl -+CFLAGS-w_log10.c += -fno-builtin-log10l -+CFLAGS-w_log1p.c += -fno-builtin-log1pl -+CFLAGS-e_log2.c += -fno-builtin-log2l -+CFLAGS-s_logb.c += -fno-builtin-logbl -+CFLAGS-s_lrint.c += -fno-builtin-lrintl -+CFLAGS-s_lround.c += -fno-builtin-lroundl -+CFLAGS-s_modf.c += -fno-builtin-modfl -+CFLAGS-s_nan.c += -fno-builtin-nanl -+CFLAGS-s_nearbyint.c += -fno-builtin-nearbyintl -+CFLAGS-s_nextafter.c += -fno-builtin-nextafterl -+CFLAGS-s_nextdown.c += -fno-builtin-nextdownl -+CFLAGS-s_nexttoward.c += -fno-builtin-nexttoward -fno-builtin-nexttowardl -+CFLAGS-s_nexttowardf.c += -fno-builtin-nexttowardf -+CFLAGS-s_nextup.c += -fno-builtin-nextupl -+CFLAGS-e_pow.c += -fno-builtin-powl -+CFLAGS-w_remainder.c += -fno-builtin-remainderl -fno-builtin-dreml -+CFLAGS-s_remquo.c += -fno-builtin-remquol -+CFLAGS-s_rint.c += -fno-builtin-rintl -+CFLAGS-s_round.c += -fno-builtin-roundl -+CFLAGS-s_roundeven.c += -fno-builtin-roundevenl -+CFLAGS-w_scalb.c += -fno-builtin-scalbl -+CFLAGS-w_scalbln.c += -fno-builtin-scalblnl -+CFLAGS-s_scalbn.c += -fno-builtin-scalbnl -+CFLAGS-s_setpayload.c += -fno-builtin-setpayloadl -+CFLAGS-s_setpayloadsig.c += -fno-builtin-setpayloadsigl -+CFLAGS-s_significand.c += -fno-builtin-significandl -+CFLAGS-s_sin.c += -fno-builtin-sinl -+CFLAGS-s_sincos.c += -fno-builtin-sincosl -+CFLAGS-w_sinh.c += -fno-builtin-sinhl -+CFLAGS-w_sqrt.c += -fno-builtin-sqrtl -+CFLAGS-s_tan.c += -fno-builtin-tanl -+CFLAGS-s_tanh.c += -fno-builtin-tanhl -+CFLAGS-w_tgamma.c += -fno-builtin-tgammal -+CFLAGS-s_totalorder.c += -fno-builtin-totalorderl -+CFLAGS-s_totalordermag.c += -fno-builtin-totalordermagl -+CFLAGS-s_trunc.c += -fno-builtin-truncl -+CFLAGS-s_ufromfp.c += -fno-builtin-ufromfpl -+CFLAGS-s_ufromfpx.c += -fno-builtin-ufromfpxl -+CFLAGS-s_y0.c += -fno-builtin-y0l -+CFLAGS-s_y1.c += -fno-builtin-y1l -+CFLAGS-s_yn.c += -fno-builtin-ynl - endif - - # These files quiet sNaNs in a way that is optimized away without --- -2.26.2 - diff --git a/riscv-syscall-clobber.patch b/riscv-syscall-clobber.patch deleted file mode 100644 index ce65e3d..0000000 --- a/riscv-syscall-clobber.patch +++ /dev/null @@ -1,181 +0,0 @@ -From be74b42ee2a97009a6cd4fc90126add4a41c583b Mon Sep 17 00:00:00 2001 -From: Adhemerval Zanella -Date: Mon, 10 Feb 2020 10:32:14 -0300 -Subject: [PATCH] riscv: Avoid clobbering register parameters in syscall - -The riscv INTERNAL_SYSCALL macro might clobber the register -parameter if the argument itself might clobber any register (a function -call for instance). - -This patch fixes it by using temporary variables for the expressions -between the register assignments (as indicated by GCC documentation, -6.47.5.2 Specifying Registers for Local Variables). - -It is similar to the fix done for MIPS (bug 25523). - -Checked with riscv64-linux-gnu-rv64imafdc-lp64d build. ---- - sysdeps/unix/sysv/linux/riscv/sysdep.h | 84 +++++++++++++++++--------- - 1 file changed, 56 insertions(+), 28 deletions(-) - -diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h -index 201bf9a91b..2bd9b16f32 100644 ---- a/sysdeps/unix/sysv/linux/riscv/sysdep.h -+++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h -@@ -176,10 +176,11 @@ - # define internal_syscall1(number, err, arg0) \ - ({ \ - long int _sys_result; \ -+ long int _arg0 = (long int) (arg0); \ - \ - { \ - register long int __a7 asm ("a7") = number; \ -- register long int __a0 asm ("a0") = (long int) (arg0); \ -+ register long int __a0 asm ("a0") = _arg0; \ - __asm__ volatile ( \ - "scall\n\t" \ - : "+r" (__a0) \ -@@ -193,11 +194,13 @@ - # define internal_syscall2(number, err, arg0, arg1) \ - ({ \ - long int _sys_result; \ -+ long int _arg0 = (long int) (arg0); \ -+ long int _arg1 = (long int) (arg1); \ - \ - { \ - register long int __a7 asm ("a7") = number; \ -- register long int __a0 asm ("a0") = (long int) (arg0); \ -- register long int __a1 asm ("a1") = (long int) (arg1); \ -+ register long int __a0 asm ("a0") = _arg0; \ -+ register long int __a1 asm ("a1") = _arg1; \ - __asm__ volatile ( \ - "scall\n\t" \ - : "+r" (__a0) \ -@@ -211,12 +214,15 @@ - # define internal_syscall3(number, err, arg0, arg1, arg2) \ - ({ \ - long int _sys_result; \ -+ long int _arg0 = (long int) (arg0); \ -+ long int _arg1 = (long int) (arg1); \ -+ long int _arg2 = (long int) (arg2); \ - \ - { \ - register long int __a7 asm ("a7") = number; \ -- register long int __a0 asm ("a0") = (long int) (arg0); \ -- register long int __a1 asm ("a1") = (long int) (arg1); \ -- register long int __a2 asm ("a2") = (long int) (arg2); \ -+ register long int __a0 asm ("a0") = _arg0; \ -+ register long int __a1 asm ("a1") = _arg1; \ -+ register long int __a2 asm ("a2") = _arg2; \ - __asm__ volatile ( \ - "scall\n\t" \ - : "+r" (__a0) \ -@@ -230,13 +236,17 @@ - # define internal_syscall4(number, err, arg0, arg1, arg2, arg3) \ - ({ \ - long int _sys_result; \ -+ long int _arg0 = (long int) (arg0); \ -+ long int _arg1 = (long int) (arg1); \ -+ long int _arg2 = (long int) (arg2); \ -+ long int _arg3 = (long int) (arg3); \ - \ - { \ - register long int __a7 asm ("a7") = number; \ -- register long int __a0 asm ("a0") = (long int) (arg0); \ -- register long int __a1 asm ("a1") = (long int) (arg1); \ -- register long int __a2 asm ("a2") = (long int) (arg2); \ -- register long int __a3 asm ("a3") = (long int) (arg3); \ -+ register long int __a0 asm ("a0") = _arg0; \ -+ register long int __a1 asm ("a1") = _arg1; \ -+ register long int __a2 asm ("a2") = _arg2; \ -+ register long int __a3 asm ("a3") = _arg3; \ - __asm__ volatile ( \ - "scall\n\t" \ - : "+r" (__a0) \ -@@ -250,14 +260,19 @@ - # define internal_syscall5(number, err, arg0, arg1, arg2, arg3, arg4) \ - ({ \ - long int _sys_result; \ -+ long int _arg0 = (long int) (arg0); \ -+ long int _arg1 = (long int) (arg1); \ -+ long int _arg2 = (long int) (arg2); \ -+ long int _arg3 = (long int) (arg3); \ -+ long int _arg4 = (long int) (arg4); \ - \ - { \ - register long int __a7 asm ("a7") = number; \ -- register long int __a0 asm ("a0") = (long int) (arg0); \ -- register long int __a1 asm ("a1") = (long int) (arg1); \ -- register long int __a2 asm ("a2") = (long int) (arg2); \ -- register long int __a3 asm ("a3") = (long int) (arg3); \ -- register long int __a4 asm ("a4") = (long int) (arg4); \ -+ register long int __a0 asm ("a0") = _arg0; \ -+ register long int __a1 asm ("a1") = _arg1; \ -+ register long int __a2 asm ("a2") = _arg2; \ -+ register long int __a3 asm ("a3") = _arg3; \ -+ register long int __a4 asm ("a4") = _arg4; \ - __asm__ volatile ( \ - "scall\n\t" \ - : "+r" (__a0) \ -@@ -271,15 +286,21 @@ - # define internal_syscall6(number, err, arg0, arg1, arg2, arg3, arg4, arg5) \ - ({ \ - long int _sys_result; \ -+ long int _arg0 = (long int) (arg0); \ -+ long int _arg1 = (long int) (arg1); \ -+ long int _arg2 = (long int) (arg2); \ -+ long int _arg3 = (long int) (arg3); \ -+ long int _arg4 = (long int) (arg4); \ -+ long int _arg5 = (long int) (arg5); \ - \ - { \ - register long int __a7 asm ("a7") = number; \ -- register long int __a0 asm ("a0") = (long int) (arg0); \ -- register long int __a1 asm ("a1") = (long int) (arg1); \ -- register long int __a2 asm ("a2") = (long int) (arg2); \ -- register long int __a3 asm ("a3") = (long int) (arg3); \ -- register long int __a4 asm ("a4") = (long int) (arg4); \ -- register long int __a5 asm ("a5") = (long int) (arg5); \ -+ register long int __a0 asm ("a0") = _arg0; \ -+ register long int __a1 asm ("a1") = _arg1; \ -+ register long int __a2 asm ("a2") = _arg2; \ -+ register long int __a3 asm ("a3") = _arg3; \ -+ register long int __a4 asm ("a4") = _arg4; \ -+ register long int __a5 asm ("a5") = _arg5; \ - __asm__ volatile ( \ - "scall\n\t" \ - : "+r" (__a0) \ -@@ -294,16 +315,23 @@ - # define internal_syscall7(number, err, arg0, arg1, arg2, arg3, arg4, arg5, arg6) \ - ({ \ - long int _sys_result; \ -+ long int _arg0 = (long int) (arg0); \ -+ long int _arg1 = (long int) (arg1); \ -+ long int _arg2 = (long int) (arg2); \ -+ long int _arg3 = (long int) (arg3); \ -+ long int _arg4 = (long int) (arg4); \ -+ long int _arg5 = (long int) (arg5); \ -+ long int _arg6 = (long int) (arg6); \ - \ - { \ - register long int __a7 asm ("a7") = number; \ -- register long int __a0 asm ("a0") = (long int) (arg0); \ -- register long int __a1 asm ("a1") = (long int) (arg1); \ -- register long int __a2 asm ("a2") = (long int) (arg2); \ -- register long int __a3 asm ("a3") = (long int) (arg3); \ -- register long int __a4 asm ("a4") = (long int) (arg4); \ -- register long int __a5 asm ("a5") = (long int) (arg5); \ -- register long int __a6 asm ("a6") = (long int) (arg6); \ -+ register long int __a0 asm ("a0") = _arg0; \ -+ register long int __a1 asm ("a1") = _arg1; \ -+ register long int __a2 asm ("a2") = _arg2; \ -+ register long int __a3 asm ("a3") = _arg3; \ -+ register long int __a4 asm ("a4") = _arg4; \ -+ register long int __a5 asm ("a5") = _arg5; \ -+ register long int __a6 asm ("a6") = _arg6; \ - __asm__ volatile ( \ - "scall\n\t" \ - : "+r" (__a0) \ --- -2.25.1 - diff --git a/syslog-locking.patch b/syslog-locking.patch new file mode 100644 index 0000000..3db81c9 --- /dev/null +++ b/syslog-locking.patch @@ -0,0 +1,117 @@ +From 518db378cedc755f0ae311a1bc0487a4264f4bf0 Mon Sep 17 00:00:00 2001 +From: Andreas Schwab +Date: Tue, 23 Jun 2020 12:55:49 +0200 +Subject: [PATCH] Correct locking and cancellation cleanup in syslog functions + (bug 26100) + +Properly serialize the access to the global state shared between the +syslog functions, to avoid races in multithreaded processes. Protect a +local allocation in the __vsyslog_internal function from leaking during +cancellation. +--- + misc/syslog.c | 44 ++++++++++++++++++++++++++++---------------- + 1 file changed, 28 insertions(+), 16 deletions(-) + +Index: glibc-2.32/misc/syslog.c +=================================================================== +--- glibc-2.32.orig/misc/syslog.c ++++ glibc-2.32/misc/syslog.c +@@ -91,14 +91,20 @@ struct cleanup_arg + static void + cancel_handler (void *ptr) + { +-#ifndef NO_SIGPIPE + /* Restore the old signal handler. */ + struct cleanup_arg *clarg = (struct cleanup_arg *) ptr; + +- if (clarg != NULL && clarg->oldaction != NULL) +- __sigaction (SIGPIPE, clarg->oldaction, NULL); ++ if (clarg != NULL) ++ { ++#ifndef NO_SIGPIPE ++ if (clarg->oldaction != NULL) ++ __sigaction (SIGPIPE, clarg->oldaction, NULL); + #endif + ++ /* Free the memstream buffer, */ ++ free (clarg->buf); ++ } ++ + /* Free the lock. */ + __libc_lock_unlock (syslog_lock); + } +@@ -169,9 +175,17 @@ __vsyslog_internal(int pri, const char * + pri &= LOG_PRIMASK|LOG_FACMASK; + } + ++ /* Prepare for multiple users. We have to take care: most ++ syscalls we are using are cancellation points. */ ++ struct cleanup_arg clarg; ++ clarg.buf = NULL; ++ clarg.oldaction = NULL; ++ __libc_cleanup_push (cancel_handler, &clarg); ++ __libc_lock_lock (syslog_lock); ++ + /* Check priority against setlogmask values. */ + if ((LOG_MASK (LOG_PRI (pri)) & LogMask) == 0) +- return; ++ goto out; + + /* Set default facility if none specified. */ + if ((pri & LOG_FACMASK) == 0) +@@ -235,6 +249,9 @@ __vsyslog_internal(int pri, const char * + /* Close the memory stream; this will finalize the data + into a malloc'd buffer in BUF. */ + fclose (f); ++ ++ /* Tell the cancellation handler to free this buffer. */ ++ clarg.buf = buf; + } + + /* Output to stderr if requested. */ +@@ -252,22 +269,10 @@ __vsyslog_internal(int pri, const char * + v->iov_len = 1; + } + +- __libc_cleanup_push (free, buf == failbuf ? NULL : buf); +- + /* writev is a cancellation point. */ + (void)__writev(STDERR_FILENO, iov, v - iov + 1); +- +- __libc_cleanup_pop (0); + } + +- /* Prepare for multiple users. We have to take care: open and +- write are cancellation points. */ +- struct cleanup_arg clarg; +- clarg.buf = buf; +- clarg.oldaction = NULL; +- __libc_cleanup_push (cancel_handler, &clarg); +- __libc_lock_lock (syslog_lock); +- + #ifndef NO_SIGPIPE + /* Prepare for a broken connection. */ + memset (&action, 0, sizeof (action)); +@@ -320,6 +325,7 @@ __vsyslog_internal(int pri, const char * + __sigaction (SIGPIPE, &oldaction, (struct sigaction *) NULL); + #endif + ++ out: + /* End of critical section. */ + __libc_cleanup_pop (0); + __libc_lock_unlock (syslog_lock); +@@ -430,8 +436,14 @@ setlogmask (int pmask) + { + int omask; + ++ /* Protect against multiple users. */ ++ __libc_lock_lock (syslog_lock); ++ + omask = LogMask; + if (pmask != 0) + LogMask = pmask; ++ ++ __libc_lock_unlock (syslog_lock); ++ + return (omask); + }