Go to file
Adhemerval Zanella d40ac01cbb stdlib: Make abort/_Exit AS-safe (BZ 26275)
The recursive lock used on abort does not synchronize with a new process
creation (either by fork-like interfaces or posix_spawn ones), nor it
is reinitialized after fork().

Also, the SIGABRT unblock before raise() shows another race condition,
where a fork or posix_spawn() call by another thread, just after the
recursive lock release and before the SIGABRT signal, might create
programs with a non-expected signal mask.  With the default option
(without POSIX_SPAWN_SETSIGDEF), the process can see SIG_DFL for
SIGABRT, where it should be SIG_IGN.

To fix the AS-safe, raise() does not change the process signal mask,
and an AS-safe lock is used if a SIGABRT is installed or the process
is blocked or ignored.  With the signal mask change removal,
there is no need to use a recursive loc.  The lock is also taken on
both _Fork() and posix_spawn(), to avoid the spawn process to see the
abort handler as SIG_DFL.

A read-write lock is used to avoid serialize _Fork and posix_spawn
execution.  Both sigaction (SIGABRT) and abort() requires to lock
as writer (since both change the disposition).

The fallback is also simplified: there is no need to use a loop of
ABORT_INSTRUCTION after _exit() (if the syscall does not terminate the
process, the system is broken).

The proposed fix changes how setjmp works on a SIGABRT handler, where
glibc does not save the signal mask.  So usage like the below will now
always abort.

  static volatile int chk_fail_ok;
  static jmp_buf chk_fail_buf;

  static void
  handler (int sig)
  {
    if (chk_fail_ok)
      {
        chk_fail_ok = 0;
        longjmp (chk_fail_buf, 1);
      }
    else
      _exit (127);
  }
  [...]
  signal (SIGABRT, handler);
  [....]
  chk_fail_ok = 1;
  if (! setjmp (chk_fail_buf))
    {
      // Something that can calls abort, like a failed fortify function.
      chk_fail_ok = 0;
      printf ("FAIL\n");
    }

Such cases will need to use sigsetjmp instead.

The _dl_start_profile calls sigaction through _profil, and to avoid
pulling abort() on loader the call is replaced with __libc_sigaction.

