Commit Graph

2411 Commits

Author SHA1 Message Date
4ee039f354 avoid referencing address of extern function from vdprintf
this change is in preparation for upcoming PIC/shared library support.
the intent is to avoid going through the GOT, mainly so that dprintf
is operable immediately, prior to processing of relocations. having
dprintf accessible from the dynamic linker will make writing and
debugging the dynamic linker much easier.
2011-02-20 22:24:28 -05:00
3075f7e847 cleanup asprintf stuff 2011-02-20 17:19:37 -05:00
bdc9ed1565 fix %n specifier, again. this time it was storing the wrong value. 2011-02-20 17:10:40 -05:00
26031da0f8 make malloc(0) return unique pointers rather than NULL
this change is made with some reluctance, but i think it's for the
best. correct programs must handle either behavior, so there is little
advantage to having malloc(0) return NULL. and i managed to actually
make the malloc code slightly smaller with this change.
2011-02-20 16:16:33 -05:00
598a0147cd fix simple_malloc malloc(0) behavior not to return non-unique pointers 2011-02-20 16:12:09 -05:00
a23baf586a fix simple_malloc size restrictions
do not allow allocations that overflow ptrdiff_t; fix some overflow
checks that were not quite right but didn't matter due to address
layout implementation.
2011-02-20 16:10:38 -05:00
96f2197494 fix null pointer dereference introduced in last sigprocmask commit 2011-02-20 15:16:04 -05:00
eee150f39c make real symbols for the legacy (nonstandardized) utmp functions
this is needed in the long term for ABI compatibility anyway, and in
the immediate, it helps with building broken programs like GNU screen
that try to prototype the functions themselves rather than using the
header.
2011-02-20 15:06:26 -05:00
13e8459232 workaround gcc bug 46926 by providing a dumb sincos implementation
note that this library itself is built with -ffreestanding so sincos.c
should not be miscompiled even if the gcc used to compile musl has
this bug.
2011-02-19 17:56:57 -05:00
98e02144da use rt_sigprocmask, not legacy sigprocmask, syscall in pthread exit code 2011-02-19 15:21:05 -05:00
4b1244a0bf implement the remaining clock_* interfaces 2011-02-19 12:43:56 -05:00
19eb13b9a4 race condition fix: block all signals before decrementing thread count
the existence of a (kernelspace) thread must never have observable
effects after the thread count is decremented. if signals are not
blocked, it could end up handling the signal for rsyscall and
contributing towards the count of threads which have changed ids,
causing a thread to be missed. this could lead to one thread retaining
unwanted privilege level.

