forked from pool/glibc
Andreas Schwab
aa7f55e9fc
- Update to glibc 2.33 * The dynamic linker accepts the --list-tunables argument which prints all the supported tunables. * The dynamic linker accepts the --argv0 argument and provides opportunity to change argv[0] string. * The dynamic linker loads optimized implementations of shared objects from subdirectories under the glibc-hwcaps directory on the library search path if the system's capabilities meet the requirements for that subdirectory. * The new --help option of the dynamic linker provides usage and information and library search path diagnostics. * The mallinfo2 function is added to report statistics as per mallinfo, but with larger field widths to accurately report values that are larger than fit in an integer. * Add <sys/platform/x86.h> to provide query macros for x86 CPU features. * A new fortification level _FORTIFY_SOURCE=3 is available. * The mallinfo function is marked deprecated. * When dlopen is used in statically linked programs, alternative library implementations from HWCAP subdirectories are no longer loaded. * The deprecated <sys/vtimes.h> header and the function vtimes have been removed. * On s390(x), the type float_t is now derived from the macro __FLT_EVAL_METHOD__ that is defined by the compiler, instead of being hardcoded to double. * A future version of glibc will stop loading shared objects from the "tls" subdirectories on the library search path, the subdirectory that corresponds to the AT_PLATFORM system name, and also stop employing the legacy AT_HWCAP search mechanism. * CVE-2021-3326: An assertion failure during conversion from the ISO-20220-JP-3 character set using the iconv function has been fixed. OBS-URL: https://build.opensuse.org/request/show/868599 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=577
203 lines
5.7 KiB
Diff
203 lines
5.7 KiB
Diff
Always do locking when accessing streams (bug 15142, bug 14697)
|
|
|
|
Now that abort no longer calls fflush there is no reason to avoid locking
|
|
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.32/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)
|
|
|
|
int
|
|
-_IO_flush_all_lockp (int do_lock)
|
|
+_IO_flush_all (void)
|
|
{
|
|
int result = 0;
|
|
FILE *fp;
|
|
@@ -695,8 +695,7 @@ _IO_flush_all_lockp (int do_lock)
|
|
for (fp = (FILE *) _IO_list_all; fp != NULL; fp = fp->_chain)
|
|
{
|
|
run_fp = fp;
|
|
- if (do_lock)
|
|
- _IO_flockfile (fp);
|
|
+ _IO_flockfile (fp);
|
|
|
|
if (((fp->_mode <= 0 && fp->_IO_write_ptr > fp->_IO_write_base)
|
|
|| (_IO_vtable_offset (fp) == 0
|
|
@@ -706,8 +705,7 @@ _IO_flush_all_lockp (int do_lock)
|
|
&& _IO_OVERFLOW (fp, EOF) == EOF)
|
|
result = EOF;
|
|
|
|
- if (do_lock)
|
|
- _IO_funlockfile (fp);
|
|
+ _IO_funlockfile (fp);
|
|
run_fp = NULL;
|
|
}
|
|
|
|
@@ -718,14 +716,6 @@ _IO_flush_all_lockp (int do_lock)
|
|
|
|
return result;
|
|
}
|
|
-
|
|
-
|
|
-int
|
|
-_IO_flush_all (void)
|
|
-{
|
|
- /* We want locking. */
|
|
- return _IO_flush_all_lockp (1);
|
|
-}
|
|
libc_hidden_def (_IO_flush_all)
|
|
|
|
void
|
|
@@ -791,6 +781,9 @@ _IO_unbuffer_all (void)
|
|
{
|
|
int legacy = 0;
|
|
|
|
+ run_fp = fp;
|
|
+ _IO_flockfile (fp);
|
|
+
|
|
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
|
|
if (__glibc_unlikely (_IO_vtable_offset (fp) != 0))
|
|
legacy = 1;
|
|
@@ -800,18 +793,6 @@ _IO_unbuffer_all (void)
|
|
/* Iff stream is un-orientated, it wasn't used. */
|
|
&& (legacy || fp->_mode != 0))
|
|
{
|
|
-#ifdef _IO_MTSAFE_IO
|
|
- int cnt;
|
|
-#define MAXTRIES 2
|
|
- for (cnt = 0; cnt < MAXTRIES; ++cnt)
|
|
- if (fp->_lock == NULL || _IO_lock_trylock (*fp->_lock) == 0)
|
|
- break;
|
|
- else
|
|
- /* Give the other thread time to finish up its use of the
|
|
- stream. */
|
|
- __sched_yield ();
|
|
-#endif
|
|
-
|
|
if (! legacy && ! dealloc_buffers && !(fp->_flags & _IO_USER_BUF))
|
|
{
|
|
fp->_flags |= _IO_USER_BUF;
|
|
@@ -825,17 +806,15 @@ _IO_unbuffer_all (void)
|
|
|
|
if (! legacy && fp->_mode > 0)
|
|
_IO_wsetb (fp, NULL, NULL, 0);
|
|
-
|
|
-#ifdef _IO_MTSAFE_IO
|
|
- if (cnt < MAXTRIES && fp->_lock != NULL)
|
|
- _IO_lock_unlock (*fp->_lock);
|
|
-#endif
|
|
}
|
|
|
|
/* Make sure that never again the wide char functions can be
|
|
used. */
|
|
if (! legacy)
|
|
fp->_mode = -1;
|
|
+
|
|
+ _IO_funlockfile (fp);
|
|
+ run_fp = NULL;
|
|
}
|
|
|
|
#ifdef _IO_MTSAFE_IO
|
|
@@ -861,9 +840,7 @@ libc_freeres_fn (buffer_free)
|
|
int
|
|
_IO_cleanup (void)
|
|
{
|
|
- /* We do *not* want locking. Some threads might use streams but
|
|
- that is their problem, we flush them underneath them. */
|
|
- int result = _IO_flush_all_lockp (0);
|
|
+ int result = _IO_flush_all ();
|
|
|
|
/* We currently don't have a reliable mechanism for making sure that
|
|
C++ static destructors are executed in the correct order.
|
|
Index: glibc-2.32/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);
|
|
libc_hidden_proto (_IO_wdo_write)
|
|
-extern int _IO_flush_all_lockp (int);
|
|
extern int _IO_flush_all (void);
|
|
libc_hidden_proto (_IO_flush_all)
|
|
extern int _IO_cleanup (void);
|
|
Index: glibc-2.32/sysdeps/pthread/Makefile
|
|
===================================================================
|
|
--- 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.32.orig/sysdeps/pthread/tst-stdio1.c
|
|
+++ /dev/null
|
|
@@ -1,56 +0,0 @@
|
|
-/* Copyright (C) 2002-2021 Free Software Foundation, Inc.
|
|
- This file is part of the GNU C Library.
|
|
- Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
|
-
|
|
- 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
|
|
- <https://www.gnu.org/licenses/>. */
|
|
-
|
|
-#include <pthread.h>
|
|
-#include <signal.h>
|
|
-#include <stdio.h>
|
|
-#include <unistd.h>
|
|
-
|
|
-static int do_test (void);
|
|
-
|
|
-#define TEST_FUNCTION do_test ()
|
|
-#include "../test-skeleton.c"
|
|
-
|
|
-static void *tf (void *a)
|
|
-{
|
|
- flockfile (stdout);
|
|
- /* This call should never return. */
|
|
- return a;
|
|
-}
|
|
-
|
|
-
|
|
-int
|
|
-do_test (void)
|
|
-{
|
|
- pthread_t th;
|
|
-
|
|
- flockfile (stdout);
|
|
-
|
|
- if (pthread_create (&th, NULL, tf, NULL) != 0)
|
|
- {
|
|
- write_message ("create failed\n");
|
|
- _exit (1);
|
|
- }
|
|
-
|
|
- delayed_exit (1);
|
|
- xpthread_join (th);
|
|
-
|
|
- puts ("join returned");
|
|
-
|
|
- return 1;
|
|
-}
|