1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:18:12 +00:00
serenity/Userland/Libraries/LibC
Ben Wiederhake fb003d71c2 LibC: Avoid unnecessary mprotect during program finalization
In particular, we track separately whether each AtExitEntry has already
been called, through a separate Bitmap. This has several side-effects:

- We now call malloc() during __cxa_finalize(). I believe this is fine,
  and at that point during program execution memory pressure should be
  low anyway.
- An attacker could prevent arbitrary entries from executing by writing
  to atexit_called_entries. However, this already was possible (by
  setting atexit_entry_count to zero), and this path is even more
  troublesome (the attacker needs to overwrite atexit_called_entries,
  and a region serving as *atexit_called_entries.m_data, and magically
  know exactly how many entries already exist.)
- This reduces the size of AtExitEntry from 16 to 12 (on i686). As such,
  we can reduce the initial memory allocation from two to one page,
  reducing the initial capacity from 512 to 341 entries (or 256 to 170,
  on x86_64). It seems that most programs only use 36-47 entries anyway.

For 'true', this shaves off about 69 syscalls, as measured by strace.
2021-11-11 09:20:35 +01:00
..
arch CMake: Let Meta/serenity.sh run aarch64 make it past cmake 2021-08-28 14:43:07 +01:00
arpa LibC: Make <netinet/in.h> more POSIX compliant 2021-08-22 10:29:06 +02:00
bits LibC: Implement tfind and tsearch 2021-10-15 21:50:19 -07:00
net Kernel+LibC: Share definitions for net/{if,if_arp,route}.h 2021-08-14 19:58:11 +02:00
netinet LibC: Correctly evaluate addr in IN6_IS_ADDR_LOOPBACK 2021-11-06 00:31:01 -07:00
sys LibC: Avoid unnecessary mprotect during program initialization 2021-11-11 09:20:35 +01:00
alloca.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
assert.cpp LibC: Don't format strings when asserting with an unstable heap 2021-09-18 01:35:11 +00:00
assert.h LibC: Use C-style void cast in assert() 2021-07-13 19:02:20 +01:00
byteswap.h Everywhere: Use "the SerenityOS developers." in copyright headers 2021-04-29 00:59:26 +02:00
CMakeLists.txt LibC: Fix huge libc.a file size due to the use of llvm-ar -q 2021-11-08 01:39:07 +01:00
crt0.cpp LibC: Avoid unnecessary mprotect during program initialization 2021-11-11 09:20:35 +01:00
crt0_shared.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
ctype.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
ctype.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
cxxabi.cpp LibC: Avoid unnecessary mprotect during program finalization 2021-11-11 09:20:35 +01:00
dirent.cpp LibC: Add function fdopendir 2021-08-14 22:32:00 +01:00
dirent.h LibC: Add function fdopendir 2021-08-14 22:32:00 +01:00
dlfcn.cpp LibC+LibELF: Implement dladdr() 2021-06-06 22:16:11 +02:00
elf.h LibC+LibELF: Add definitions for extra dtags 2021-09-26 12:45:55 +02:00
endian.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
errno.h LibC: Don't clear errno on success 2021-05-30 19:37:32 +02:00
errno_numbers.h LibC: Add ELAST errno macro 2021-10-17 17:09:58 +01:00
fcntl.cpp Kernel+LibC: Pack SC_inode_watcher_add_watch_params struct better 2021-09-16 17:17:13 +02:00
fcntl.h Kernel+LibC: Share definitions in fcntl.h and sys/types.h 2021-08-14 19:58:11 +02:00
fd_set.h LibC: Modify fd_set to be compatible with X/OPEN 2021-08-22 10:29:06 +02:00
fenv.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
fenv.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
float.h LibC: Don't include fenv.h from float.h 2021-07-08 10:11:00 +02:00
fnmatch.cpp Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00
fnmatch.h Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00
getopt.cpp Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
getopt.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
grp.cpp LibC: Add putgrent 2021-07-15 11:16:58 +02:00
grp.h LibC: Fix grp.h includes 2021-07-17 13:00:33 +02:00
iconv.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
inttypes.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
inttypes.h LibC: Don't include AK headers in system headers 2021-07-15 23:51:59 +02:00
ioctl.cpp LibC: Don't truncate arguments for ioctl() on x86_64 2021-07-22 04:18:39 +04:30
langinfo.cpp Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00
langinfo.h Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00
libcinit.cpp LibC+DynamicLoader: Store the auxiliary vector address at startup 2021-09-20 18:32:09 +02:00
libgen.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
libgen.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
limits.h LibC: Define ULLONG_MAX 2021-10-17 23:43:43 +01:00
link.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
link.h Userland: Prefer using ARCH() over __LP64__ 2021-07-13 23:19:33 +02:00
locale.cpp LibC: Let setlocale() pretend that setting the locale succeeded 2021-06-05 10:56:37 +02:00
locale.h LibC: Define locale categories (LC_*) as macros 2021-10-23 23:31:43 -07:00
malloc.cpp LibC: Don't format strings when asserting with an unstable heap 2021-09-18 01:35:11 +00:00
mallocdefs.h AK+Everywhere: Reduce the number of template parameters of IntrusiveList 2021-09-10 18:05:46 +03:00
memory.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
mntent.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
mntent.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
net.cpp LibC: Add definitions/stubs for IPv6 functionality 2021-05-09 21:16:11 +02:00
netdb.cpp AK: Make ByteBuffer::try_* functions return ErrorOr<void> 2021-11-10 21:58:58 +01:00
netdb.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
nl_types.h Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00
paths.h Everywhere: Use "the SerenityOS developers." in copyright headers 2021-04-29 00:59:26 +02:00
poll.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
poll.h Kernel+LibC: Share definitions for poll.h 2021-08-14 19:58:11 +02:00
priority.cpp LibC: Add getpriority() and setpriority() stubs 2021-09-23 18:51:21 +02:00
pthread_forward.cpp LibC+AK: Remove our custom macros from <assert.h> 2021-06-08 17:29:57 +02:00
pthread_integration.cpp LibC: Only set owner on recursive mutexes 2021-07-06 17:25:34 +02:00
pthread_tls.cpp Toolchain+Userland: Enable TLS for x86_64 2021-07-04 01:07:28 +02:00
pty.cpp LibC: Remove debug spam from openpty() 2021-10-26 08:47:06 +02:00
pty.h LibC: Remove 'int* aslave' parameter from forkpty() 2021-05-06 13:52:46 +01:00
pwd.cpp LibC: Do not include errno.h inside unistd.h 2021-05-14 22:24:02 +02:00
pwd.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
qsort.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
regex.cpp LibC: Add stub forwarders to LibRegex C API 2021-08-12 18:56:30 +02:00
regex.h LibRegex+LibUnicode: Begin implementing Unicode property escapes 2021-07-30 21:26:31 +01:00
resolv.cpp Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00
resolv.h Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00
scanf.cpp LibC: Fix %n conversion specifier in scanf() format 2021-10-24 22:43:27 -07:00
sched.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
sched.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
search.cpp LibC: Stub out tdelete 2021-10-15 21:50:19 -07:00
search.h LibC: Add missing header in search.h 2021-10-20 09:20:18 +01:00
serenity.cpp Kernel+Userland: Remove loadable kernel moduless 2021-09-11 19:05:00 +02:00
serenity.h Kernel+Userland: Remove loadable kernel moduless 2021-09-11 19:05:00 +02:00
setjmp.h LibC: Run clang-format on setjmp.h 2021-08-31 01:37:30 +02:00
shadow.cpp LibC: Allow empty spwd members when writing shadow entries via putspent 2021-05-30 17:42:03 +01:00
shadow.h LibCore: Fix building the library on macOS 2021-05-01 15:56:16 +02:00
signal.cpp LibC: Support getsignalbyname() with full signal name 2021-08-22 15:23:25 +02:00
signal.h LibC: Expose sig_sysname array 2021-08-18 10:33:48 +02:00
signal_numbers.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
spawn.cpp LibC: Do not include errno.h inside unistd.h 2021-05-14 22:24:02 +02:00
spawn.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
ssp.cpp Everywhere: Make some symbols __attribute__((used)) for LTO 2021-10-17 17:09:58 +01:00
stat.cpp Kernel+LibC: Pack SC_stat_params struct tighter 2021-09-16 17:17:13 +02:00
stdarg.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
stddef.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
stdint.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
stdio.cpp LibC: Make remove() propagate non-EISDIR unlink() errors 2021-09-09 21:49:49 +02:00
stdio.h LibC: Add definition for FOPEN_MAX 2021-10-23 15:06:33 +02:00
stdio_ext.h Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00
stdlib.cpp LibC: Add labs() 2021-10-31 12:00:57 +01:00
stdlib.h LibC+LibELF: Move getauxval and AT_* flags to sys/auxv.h 2021-10-28 11:24:36 +02:00
string.cpp LibC: Upgrade memmove() to memcpy() when possible 2021-09-13 19:11:33 +02:00
string.h LibC: Implement strerror_r() 2021-05-25 17:36:02 +02:00
strings.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
strings.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
stubs.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
sysexits.h LibC: Use EX_IOERR instead of EX_IOER 2021-06-10 20:21:08 +01:00
syslog.cpp LibC: Convert StringBuilder::appendf() => AK::Format 2021-05-07 21:12:09 +02:00
syslog.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
termcap.cpp LibC: Mark termcap symbols as weak 2021-10-15 14:47:41 -07:00
termcap.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
termios.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
termios.h Kernel+LibC: Share definitions for termios.h 2021-08-14 19:58:11 +02:00
time.cpp LibC: Don't delete null check in gettimeofday 2021-08-12 21:10:44 +02:00
time.h Kernel+LibC: Share definitions for time.h and sys/stat.h 2021-08-14 19:58:11 +02:00
times.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
ulimit.cpp LibC: Add stubs for getrlimit()/setrlimit() 2021-05-08 19:14:21 +02:00
ulimit.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
unistd.cpp LibC: Use the new pread syscall to implement pread 2021-10-13 16:10:50 +02:00
unistd.h LibC: Add chroot() stub 2021-09-23 18:51:21 +02:00
utime.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
utime.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
utmp.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
utsname.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
wchar.cpp LibC: Implement mbsnrtowcs 2021-10-21 23:57:32 -07:00
wchar.h LibC: Primitively implement wcsxfrm 2021-10-17 17:09:58 +01:00
wctype.cpp Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00
wctype.h Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00