summaryrefslogtreecommitdiff
path: root/lib/libc
AgeCommit message (Collapse)Author
2023-06-26Fix Ed Schouten's nameTheo Buehler
from weerd
2023-06-26document handling of NULL envp as an extension;Jason McIntyre
from lucas de sena ok espie
2023-06-23Revert previous, not all platforms allow compilingOtto Moerbeek
__builtin_return_address(a) with a != 0.
2023-06-22Allow to ask for deeper callers for leak reports using malloc options.Otto Moerbeek
ok deraadt@
2023-06-21Use recallocarray() consistently. recallocarray() was introduced to simplifyClaudio Jeker
exactly this use case where the new memory needs to be zeroed during resize. Since recallocarray() takes care of all this there is no need to bzero() memory anymore. OK tb@ millert@
2023-06-07Add portable version and m88k-specific version lb() function, becauseKenji Aoyama
unfortunately gcc3 does not have __builtin_clz(). ok miod@ otto@
2023-06-04More thorough write-afetr-free checks.Otto Moerbeek
On free, chunks (the pieces of a pages used for smaller allocations) are junked and then validated after they leave the delayed free list. So after free, a chunk always contains junk bytes. This means that if we start with the right contents for a new page of chunks, we can *validate* instead of *write* junk bytes when (re)-using a chunk. With this, we can detect write-after-free when a chunk is recycled, not justy when a chunk is in the delayed free list. We do a little bit more work on initial allocation of a page of chunks and when re-using (as we validate now even on junk level 1). Also: some extra consistency checks for recallocaray(3) and fixes in error messages to make them more consistent, with man page bits. Plus regress additions.
2023-06-02pledge(2): stdio: permit restricted profil(2) for moncontrol(3)Scott Soule Cheloha
Currently, pledged '-pg' binaries get killed in _mcleanup() when they try to disable profil(2) via moncontrol(3). Disabling profil(2) is harmless. Add profil(2) to the "stdio" pledge(2) promise and permit profil(2) calls when the scale argument is zero. Enabling profil(2) remains forbidden in pledged processes. This gets us one step closer to making '-pg' binaries compatible with pledge(2). The next step is to decide how to exfiltrate the profiling data from the process during _mcleanup(). Prompted by semarie@. Cleaned up by deraadt@. With input from deraadt@, espie@, and semarie@. "Looks good" deraadt@ pledge(2) pieces ok semarie@
2023-05-27Remove malloc interposition, a workaround that was once needed for emacsOtto Moerbeek
ok guenther@
2023-05-19Since waitid(2) shares code with wait4(2) and doesn't expose anyPhilip Guenther
non-trivial new information or code-paths over wait4(), include it in pledge("stdio") discussed with deraadt@
2023-05-18memmove() entry point is declared with NENTRY() and isn't consecutivePhilip Guenther
with an ENTRY(), so it needs its own endbr64 for IBT ok deraadt@
2023-05-18Add PROTO_NORMAL() declarations for the remaining syscalls, to avoidPhilip Guenther
future, inadvertant PLT entries. Move the __getcwd and __realpath declarations to hidden/{stdlib,unistd}.h to consolidate and remove duplication. ok tb@ otto@ deraadt@
2023-05-18Add PROTO_NORMAL() declarations for utrace (and ktrace) syscallsPhilip Guenther
so that the internal call can't be interposed over by the app. ok tb@ otto@ deraadt@
2023-05-18Make two corrections to the vfork(2) stub:Philip Guenther
* with IBT, it can't return via an indirect jump as that would require the *caller* to have an endbr64 * to support a potential vmspace-sharing implementation, keep the retguard value in an arg register across the underlying syscall ok kettenis@ deraadt@
2023-05-16add net.inet.tcp.tso;Jason McIntyre
ok jan bluhm
2023-05-13default path includes /usr/local/sbinKlemens Nanni
Improve markup while here. Feedback tb jmc OK millert
2023-05-11Retguard addition in commit 72pYktDvmJhq7OyF was based on the understandingPhilip Guenther
that the removal of the off_t padding, amd64 syscalls no longer passed a 7th or later argument. We overlooked that syscall(2) bumps the arg count by one, so six argument calls like SYS_sysctl still pass an argument on the stack. So, repush the 7th argument so it's at the expected stack offset after the retguard register is pushed. problem reported and ok bluhm@
2023-05-10As mmap(2) is no longer a LOCK syscall, do away with the extraOtto Moerbeek
unlock-lock dance it serves no real purpose any more. Confirmed by a small performance increase in tests. ok @tb
2023-04-26Declare sendsyslog to match its man pageGreg Steuck
This simplifies syzkaller revival after the removal of __syscall. OK bluhm, millert, deraadt
2023-04-21remove duplicate includeJonathan Gray
ok otto@
2023-04-19remove duplicate includesJonathan Gray
ok tb@
2023-04-17remove bad Pp;Jason McIntyre
(sorry, otto, for not spotting in the updated diff)
2023-04-16Dump (leak) info using utrace(2) and compile the code always inOtto Moerbeek
except for bootblocks. This way we have built-in leak detecction always (if enable by malloc flags). See man pages for details.
2023-04-05Introduce variation in location of junked bytes; ok tb@Otto Moerbeek
2023-04-01Check all chunks in the delayed free list for write-after-free.Otto Moerbeek
Should catch more of them and closer (in time) to the WAF. ok tb@
2023-03-31Since all arm64 assembly code in libc uses the ENTRY* macros fromMark Kettenis
<machine/asm.h> they are already get the necessary "bti c" instructions. Passi the -mmark-bti-property option to mark the corresponding object files as having BTI support. ok deraadt@
2023-03-25Last arg is also a pointer, so pass NULL instead of 0; ok deraadt@Otto Moerbeek
2023-03-25Change malloc chunk sizes to be fine grained.Otto Moerbeek
The basic idea is simple: one of the reasons the recent sshd bug is potentially exploitable is that a (erroneously) freed malloc chunk gets re-used in a different role. malloc has power of two chunk sizes and so one page of chunks holds many different types of allocations. Userland malloc has no knowledge of types, we only know about sizes. So I changed that to use finer-grained chunk sizes. This has some performance impact as we need to allocate chunk pages in more cases. Gain it back by allocation chunk_info pages in a bundle, and use less buckets is !malloc option S. The chunk sizes used are 16, 32, 48, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 640, 768, 896, 1024, 1280, 1536, 1792, 2048 (and a few more for sparc64 with its 8k sized pages and loongson with its 16k pages). If malloc option S (or rather cache size 0) is used we use strict multiple of 16 sized chunks, to get as many buckets as possible. ssh(d) enabled malloc option S, in general security sensitive programs should. See the find_bucket() and bin_of() functions. Thanks to Tony Finch for pointing me to code to compute nice bucket sizes. ok tb@
2023-03-15Fix a number of out of bound reads in DNS response parsing.Todd C. Miller
Originally from djm@. OK deraadt@ florian@ bluhm@
2023-03-02When parsing %s, the result should be in the local time zone.Todd C. Miller
Based on a patch from enh@google. OK tb@
2023-02-27use the correct size of the execve syscall stubTheo de Raadt
2023-02-27Calculate the size of the static (and profiled static) execve syscall stubTheo de Raadt
and store it in a const variable for use by crt0. help from kettenis and miod
2023-02-27There is no reason to-be-cleared chunks cannot participate in delayedOtto Moerbeek
freeing; ok tb@
2023-02-24Try to warn about syscall() possibly being deleted from libc in theTheo de Raadt
future. The ports team is already running around with axes and mops, but don't worry such an action won't happen quickly. with tb
2023-02-23adjust documentation for ktrace.h changes. utrace() is now easier to useTheo de Raadt
ok guenther
2023-02-22remove .Pp before .Sh;Jason McIntyre
2023-02-22Point to <signal.h> and not <sys/signal.h>: the latter isPhilip Guenther
an implementation detail for the kernel, libc, and libkvm, and should not be a concern for others.
2023-02-22Prefer 'argument' over 'parameter' when refering to the valuePhilip Guenther
passed in a specific call. From discussion with schwarze@ and jmc@ ok jmc@
2023-02-22Prefer "get or set" over "get/set" or "get and set".Philip Guenther
From discussion with schwarze@ and jmc@ ok jmc@
2023-02-21adress -> address;Jason McIntyre
2023-02-21hppa does some weird callgate stuff, so the pinsyscall() provides theTheo de Raadt
wrong address to the kernel. disable for now.
2023-02-21dlfcn/init.cTheo de Raadt
2023-02-21Do pinsyscall() after static libc is configured for errno storage.Theo de Raadt
2023-02-21pinsyscall(2) is not just for dynamic binaries anymore, so make theTheo de Raadt
text more generic
2023-02-21In static binaries, if WEAK execve can be found, use pinsyscall(2) toTheo de Raadt
tell the kernel where the execve stub is found. With this mechanism we cannot tell the size, so use 128 as an estimate for the most we expect from any architecture. discussed with kettenis, ok guenther
2023-02-21create a stub for pinsyscall(2)Theo de Raadt
ok guenther
2023-02-21correct parameter typeTheo de Raadt
2023-02-19auth_getchallenge does not exist anymoreaisha
2023-02-18missing dot before macro; from josiah frentsosJason McIntyre
2023-02-17Only compile _ng_print() #ifdef DEBUG_NG; ok millert@Miod Vallat