No description
  • C 93.1%
  • Assembly 4.8%
  • C++ 1.3%
  • Awk 0.4%
  • Makefile 0.3%
  • Other 0.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Rich Felker f21a96538f fix toctou race in popen children's closing of other popen pipes
since commit e1a51185ce, popen obeys an
obscure historical requirement to implement a sort of pseudo-cloexec
behavior for other pipe streams obtained by popen. but since popen
uses posix_spawn (and thereby posix_spawn file actions) internally,
the time of check for other pipe streams is separated from the time of
closure.

this was intended to be addressed by popen holding the open file list
lock across posix_spawn, but pclose (via fclose) closes the file
descriptor before taking the open file list lock, only using the lock
for updating the linked list pointers. this is to avoid serializing
fclose operations across the entire process, since in general close
may be a blocking operation.

multiple solutions to this problem were considered, but the simplest
and least invasive is conditionally taking the open file list lock
early for popen streams -- that is, for FILE streams where the
pipe_pid member is nonzero. since the file descriptor refers to a
pipe, closing it is a simple, nonblocking operation, and the only cost
is the time spent entering and leaving kernelspace while the lock is
held.

since individual FILE locks cannot be held while taking the open file
list lock (this would violate lock order protocol and produce
deadlocks), the FILE lock must be released after fflush but before the
ofl lock is taken. there is no point in retaking the lock afterwards,
since the FILE pointer is no longer valid and any further use by the
application would be undefined. so, simply let fflush do the locking.

note that the early return path (F_PERM) is not reachable for popen
streams, only for stdin/stdout/stderr, which are always normal FILEs.
thus, it does not provide a code path to return with the ofl lock
still held.
2026-07-28 19:26:37 -04:00
arch riscv32: fix missing and extraneous items in syscall table 2026-06-18 11:33:50 -04:00
compat/time32 remove LFS64 symbol aliases; replace with dynamic linker remapping 2022-10-19 14:01:31 -04:00
crt mips: use preferred asm mnemomic jr for better assembler compatibility 2024-10-22 18:58:02 -04:00
dist add another example option to dist/config.mak 2012-04-24 16:49:11 -04:00
include sys/mman.h: add MADV_COLLAPSE from linux v6.1 2026-03-19 09:57:30 -04:00
ldso ldso: fix missing errno code when reporting relro mprotect failure 2026-05-05 20:34:14 -04:00
src fix toctou race in popen children's closing of other popen pipes 2026-07-28 19:26:37 -04:00
tools install.sh: avoid creating symlinks with restricted permissions 2024-02-03 19:57:30 -05:00
.gitignore remove obsolete gitignore rules 2016-07-06 00:21:25 -04:00
.mailmap update contributor name 2019-12-07 12:21:35 -05:00
configure configure: enable riscv32 port 2024-02-29 16:59:06 -05:00
COPYRIGHT update contributor name in authorship notices 2024-10-10 19:44:58 -04:00
dynamic.list fix regression in access to optopt object 2018-11-19 13:20:41 -05:00
INSTALL update INSTALL file archs list with riscv32, loongarch64 additions 2024-02-29 19:23:03 -05:00
Makefile fix missing make dependency for Scrt1.o due to typo 2024-08-09 23:03:52 -04:00
README update version reference in the README file 2014-06-25 14:16:53 -04:00
VERSION release 1.2.6 2026-03-20 11:40:00 -04:00
WHATSNEW release 1.2.6 2026-03-20 11:40:00 -04:00

    musl libc

musl, pronounced like the word "mussel", is an MIT-licensed
implementation of the standard C library targetting the Linux syscall
API, suitable for use in a wide range of deployment environments. musl
offers efficient static and dynamic linking support, lightweight code
and low runtime overhead, strong fail-safe guarantees under correct
usage, and correctness in the sense of standards conformance and
safety. musl is built on the principle that these goals are best
achieved through simple code that is easy to understand and maintain.

The 1.1 release series for musl features coverage for all interfaces
defined in ISO C99 and POSIX 2008 base, along with a number of
non-standardized interfaces for compatibility with Linux, BSD, and
glibc functionality.

For basic installation instructions, see the included INSTALL file.
Information on full musl-targeted compiler toolchains, system
bootstrapping, and Linux distributions built on musl can be found on
the project website:

    http://www.musl-libc.org/