this change may also address other subtle race conditions in
application code that uses signals.
2011-02-19 11:04:36 -05:00
a49c119276 prevent sigprocmask/pthread_sigmask from blocking implementation signals
this code was wrongly disabled because the old version was trying to
be too clever and didn't work. replaced it with a simple version for
now.
2011-02-19 10:51:13 -05:00
fb11b6b85e make pthread_exit run dtors for last thread, wait to decrement thread count 2011-02-19 10:38:57 -05:00
69ecbd0f31 make mktemp match the historic behavior, and update functions that use it
the historic mktemp is supposed to blank the template string on
failure, rather than returning 0. just zero the first character so
that mkstemp and mkdtemp can still retry with O(1) space requirement.
2011-02-19 09:40:07 -05:00
2e6239dd06 fix major bug created from copying mkdtemp logic 2011-02-19 09:34:28 -05:00
095a5ae6f2 add syscall wrappers for inotify 2011-02-19 02:52:29 -05:00
cc2a8228fa cleanup cruft left from when kernel and user time_t disagreed 2011-02-19 02:28:42 -05:00
e9417fffb3 add pthread_atfork interface
note that this presently does not handle consistency of the libc's own
global state during forking. as per POSIX 2008, if the parent process
was threaded, the child process may only call async-signal-safe
functions until one of the exec-family functions is called, so the
current behavior is believed to be conformant even if non-ideal. it
may be improved at some later time.
2011-02-18 19:52:42 -05:00
446b4207cc major improvements to temp file name generator
use current time in nanoseconds and some potentially-random (if aslr
is enabled) pointer values for the initial tempfile name generation,
and step via a cheap linear prng on collisions. limit the number of
retry attempts to prevent denial of service attacks even if an
attacker can guess the filenames.
2011-02-18 17:04:56 -05:00
3e9e30166f reformat mkstemp like mkdtemp
this is cleaner and makes it easy to impose a limit on the number of
retries later if it seems desirable to do so.
2011-02-18 16:32:33 -05:00
d5ca067c7b add portable lchown (trivial to support and a few ancient things want it..) 2011-02-17 23:13:46 -05:00
e882756311 reorganize pthread data structures and move the definitions to alltypes.h
this allows sys/types.h to provide the pthread types, as required by
POSIX. this design also facilitates forcing ABI-compatible sizes in
the arch-specific alltypes.h, while eliminating the need for
developers changing the internals of the pthread types to poke around
with arch-specific headers they may not be able to test.
2011-02-17 17:16:20 -05:00
187fe29d5b make daemon try the operations that might fail before fork rather than after 2011-02-17 10:30:00 -05:00
19e35c500b daemon should check for failures and return -1 2011-02-17 10:28:56 -05:00
b24bc15f5c don't compare elements with themselves during qsort.
this is actually a workaround for a bug in gcc, whereby it asserts
inequality of the keys being compared...
2011-02-17 00:03:24 -05:00
5cbd76c6b0 fix printf %n specifier - missing breaks had it clobbering memory 2011-02-16 18:19:46 -05:00
e3657ba599 patch by njk, simplifies thread register initialization for x86_64
It's not necessary to save any registers on the stack across syscall in
x86_64 __set_thread_area.  Don't waste cycles or bytes on it.
2011-02-16 09:50:57 -05:00
22cd9cae81 patch from njk: make x86_64 __uniclone branchless. 2011-02-16 09:49:54 -05:00
bad481266e fix compile failure: legacy cuserid needs to define feature test 2011-02-16 09:30:56 -05:00
9b235e8374 remove standalone syscall cruft
this was originally written for an early draft of the library where
non-standard functions would reside in a static library separate from
the shared libc.so, which would implement a pure standard. the idea
was not to depend on an implementation-dependent __syscall_ret
function in the main libc. but it turned out to be better to put
everything in a single library for both static and dynamic linking
uses, and thus the (incomplete) remnants of this feature were just
enlarging the source and binary.
2011-02-15 14:39:02 -05:00
1e12632591 Port musl to x86-64. One giant commit! 2011-02-15 07:32:09 -05:00
c2afb747b0 yet another ugly legacy syscall rename... 2011-02-15 05:52:27 -05:00
f7eb91e795 fix getrlimit handling on 32-bit systems, and ease porting to 64-bit 2011-02-15 05:42:27 -05:00
03a2f3e48c cleanup socketcall syscall interface to ease porting to sane(r) archs 2011-02-15 04:40:40 -05:00
cfe373146d finish moving 32-bit-specific junk out of source files. 2011-02-15 04:12:19 -05:00
a5bf06c035 move arch-specific internal headers into place 2011-02-15 04:00:40 -05:00
7b2dd2235d finish unifying thread register handling in preparation for porting 2011-02-15 03:56:52 -05:00
0b2006c8fe begin unifying clone/thread management interface in preparation for porting 2011-02-15 03:24:58 -05:00
59666802fb make pthread_create return EAGAIN on resource failure, as required by POSIX 2011-02-15 02:20:21 -05:00
976f42d1f1 guard against hard links to non-ordinary-files when reading tcb shadow 2011-02-14 21:15:07 -05:00
ca1aa5bae9 more header cleanup and conformance fixes - string.h 2011-02-14 20:53:15 -05:00
1322cb82a3 header cleanup, conformance fixes - signals 2011-02-14 20:33:54 -05:00
6fbf8bfd75 another pointer signedness fix 2011-02-14 19:40:20 -05:00
a8c17e6587 fix some pointer signedness issues (this was invalid C) 2011-02-14 19:37:01 -05:00
c247ebdd98 more header fixes, minor warning fix 2011-02-14 19:33:11 -05:00
5377715ce0 ensure standard functions mk[sd]temp don't depend on removed function mktemp 2011-02-14 19:18:06 -05:00
c255e5542d put confstr.c with the other conf functions 2011-02-14 19:13:18 -05:00
80695b1d1e begin namespace-cleanup of standard C headers 2011-02-14 05:10:10 -05:00
7fe308eb9f use a more-correct integer type, and silence 64-bit warnings as a bonus 2011-02-13 23:38:21 -05:00