Checked on x86_64-linux-gnu and aarch64-linux-gnu.

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-10-08 14:40:12 -03:00
advisories
argp
assert assert: Mark __assert_fail as cold 2024-07-26 20:41:00 +08:00
benchtests benchtests: Add random memset benchmark 2024-08-07 14:58:46 +01:00
bits AArch64: Add vector logp1 alias for log1p 2024-09-19 17:53:34 +01:00
catgets Fix conditionals on mtrace-based tests (bug 31892) 2024-07-01 17:20:30 +02:00
ChangeLog.old Add ChangeLog file 2024-07-21 18:33:37 +02:00
conform Disable _TIME_BITS if the compiler defaults to it 2024-10-01 08:44:41 -03:00
csu
ctype
debug stdlib: Make abort/_Exit AS-safe (BZ 26275) 2024-10-08 14:40:12 -03:00
dirent Linux: readdir64_r should not skip d_ino == 0 entries (bug 32126) 2024-09-21 19:32:34 +02:00
dlfcn
elf elf: Move __rtld_malloc_init_stubs call into _dl_start_final 2024-09-24 13:23:10 +02:00
gmon
gnulib
hesiod
htl hurd: Fix missing pthread_ compat symbol in libc 2024-08-01 23:58:51 +02:00
hurd x86_64 hurd: ensure we have a large enough buffer to receive exception_raise requests. 2024-07-30 16:59:12 +02:00
iconv iconv: Use $(run-program-prefix) for running iconv (bug 32197) 2024-09-24 12:35:40 +02:00
iconvdata iconv: Preserve iconv -c error exit on invalid inputs (bug 32046) 2024-09-20 13:51:09 +02:00
include stdlib: Make abort/_Exit AS-safe (BZ 26275) 2024-10-08 14:40:12 -03:00
inet inet: Avoid label at end of compound statement in tst-if_nameindex 2024-08-26 16:45:31 +02:00
intl
io Do not use -Wp to disable fortify (BZ 31928) 2024-10-01 08:44:40 -03:00
libio libio: Set _vtable_offset before calling _IO_link_in [BZ #32148] 2024-10-01 07:31:25 +08:00
locale support: Use macros for *stat wrappers 2024-08-16 16:05:20 +02:00
localedata Fix whitespace related license issues. 2024-10-07 18:08:16 -04:00
login login: Re-flow and sort multiline Makefile definitions 2024-08-07 11:02:03 -03:00
mach
malloc malloc: Link threading tests with $(shared-thread-library) 2024-08-20 16:16:25 +02:00
manual stdlib: Make abort/_Exit AS-safe (BZ 26275) 2024-10-08 14:40:12 -03:00
math AArch64: Add vector logp1 alias for log1p 2024-09-19 17:53:34 +01:00
mathvec
misc misc: Link tst-mkstemp-fuse-parallel with $(shared-thread-library) 2024-09-24 13:05:52 +02:00
nis
nptl stdlib: Make abort/_Exit AS-safe (BZ 26275) 2024-10-08 14:40:12 -03:00
nptl_db
nscd
nss nss: Fix incorrect switch fall-through in tst-nss-gai-actions 2024-08-07 15:00:25 +02:00
po po/*: regenerate (only line number changes) 2024-07-21 17:50:35 +02:00
posix stdlib: Make abort/_Exit AS-safe (BZ 26275) 2024-10-08 14:40:12 -03:00
resolv resolv: Fix tst-resolv-short-response for older GCC (bug 32042) 2024-08-01 21:07:48 +02:00
resource
rt debug: Fix clang mq_open fortify wrapper (BZ 31917) 2024-06-27 13:32:48 -03:00
scripts scripts: Remove arceb-linux-gnu from build-many-glibcs.py 2024-09-25 11:25:22 +02:00
setjmp
signal stdlib: Make abort/_Exit AS-safe (BZ 26275) 2024-10-08 14:40:12 -03:00
socket Fix name space violation in fortify wrappers (bug 32052) 2024-08-05 16:49:58 +02:00
soft-fp
stdio-common stdio-common/Makefile: Fix FAIL: lint-makefiles 2024-10-08 08:46:45 +08:00
stdlib stdlib: Make abort/_Exit AS-safe (BZ 26275) 2024-10-08 14:40:12 -03:00
string string: strerror, strsignal cannot use buffer after dlmopen (bug 32026) 2024-08-19 15:48:03 +02:00
sunrpc
support support: Add valgrind instructions to <support/fuse.h> 2024-09-21 19:29:13 +02:00
sysdeps stdlib: Make abort/_Exit AS-safe (BZ 26275) 2024-10-08 14:40:12 -03:00
sysvipc
termios
time time/Makefile: Split and sort tests 2024-07-12 17:33:28 +02:00
timezone timezone: sync to TZDB 2024b 2024-09-05 20:57:17 +00:00
wcsmbs Do not use -Wp to disable fortify (BZ 31928) 2024-10-01 08:44:40 -03:00
wctype
.clang-format
.gitattributes
.gitignore
abi-tags
aclocal.m4 Convert to autoconf 2.72 (vanilla release, no distribution patches) 2024-06-17 21:15:28 +02:00
config.h.in arc: Remove HAVE_ARC_BE macro and disable big-endian port 2024-09-25 11:25:22 +02:00
config.make.in manual: add syscalls 2024-07-09 11:54:29 +02:00
configure Disable _TIME_BITS if the compiler defaults to it 2024-10-01 08:44:41 -03:00
configure.ac Disable _TIME_BITS if the compiler defaults to it 2024-10-01 08:44:41 -03:00
CONTRIBUTED-BY
COPYING
COPYING.LIB
extra-lib.mk
gen-locales.mk
INSTALL install.texi: bump "latest verified" versions 2024-07-21 00:27:35 +02:00
libc-abis
libof-iterator.mk
LICENSES
MAINTAINERS
Makeconfig Disable _TIME_BITS if the compiler defaults to it 2024-10-01 08:44:41 -03:00
Makefile
Makefile.help
Makefile.in
Makerules
NEWS stdlib: Make abort/_Exit AS-safe (BZ 26275) 2024-10-08 14:40:12 -03:00
o-iterator.mk
README
Rules Implement run-built-tests=no for make xcheck, always build xtests 2024-09-21 00:29:55 +02:00
SECURITY.md
SHARED-FILES Update to Unicode 16.0.0 [BZ #32168] 2024-09-27 14:43:38 +02:00
shlib-versions
test-skeleton.c
version.h Increase version number to 2.40.9000 2024-07-21 18:49:35 +02:00

This directory contains the sources of the GNU C Library.
See the file "version.h" for what release version you have.

The GNU C Library is the standard system C library for all GNU systems,
and is an important part of what makes up a GNU system.  It provides the
system API for all programs written in C and C-compatible languages such
as C++ and Objective C; the runtime facilities of other programming
languages use the C library to access the underlying operating system.

In GNU/Linux systems, the C library works with the Linux kernel to
implement the operating system behavior seen by user applications.
In GNU/Hurd systems, it works with a microkernel and Hurd servers.

The GNU C Library implements much of the POSIX.1 functionality in the
GNU/Hurd system, using configurations i[4567]86-*-gnu and x86_64-gnu.

When working with Linux kernels, this version of the GNU C Library
requires Linux kernel version 3.2 or later.

Also note that the shared version of the libgcc_s library must be
installed for the pthread library to work correctly.

The GNU C Library supports these configurations for using Linux kernels:

	aarch64*-*-linux-gnu
	alpha*-*-linux-gnu
	arc*-*-linux-gnu
	arm-*-linux-gnueabi
	csky-*-linux-gnuabiv2
	hppa-*-linux-gnu
	i[4567]86-*-linux-gnu
	x86_64-*-linux-gnu	Can build either x86_64 or x32
	loongarch64-*-linux-gnu Hardware floating point, LE only.
	m68k-*-linux-gnu
	microblaze*-*-linux-gnu
	mips-*-linux-gnu
	mips64-*-linux-gnu
	or1k-*-linux-gnu
	powerpc-*-linux-gnu	Hardware or software floating point, BE only.
	powerpc64*-*-linux-gnu	Big-endian and little-endian.
	s390-*-linux-gnu
	s390x-*-linux-gnu
	riscv32-*-linux-gnu
	riscv64-*-linux-gnu
	sh[34]-*-linux-gnu
	sparc*-*-linux-gnu
	sparc64*-*-linux-gnu

If you are interested in doing a port, please contact the glibc
maintainers; see https://www.gnu.org/software/libc/ for more
information.

See the file INSTALL to find out how to configure, build, and install
the GNU C Library.  You might also consider reading the WWW pages for
the C library at https://www.gnu.org/software/libc/.

The GNU C Library is (almost) completely documented by the Texinfo manual
found in the `manual/' subdirectory.  The manual is still being updated
and contains some known errors and omissions; we regret that we do not
have the resources to work on the manual as much as we would like.  For
corrections to the manual, please file a bug in the `manual' component,
following the bug-reporting instructions below.  Please be sure to check
the manual in the current development sources to see if your problem has
already been corrected.

Please see https://www.gnu.org/software/libc/bugs.html for bug reporting
information.  We are now using the Bugzilla system to track all bug reports.
This web page gives detailed information on how to report bugs properly.

The GNU C Library is free software.  See the file COPYING.LIB for copying
conditions, and LICENSES for notices about a few contributions that require
these additional notices to be distributed.  License copyright years may be
listed using range notation, e.g., 1996-2015, indicating that every year in
the range, inclusive, is a copyrightable year that would otherwise be listed
individually.