about summary refs log tree commit diff
path: root/src/unistd
Commit message (Collapse)AuthorAgeFilesLines
* support null buffer argument to getcwd, auto-allocating behaviorRich Felker2012-03-011-1/+6
| | | | | | | this is a popular extension some programs depend on, and by using a temporary buffer and strdup rather than malloc prior to the syscall, i've avoided the dependency on free and thus minimized the bloat cost of supporting this feature.
* cleanup various minor issues reported by nszRich Felker2011-09-261-1/+1
| | | | | | | | | the changes to syscall_ret are mostly no-ops in the generated code, just cleanup of type issues and removal of some implementation-defined behavior. the one exception is the change in the comparison value, which is fixed so that 0xf...f000 (which in principle could be a valid return value for mmap, although probably never in reality) is not treated as an error return.
* update syscalls with off_t arguments to handle argument alignment, if neededRich Felker2011-09-214-4/+4
| | | | | | the arm syscall abi requires 64-bit arguments to be aligned on an even register boundary. these new macros facilitate meeting the abi requirement without imposing significant ugliness on the code.
* fix various errors in function signatures/prototypes found by nszRich Felker2011-09-132-2/+2
|
* fix some bugs in setxid and update setrlimit to use __synccallRich Felker2011-07-301-8/+6
| | | | | | | | setrlimit is supposed to be per-process, not per-thread, but again linux gets it wrong. work around this in userspace. not only is it needed for correctness; setxid also depends on the resource limits for all threads being the same to avoid situations where temporarily unlimiting the limit succeeds in some threads but fails in others.
* add setxid.c for new set*id() framework. missed in last commit.Rich Felker2011-07-291-0/+49
|
* new attempt at making set*id() safe and robustRich Felker2011-07-298-8/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | changing credentials in a multi-threaded program is extremely difficult on linux because it requires synchronizing the change between all threads, which have their own thread-local credentials on the kernel side. this is further complicated by the fact that changing the real uid can fail due to exceeding RLIMIT_NPROC, making it possible that the syscall will succeed in some threads but fail in others. the old __rsyscall approach being replaced was robust in that it would report failure if any one thread failed, but in this case, the program would be left in an inconsistent state where individual threads might have different uid. (this was not as bad as glibc, which would sometimes even fail to report the failure entirely!) the new approach being committed refuses to change real user id when it cannot temporarily set the rlimit to infinity. this is completely POSIX conformant since POSIX does not require an implementation to allow real-user-id changes for non-privileged processes whatsoever. still, setting the real uid can fail due to memory allocation in the kernel, but this can only happen if there is not already a cached object for the target user. thus, we forcibly serialize the syscalls attempts, and fail the entire operation on the first failure. this *should* lead to an all-or-nothing success/failure result, but it's still fragile and highly dependent on kernel developers not breaking things worse than they're already broken. ideally linux will eventually add a CLONE_USERCRED flag that would give POSIX conformant credential changes without any hacks from userspace, and all of this code would become redundant and could be removed ~10 years down the line when everyone has abandoned the old broken kernels. i'm not holding my breath...
* omit errno update path for syscalls that cannot failRich Felker2011-04-217-7/+7
|
* workaround bug in linux dup2Rich Felker2011-04-201-1/+4
| | | | | | the linux documentation for dup2 says it can fail with EBUSY due to a race condition with open and dup in the kernel. shield applications (and the rest of libc) from this nonsense by looping until it succeeds
* remove bogus extra logic for close cancellabilityRich Felker2011-04-181-3/+1
| | | | | | like all other syscalls, close should return to the caller if and only if it successfully performed its action. it is necessary that the application be able to determine whether the close succeeded.
* debloat: use __syscall instead of syscall where possibleRich Felker2011-04-171-1/+1
| | | | | | don't waste time (and significant code size due to function call overhead!) setting errno when the result of a syscall does not matter or when it can't fail.
* overhaul pthread cancellationRich Felker2011-04-178-38/+9
| | | | | | | | | | | | | | | | | | | | | | this patch improves the correctness, simplicity, and size of cancellation-related code. modulo any small errors, it should now be completely conformant, safe, and resource-leak free. the notion of entering and exiting cancellation-point context has been completely eliminated and replaced with alternative syscall assembly code for cancellable syscalls. the assembly is responsible for setting up execution context information (stack pointer and address of the syscall instruction) which the cancellation signal handler can use to determine whether the interrupted code was in a cancellable state. these changes eliminate race conditions in the previous generation of cancellation handling code (whereby a cancellation request received just prior to the syscall would not be processed, leaving the syscall to block, potentially indefinitely), and remedy an issue where non-cancellable syscalls made from signal handlers became cancellable if the signal handler interrupted a cancellation point. x86_64 asm is untested and may need a second try to get it right.
* consistency: change all remaining syscalls to use SYS_ rather than __NR_ prefixRich Felker2011-04-0612-12/+12
|
* move rsyscall out of pthread_create moduleRich Felker2011-04-066-12/+6
| | | | | | | | | | | | | | this is something of a tradeoff, as now set*id() functions, rather than pthread_create, are what pull in the code overhead for dealing with linux's refusal to implement proper POSIX thread-vs-process semantics. my motivations are: 1. it's cleaner this way, especially cleaner to optimize out the rsyscall locking overhead from pthread_create when it's not needed. 2. it's expected that only a tiny number of core system programs will ever use set*id() functions, whereas many programs may want to use threads, and making thread overhead tiny is an incentive for "light" programs to try threads.
* make ualarm actually work (obsolete function removed from SUS)Rich Felker2011-04-031-4/+9
|
* add setresuid/setresgid functions (nonstandard)Rich Felker2011-04-032-0/+20
|
* remove obsolete and useless useconds_t typeRich Felker2011-04-012-2/+2
|
* global cleanup to use the new syscall interfaceRich Felker2011-03-2049-50/+50
|
* syscall overhaul part two - unify public and internal syscall interfaceRich Felker2011-03-194-4/+4
| | | | | | | | | | | | | | | | with this patch, the syscallN() functions are no longer needed; a variadic syscall() macro allows syscalls with anywhere from 0 to 6 arguments to be made with a single macro name. also, manually casting each non-integer argument with (long) is no longer necessary; the casts are hidden in the macros. some source files which depended on being able to define the old macro SYSCALL_RETURNS_ERRNO have been modified to directly use __syscall() instead of syscall(). references to SYSCALL_SIGSET_SIZE and SYSCALL_LL have also been changed. x86_64 has not been tested, and may need a follow-up commit to fix any minor bugs/oversights.
* finish moving 32-bit-specific junk out of source files.Rich Felker2011-02-154-14/+4
|
* put confstr.c with the other conf functionsRich Felker2011-02-141-17/+0
|
* cleaning up syscalls in preparation for x86_64 portRich Felker2011-02-1314-24/+27
| | | | | | | | | - hide all the legacy xxxxxx32 name cruft in syscall.h so the actual source files can be clean and uniform across all archs. - cleanup llseek/lseek and mmap2/mmap handling for 32/64 bit systems - alternate implementation for nice if the target lacks nice syscall
* initial check-in, version 0.5.0 v0.5.0Rich Felker2011-02-1271-0/+646