about summary refs log tree commit diff
Commit message (Collapse)AuthorAgeFilesLines
* remove return with expression in void functionMichael Forney2021-04-271-1/+1
|
* remove unnecessary cast for map_library returnÉrico Nogueira2021-04-201-1/+1
| | | | the function already returns (void *)
* add pthread_getname_np functionÉrico Rolim2021-04-202-0/+26
| | | | based on the pthread_setname_np implementation
* fix popen not to leak pipes from one child to anotherRich Felker2021-04-201-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | POSIX places an obscure requirement on popen which is like a limited version of close-on-exec: "The popen() function shall ensure that any streams from previous popen() calls that remain open in the parent process are closed in the new child process." if the POSIX-future 'e' mode flag is passed, producing a pipe FILE with FD_CLOEXEC on the underlying pipe, this requirement is automatically satisfied. however, for applications which use multiple concurrent popen pipes but don't request close-on-exec, fd leaks from earlier popen calls to later ones could produce deadlock situations where processes are waiting for a pipe EOF that will never happen. to fix this, iterate through all open FILEs and add close actions for those obtained from popen. this requires holding a lock on the open file list across the posix_spawn call so that additional popen FILEs are not created after the list is traversed. note that it's still possible for another popen call to start and create its pipe while the lock is held, but such pipes are created with O_CLOEXEC and only drop close-on-exec status (when 'e' flag is omitted) under control of the lock.
* remove spurious lock in popenRich Felker2021-04-201-2/+0
| | | | | | | the newly allocated FILE * has not yet leaked to the application and is only visible to stdio internals until popen returns. since we do not change any fields of the structure observed by libc internals, only the pipe_pid member, locking is not necessary.
* define __STDC_UTF_{16,32}__ macrosÉrico Nogueira2021-04-191-0/+3
| | | | | these macros are used to indicate that the implementation uses, respectively, utf-16 and utf-32 encoding for char16_t and char32_t.
* fix regression in dl_iterate_phdr reporting of modules with no TLSRich Felker2021-04-161-1/+2
| | | | | | | | | __tls_get_addr should not be called with an invalid TLS module id of 0. in practice it probably "works", returning the DTV length as if it were a pointer, and the callback should probably not inspect dlpi_tls_data in this case, but it's likely that some real-world callbacks use a check on dlpi_tls_data being non-null, rather than on dlpi_tls_modid being nonzero, to conclude that the module has TLS.
* nscd: fall back gracefully on kernels without AF_UNIX supportJoakim Sindholt2021-04-161-1/+9
|
* mallocng/aligned_alloc: check for malloc failureDominic Chen2021-04-161-0/+3
| | | | | | With mallocng, calling posix_memalign() or aligned_alloc() will SIGSEGV if the internal malloc() call returns NULL. This does not occur with oldmalloc, which explicitly checks for allocation failure.
* make epoll_[p]wait a cancellation pointRich Felker2021-04-031-2/+2
| | | | | | | | | this is a Linux-specific function and not covered by POSIX's requirements for which interfaces are cancellation points, but glibc makes it one and existing software relies on it being one. at some point a review for similar functions that should be made cancellation points should be done.
* fix dl_iterate_phdr dlpi_tls_data reporting to match specRich Felker2021-03-262-2/+3
| | | | | | | | | | dl_iterate_phdr was wrongly reporting the address of the DSO's PT_TLS image rather than the calling thread's instance of the TLS. the man page, which is essentially normative for a nonstandard function of this sort, clearly specifies the latter. it does not clarify where exactly within/relative-to the image the pointer should point, but the reasonable thing to do is match the ABI's DTP offset, and this seems to be what other implementations do.
* remove no-longer-needed special case handling in popenRich Felker2021-03-151-16/+0
| | | | | | | | | | popen was special-casing the possibility (only possible when the parent closed stdin and/or stdout) that the child's end of the pipe was already on the final desired fd number, in which case there was no way to get rid of its close-on-exec flag in the child. commit 6fc6ca1a323bc0b6b9e9cdc8fa72221ae18fe206 made this unnecessary by implementing the POSIX-future requirement that dup2 file actions with equal source and destination fd values remove the close-on-exec flag.
* use internal malloc for posix_spawn file actions objectsRich Felker2021-03-151-0/+5
| | | | | | this makes it possible to perform actions on file actions objects with a libc-internal lock held without creating lock order relationships that are silently imposed on an application-provided malloc.
* don't fail to map library/executable with zero-length segment mapsRich Felker2021-03-051-0/+1
| | | | | | | reportedly the GNU linker can emit such segments, causing spurious failure to load due to mmap with a length of zero producing EINVAL. no action is required for such a load map (it's effectively a nop in the program headers table) so just treat it as always successful.
* suppress isascii() macro for C++Érico Rolim2021-02-251-0/+2
| | | | analogous to commit a60457c84a4b59ab564d7f4abb660a70283ba98d.
* guard against compilers failing to handle setjmp specially by defaultRich Felker2021-02-221-3/+11
| | | | | | | | | | | | | | | | | | | | | | | since 4.1, gcc has had the __returns_twice__ attribute and has required functions which return twice to carry it; however it's always applied it automatically to known setjmp-like function names. clang however does not do this reliably, at least not with -ffreestanding and possibly under other conditions, resulting in silent emission of wrong code. since the symbol name setjmp is in no way special (setjmp is specified as a macro that could expand to use any implementation-specific symbol name or names), a compiler is justified not to do anything special without further hints, and it's reasonable to do what we can to provide such hints. gcc 4.0.x and earlier do not recognize the attribute, so make use conditional on __GNUC__ macros. clang and other gcc-like compilers report (and have always reported) a later "GNUC" version so the preprocessor conditional should function as desired for them as too. undefine the internal macro after use so that nothing abuses it as a public feature.
* aarch64/bits/mman.h: add PROT_MTE from linux v5.10Szabolcs Nagy2021-02-151-0/+1
| | | | | | | see linux commit 9f3419315f3cdc41a7318e4d50ba18a592b30c8c arm64: mte: Add PROT_MTE support to mmap() and mprotect()
* aarch64/bits/hwcap.h: add HWCAP2_MTE from linux v5.10Szabolcs Nagy2021-02-151-0/+1
| | | | | | | see linux commit 3b714d24ef173f81c78af16f73dcc9b40428c803 arm64: mte: CPU feature detection and initial sysreg configuration
* add aarch64/bits/mman.h with PROT_BTI from linux v5.8Szabolcs Nagy2021-02-151-0/+1
| | | | | | | this was missing, see linux commit 8ef8f360cf30be12382f89ff48a57fbbd9b31c14 arm64: Basic Branch Target Identification support
* aarch64/bits/hwcap.h: add HWCAP2_BTI from linux v5.8Szabolcs Nagy2021-02-151-0/+1
| | | | | | | hwcap for BTI was missing, see linux commit 8ef8f360cf30be12382f89ff48a57fbbd9b31c14 arm64: Basic Branch Target Identification support
* signal.h: add MTE specific SIGSEGV codes from linux v5.10Szabolcs Nagy2021-02-151-0/+2
| | | | | | | add synchronouse and asynchronous tag check failure codes, see linux commit 74f1082487feb90bbf880af14beb8e29c3030c9f arm64: mte: Add specific SIGSEGV codes
* sys/prctl.h: add MTE related constants from linux v5.10Szabolcs Nagy2021-02-151-0/+7
| | | | | | | | | | these are for the aarch64 MTE (memory tagging extension), see linux commit 1c101da8b971a36695319dce7a24711dc567a0dd arm64: mte: Allow user control of the tag check mode via prctl() linux commit af5ce95282dc99d08a27a407a02c763dde1c5558 arm64: mte: Allow user control of the generated random tags via prctl()
* elf.h: add NT_ARM_TAGGED_ADDR_CTRL from linux v5.10Szabolcs Nagy2021-02-151-0/+1
| | | | | | | see linux commit 2200aa7154cb7ef76bac93e98326883ba64bfa2e arm64: mte: ptrace: Add NT_ARM_TAGGED_ADDR_CTRL regset
* sys/mman.h: add MAP_HUGE_16KB from linux v5.10Szabolcs Nagy2021-02-151-0/+1
| | | | | | | see linux commit e47168f3d1b14af5281cf50c59561d59d28201f9 powerpc/8xx: Support 16k hugepages with 4k pages
* sys/mount.h: add MS_NOSYMFOLLOW from linux v5.10Szabolcs Nagy2021-02-151-0/+1
| | | | | | | | path resolution does not follow symlinks on nosymfollow mounts (but readlink still does), see linux commit dab741e0e02bd3c4f5e2e97be74b39df2523fc6e Add a "nosymfollow" mount option.
* sys/membarrier.h: add new constants from linux v5.10Szabolcs Nagy2021-02-151-0/+4
| | | | | | | | can cause rseq restart on another cpu to synchronize with global memory access from rseq critical sections, see linux commit 2a36ab717e8fe678d98f81c14a0b124712719840 rseq/membarrier: Add MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ
* bits/syscall.h: add process_madvise from linux v5.10Szabolcs Nagy2021-02-1516-0/+16
| | | | | | | | | mainly added to linux to allow a central process management service in android to give MADV_COLD|PAGEOUT hints for other processes, see linux commit ecb8ac8b1f146915aa6b96449b66dd48984caacc mm/madvise: introduce process_madvise() syscall: an external memory hinting API
* fix error return value for cuseridRich Felker2021-02-131-2/+3
| | | | | | | the historical function was specified to return an empty string in the caller-provided buffer, not a null pointer, to indicate error when the argument is non-null. only when the argument is null should it return a null pointer on error.
* fix misuse of getpwuid_r in cuseridRich Felker2021-02-131-1/+2
| | | | | | getpwuid_r can return 0 but without a result in the case where there was no error but no record exists. in that case cuserid was treating it as success and copying junk out of pw.pw_name to the output buffer.
* cuserid: don't return truncated resultsRich Felker2021-02-131-1/+5
| | | | checking the length also drops the need to pull in snprintf.
* cuserid: support invocation with a null pointer argumentSören Tempel2021-02-131-0/+2
| | | | | | this function was removed from the standard in 2001 but appeared in SUSv2 with an obligation to support calls with a null pointer argument, using a static buffer.
* riscv64: define ELF_NFPREGKhem Raj2021-02-121-0/+1
| | | | ELF_NFPREG is used by some userspace applications like gdb
* math: fix expm1f overflow thresholdSzabolcs Nagy2021-02-101-2/+1
| | | | | | | | | the threshold was wrong so expm1f overflowed to inf a bit too early and on most targets uint32_t compare is faster than float compare so use that. this also fixes sinhf incorrectly returning nan for some values where the internal expm1f overflowed.
* math: fix acoshf for negative inputsSzabolcs Nagy2021-02-101-4/+4
| | | | | | | | | | | | | | | | | | | | on some negative inputs (e.g. -0x1.1e6ae8p+5) acoshf failed to return nan. ensure that negative inputs result nan without introducing new branches. this was tried before in commit 101e6012856918440b5d7474739c3fc22a8d3b85 math: fix acoshf on negative values but that fix was wrong. there are 3 formulas used: log1p(x-1 + sqrt((x-1)*(x-1)+2*(x-1))) log(2*x - 1/(x+sqrt(x*x-1))) log(x) + 0.693147180559945309417232121458176568 the first fails on large negative inputs (may compute log1p(0) or log1p(inf)), the second one fails on some mid range or large negative inputs (may compute log(large) or log(inf)) and the last one fails on -0 (returns -inf).
* fix possible fd leak via missing O_CLOEXEC in pthread_setname_npÉrico Rolim2021-01-301-1/+1
| | | | | the omission of the flag here seems to have been an oversight when the function was added in 8fb28b0b3e7a5e958fb844722a4b2ef9bc244af1
* oldmalloc: preserve errno across freeRich Felker2021-01-301-0/+4
| | | | | | | | as an outcome of Austin Group issue #385, future versions of the standard will require free not to alter the value of errno. save and restore it individually around the calls to madvise and munmap so that the cost is not imposed on calls to free that do not result in any syscall.
* fix build regression in oldmallocRich Felker2021-01-301-1/+1
| | | | | | commit 8d37958d58cf36f53d5fcc7a8aa6d633da6071b2 inadvertently broke oldmalloc by having it implement __libc_malloc rather than __libc_malloc_impl.
* preserve errno across freeRich Felker2021-01-301-2/+10
| | | | | | | | as an outcome of Austin Group issue #385, future versions of the standard will require free not to alter the value of errno. save and restore it individually around the calls to madvise and munmap so that the cost is not imposed on calls to free that do not result in any syscall.
* fix inconsistent signature of __libc_start_mainRich Felker2021-01-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | commit 7586360badcae6e73f04eb1b8189ce630281c4b2 removed the unused arguments from the definition of __libc_start_main, making it incompatible with the declaration at the point of call, which still passed 6 arguments. calls with mismatched function type have undefined behavior, breaking LTO and any other tooling that checks for function signature mismatch. removing the extra arguments from the point of call (crt1) is not an option for fixing this, since that would be a change in ABI surface between application and libc. adding back the extra arguments requires some care. on archs that pass arguments on the stack or that reserve argument spill space for the callee on the stack, it imposes an ABI requirement on the caller to provide such space. the modern crt1.c entry point provides such space, but originally there was arch-specific asm for the call to __libc_start_main. the last of this asm was removed in commit 6fef8cafbd0f6f185897bc87feb1ff66e2e204e1, and manual review of the code removed and its prior history was performed to check that all archs/variants passed the legacy init/fini/ldso_fini arguments.
* fail posix_spawn file_actions operations with negative fdsRich Felker2021-01-304-0/+4
| | | | | | | | | | | these functions are specified to fail with EBADF on negative fd arguments. apart from close, they are also specified to fail if the value exceeds OPEN_MAX, but as written it is not clear that this imposes any requirement when OPEN_MAX is not defined, and it's undesirable to impose a dynamic limit (via setrlimit) here since the limit at the time of posix_spawn may be different from the limit at the time of setting up the file actions. this may require revisiting later.
* release 1.2.2 v1.2.2Rich Felker2021-01-142-1/+52
|
* fix VIDIOC_DQEVENT (v4l2) ioctl fallback for pre-5.6 kernelsRich Felker2020-12-141-1/+9
| | | | | | | | | | | | commit 2412638bb39eb799b2600393bbd71cca8ae96bb2 got the size of struct v4l2_event wrong and failed to account for the fact that the old struct might be either 120 bytes with time misaligned mod 8, or 128 bytes with time aligned mod 8, due to the contained union having 64-bit members whose alignment is arch-dependent. rather than adding new logic to handle the differences, use an actual stripped-down version of the structure in question to derive the ioctl number, size, and offsets.
* fix v4l2 buffer ioctl fallbacks for pre-5.6 kernelsArnd Bergmann2020-12-141-4/+4
| | | | | | | | commit 2412638bb39eb799b2600393bbd71cca8ae96bb2 got the size of struct v4l2_buffer wrong and omitted the tv_usec member slot from the offset list, so the ioctl numbers never matched and fallback code path was never taken. this caused the affected ioctls to fail with ENOTTY on kernels not new enough to have the native time64 ioctls.
* sh: fix incorrect mcontext_t member namingAriadne Conill2020-12-122-4/+13
| | | | | while the layouts match, the member member naming expected by software using mcontext_t omits the sc_ prefix.
* use libc-internal malloc for newlocale/freelocaleRich Felker2020-12-092-0/+10
| | | | | | | this is necessary for MT-fork correctness now that the code runs under locale lock. it would not be hard to avoid, but __get_locale is already using libc-internal malloc anyway. this can be reconsidered during locale overhaul later if needed.
* drop use of pthread_once in newlocaleRich Felker2020-12-091-9/+7
| | | | | | | in general, pthread_once is not compatible with MT-fork constraints (commit 167390f05564e0a4d3fcb4329377fd7743267560). here it actually no longer matters, because it's now called with a lock held, but since the lock is held it's pointless to use pthread_once.
* lift locale lock out of internal __get_localeRich Felker2020-12-094-18/+19
| | | | | | this allows the lock to be shared with setlocale, eliminates repeated per-category lock/unlock in newlocale, and will allow the use of pthread_once in newlocale to be dropped (to be done separately).
* fix misleading comment in strstrRich Felker2020-12-091-1/+1
| | | | | | | | the intent here is just to scan at least l bytes forward for the end of the haystack and at least some decent minimum to avoid doing it over and over if the needle is short, with no need to be precise. the comment erroneously stated this as an estimate for MIN when it's actually an estimate for MAX.
* drop use of pthread_once for aio thread stack size initRich Felker2020-12-081-10/+8
| | | | | | | | | | | | | pthread_once is not compatible with MT-fork constraints (commit 167390f05564e0a4d3fcb4329377fd7743267560) and is not needed here anyway; we already have a lock suitable for initialization. while changing this, fix a corner case where AT_MINSIGSTKSZ gives a value that's more than MINSIGSTKSZ but by a margin of less than 2048, thereby causing the size to be reduced. it shouldn't matter but the intent was to be the larger of a 2048-byte margin over the legacy fixed minimum stack requirement or a 512-byte margin over the minimum the kernel reports at runtime.
* fix omission of non-stub pthread_mutexattr_getprotocolRich Felker2020-12-071-1/+1
| | | | | | | this change should have been made when priority inheritance mutex support was added. if priority protection is also added at some point the implementation will need to change and will probably no longer be a simple bit shuffling.