summaryrefslogtreecommitdiffstats
path: root/libc/arch-arm/syscalls
Commit message (Collapse)AuthorAgeFilesLines
* Hide accidentally-exposed __clock_nanosleep.Elliott Hughes2015-06-161-2/+3
| | | | | | Bug: http://b/21858067 Change-Id: Iaa83a5e17cfff796aed4f641d0d14427614d9399 (cherry picked from commit b1304935b64ffcd59cd787cc9ac83a2d14dc587b)
* Add process_vm_readv and process_vm_writev.Elliott Hughes2015-06-102-0/+44
| | | | | | Bug: http://b/21761353 Change-Id: Ic8ef3f241d62d2a4271fbc783c8af50257bac498 (cherry picked from commit be57a40d2973739c4fb0aa1cfb0014f34aeec2bd)
* libc: Add O_PATH support for fgetxattr / fsetxattrNick Kralevich2015-06-022-4/+6
| | | | | | | | | | | | | | | | | | | | | | Support O_PATH file descriptors when handling fgetxattr and fsetxattr. This avoids requiring file read access to pull extended attributes. This is needed to support O_PATH file descriptors when calling SELinux's fgetfilecon() call. In particular, this allows the querying and setting of SELinux file context by using something like the following code: int dirfd = open("/path/to/dir", O_DIRECTORY); int fd = openat(dirfd, "file", O_PATH | O_NOFOLLOW); char *context; fgetfilecon(fd, &context); This change was motivated by a comment in https://android-review.googlesource.com/#/c/152680/1/toys/posix/ls.c (cherrypicked from commit 2825f10b7f61558c264231a536cf3affc0d84204) Change-Id: Ic0cdf9f9dd0e35a63b44a4c4a08400020041eddf
* Fix error handling for negative size in ftruncate.Dan Albert2015-06-011-14/+0
| | | | | | Bug: 21309901 Change-Id: I54692ab8105dd09db6af7a2c0894a17bdd118aa0 (cherry picked from commit c05554ec5c9aff5e0f1e83de9bb62c3569eecca2)
* Hide rt_sigqueueinfo.Yabin Cui2015-05-181-2/+3
| | | | | | Bug: 19358804 Change-Id: I38a53ad64c81d0eefdd1d24599e769fd8a477a56 (cherry picked from commit 40a8f214a5264efe5feaaffd55cea67fb87d097b)
* Simplify close(2) EINTR handling.Elliott Hughes2015-04-231-2/+3
| | | | | | | | | | | | | | | | This doesn't affect code like Chrome that correctly ignores EINTR on close, makes code that tries TEMP_FAILURE_RETRY work (where before it might have closed a different fd and appeared to succeed, or had a bogus EBADF), and makes "goto fail" code work (instead of mistakenly assuming that EINTR means that the close failed). Who loses? Anyone actively trying to detect that they caught a signal while in close(2). I don't think those people exist, and I think they have better alternatives available. Bug: https://code.google.com/p/chromium/issues/detail?id=269623 Bug: http://b/20501816 Change-Id: I11e2f66532fe5d1b0082b2433212e24bdda8219b
* Make gensyscalls.py use the ALIAS_SYMBOL macro.Christopher Ferris2015-03-243-6/+3
| | | | Change-Id: Ib94c0abb6fc85126ecc5ed3f1962b2b8b90b9952
* Fix "faccessat ignores flags"Nick Kralevich2015-02-241-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The kernel system call faccessat() does not have any flags arguments, so passing flags to the kernel is currently ignored. Fix the kernel system call so that no flags argument is passed in. Ensure that we don't support AT_SYMLINK_NOFOLLOW. This non-POSIX (http://pubs.opengroup.org/onlinepubs/9699919799/functions/access.html) flag is a glibc extension, and has non-intuitive, error prone behavior. For example, consider the following code: symlink("foo.is.dangling", "foo"); if (faccessat(AT_FDCWD, "foo", R_OK, AT_SYMLINK_NOFOLLOW) == 0) { int fd = openat(AT_FDCWD, "foo", O_RDONLY | O_NOFOLLOW); } The faccessat() call in glibc will return true, but an attempt to open the dangling symlink will end up failing. GLIBC documents this as returning the access mode of the symlink itself, which will always return true for any symlink on Linux. Some further discussions of this are at: * http://lists.landley.net/pipermail/toybox-landley.net/2014-September/003617.html * http://permalink.gmane.org/gmane.linux.lib.musl.general/6952 AT_SYMLINK_NOFOLLOW seems broken by design. I suspect this is why this function was never added to POSIX. (note that "access" is pretty much broken by design too, since it introduces a race condition between check and action). We shouldn't support this until it's clearly documented by POSIX or we can have it produce intuitive results. Don't support AT_EACCESS for now. Implementing it is complicated, and pretty much useless on Android, since we don't have setuid binaries. See http://git.musl-libc.org/cgit/musl/commit/?id=0a05eace163cee9b08571d2ff9d90f5e82d9c228 for how an implementation might look. Bug: 18867827 Change-Id: I25b86c5020f3152ffa3ac3047f6c4152908d0e04
* Ensure raw fchmod/fchmodat syscalls are hidden.Nick Kralevich2015-02-032-4/+6
| | | | | | | | | | | | | | | | | In https://android-review.googlesource.com/#/c/127908/5/libc/SYSCALLS.TXT@116 Elliott said: for LP64 these will be hidden. for LP32 we were cowards and left them all public for compatibility (though i don't think we ever dremeled to see whether it was needed). we don't have an easy way to recognize additions, though, so we can't prevent adding new turds. Add a mechanism to prevent the adding of new turds, and use that mechanism on the fchmod/fchmodat system calls. Bug: 19233951 Change-Id: I98f98345970b631a379f348df57858f9fc3d57c0
* Add fchmodat(AT_SYMLINK_NOFOLLOW) and fchmod O_PATH supportNick Kralevich2015-02-022-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many libc functions have an option to not follow symbolic links. This is useful to avoid security sensitive code from inadvertantly following attacker supplied symlinks and taking inappropriate action on files it shouldn't. For example, open() has O_NOFOLLOW, chown() has lchown(), stat() has lstat(), etc. There is no such equivalent function for chmod(), such as lchmod(). To address this, POSIX introduced fchmodat(AT_SYMLINK_NOFOLLOW), which is intended to provide a way to perform a chmod operation which doesn't follow symlinks. Currently, the Linux kernel doesn't implement AT_SYMLINK_NOFOLLOW. In GLIBC, attempting to use the AT_SYMLINK_NOFOLLOW flag causes fchmodat to return ENOTSUP. Details are in "man fchmodat". Bionic currently differs from GLIBC in that AT_SYMLINK_NOFOLLOW is silently ignored and treated as if the flag wasn't present. This patch provides a userspace implementation of AT_SYMLINK_NOFOLLOW for bionic. Using open(O_PATH | O_NOFOLLOW), we can provide a way to atomically change the permissions on files without worrying about race conditions. As part of this change, we add support for fchmod on O_PATH file descriptors, because it's relatively straight forward and could be useful in the future. The basic idea behind this implementation comes from https://sourceware.org/bugzilla/show_bug.cgi?id=14578 , specifically comment #10. Change-Id: I1eba0cdb2c509d9193ceecf28f13118188a3cfa7
* support _POSIX_REALTIME_SIGNALSYabin Cui2014-12-081-0/+14
| | | | | Bug: 18489947 Change-Id: I2e834d68bc10ca5fc7ebde047b517a3074179475
* Add sethostname(2).Elliott Hughes2014-11-071-0/+14
| | | | | | Not very useful, but helps building stuff like toybox out of the box. Change-Id: I110e39030452bd093a84278e019c5752d293718d
* Add clock_settime and clock_nanosleep.Haruki Hasegawa2014-10-131-2/+2
| | | | | | | | | | | Add the missing prototypes, fix the existing prototypes to use clockid_t rather than int, fix clock_nanosleep's failure behavior, and add simple tests. Bug: 17644443 Bug: https://code.google.com/p/android/issues/detail?id=77372 Change-Id: I03fba369939403918abcabae9551a7123953d780 Signed-off-by: Haruki Hasegawa <h6a.h4i.0@gmail.com>
* Add posix_fadvise(3).Elliott Hughes2014-09-111-0/+22
| | | | | | | (cherry-pick of 00008263782e484020420c606f7d145fe7d0a4d8.) Bug: 12449798 Change-Id: I07cbf3f670a0d1304b68148325a774f266b5c433
* Ensure __set_errno is still visible on LP32.Elliott Hughes2014-09-08197-591/+197
| | | | | | | | | | | | | | | | | | The use of the .hidden directive to avoid going via the PLT for __set_errno had the side-effect of actually making __set_errno hidden (which is odd because assembler directives don't usually affect symbols defined in a different file --- you can't even create a weak reference to a symbol that's defined in a different file). This change switches the system call stubs over to a new always-hidden __set_errno_internal and has a visible __set_errno on LP32 just for binary compatibility with old NDK apps. (cherry-pick of 7efad83d430f4d824f2aaa75edea5106f6ff8aae.) Bug: 17423135 Change-Id: I6b6d7a05dda85f923d22e5ffd169a91e23499b7b
* Make __set_errno hidden in asm.Dan Albert2014-08-08197-0/+394
| | | | | | | This fixes the build after the -Bsymbolic change. Bug: 16853291 Change-Id: I989c9fec3c32e0289ea257a3bd2b7fd2709b6ce2
* Revert "Replaces vfork() implementation with fork()"Dan Albert2014-08-051-0/+14
| | | | | | | | We're getting cold feet on this one... let's put it back. This reverts commit 210331d9762037afb9b5ed8413079c6f65872df9. Change-Id: I6b0d3c2b1dbf7f1dc9566979a91b7504c2189269
* Implement <sys/fsuid.h>.Elliott Hughes2014-07-302-0/+28
| | | | Change-Id: I1e5e50444a1b5a430ba5b5d9b8b1d91219af5e92
* Add splice, tee, and vmsplice.Elliott Hughes2014-06-243-0/+50
| | | | Change-Id: I5f43380b88d776a8bb607b47dbbc5db5a2fe6163
* Cache getpid.Elliott Hughes2014-06-201-2/+2
| | | | | | | | | | | | | | | | | In practice, with this implementation we never need to make a system call. We get the main thread's tid (which is the same as our pid) back from the set_tid_address system call we have to make during initialization. A new pthread will have the same pid as its parent, and a fork child's main (and only) thread will have a pid equal to its tid, which we get for free from the kernel before clone returns. The only time we'd actually have to make a getpid system call now is if we take a signal during fork and the signal handler calls getpid. (That, or we call getpid in the dynamic linker while it's still dealing with its own relocations and hasn't even set up the main thread yet.) Bug: 15387103 Change-Id: I6d4718ed0a5c912fc75b5f738c49a023dbed5189
* Remove ioprio_get(2) and ioprio_set(2) from LP64.Dan Albert2014-06-122-28/+0
| | | | | Bug: 11156955 Change-Id: I07b596d85e4bd6347d488d1a92c8d0a00b5ef3b3
* Merge "Replaces vfork() implementation with fork()"Dan Albert2014-06-101-14/+0
|\
| * Replaces vfork() implementation with fork()Dan Albert2014-06-101-14/+0
| | | | | | | | | | | | | | | | vfork() was removed from POSIX 2008, so this replaces its implementation with a call to fork(). Bug: 13935372 Change-Id: I6d99ac9e52a2efc5ee9bda1cab908774b830cedc
* | Remove getdents from bionic.Elliott Hughes2014-06-061-2/+2
|/ | | | | Bug: 11156955 Change-Id: I6c306989801be552d85fba8a50dcdc79282fb9d2
* Avoid a system call in 'gettid'.Elliott Hughes2014-06-021-14/+0
| | | | | | | | | | | | | System calls can be pretty slow. This is mako, which has one of our lowest latencies: iterations ns/op BM_unistd_getpid 10000000 209 BM_unistd_gettid 200000000 8 Bug: 15297299 (kernel panic from too many gettid calls) Bug: 15315766 (excessive gettid overhead in liblogd) Change-Id: I49656c0fc5b5d092390264a59e4f2c0d8a8b1aeb
* Revert "Revert "Lose the hand-written futex assembler.""Elliott Hughes2014-05-281-22/+0
| | | | | | | | | | | | | | | | | | | | | | The problem with the original patch was that using syscall(3) means that errno can be set, but pthread_create(3) was abusing the TLS errno slot as a pthread_mutex_t for the thread startup handshake. There was also a mistake in the check for syscall failures --- it should have checked against -1 instead of 0 (not just because that's the default idiom, but also here because futex(2) can legitimately return values > 0). This patch stops abusing the TLS errno slot and adds a pthread_mutex_t to pthread_internal_t instead. (Note that for LP64 sizeof(pthread_mutex_t) > sizeof(uintptr_t), so we could potentially clobber other TLS slots too.) I've also rewritten the LP32 compatibility stubs to directly reuse the code from the .h file. This reverts commit 75c55ff84ebfa686c7ae2cc8ee431c6a33bd46b4. Bug: 15195455 Change-Id: I6ffb13e5cf6a35d8f59f692d94192aae9ab4593d
* Revert "Lose the hand-written futex assembler."Narayan Kamath2014-05-281-0/+22
| | | | | | | | | | This reverts commit ced906c849704f379d7191822f6d74993d4fa296. Causes issues on art / dalvik due to a broken return value check and other undiagnosed issues. bug: 15195455 Change-Id: I5d6bbb389ecefb0e33a5237421a9d56d32a9317c
* Lose the hand-written futex assembler.Elliott Hughes2014-05-221-22/+0
| | | | | | | Also stop exporting 'futex'. Bug: 12250341 Change-Id: Icc4fa4296cd04dfe0d1061822c69e2eb40c3433a
* Remove the tkill(2) stub.Elliott Hughes2014-05-221-14/+0
| | | | | | | | | glibc doesn't have tkill or tgkill and says "use syscall(3) instead". I've left tgkill since it's quite widely used, but there's no reason to have tkill as well. Bug: 11156955 Change-Id: Ifc0af750320086f829bc9914551c172b501f3b60
* Remove __syslog; we have the public klogctl API.Elliott Hughes2014-05-201-14/+0
| | | | | Bug: 11156955 Change-Id: I5c2cc02f39f76dd32984135f5c12c10bf2853796
* Remove perf_event_open.Elliott Hughes2014-05-201-22/+0
| | | | | | | | | This was accidentally added at a time when you couldn't add a constant to <syscall.h> without generating an assembly stub! (You no longer need to add the constants at all.) Bug: 11156955 Change-Id: I053c17879138787976c744a5ecf7d30ee51dc48f
* Mark sockets on creation (socket()) and accept4().Sreeram Ramachandran2014-05-193-18/+4
| | | | | | Remove the separate syscall for accept() and implement it as accept4(..., 0). Change-Id: Ib0b8f5d7c5013b91eae6bbc3847852eb355c7714
* Hide __signalfd4, used to implement signalfd(3).Elliott Hughes2014-05-161-2/+2
| | | | | Bug: 11156955 Change-Id: I50842279cb5b32ec8bd45193435574e415cd806e
* Mark sockets on accept().Sreeram Ramachandran2014-05-141-2/+2
| | | | | | (cherry picked from commit 58b1f3f6a30a660ad81637c2b50382c3d279243b) Change-Id: I5d09be413cf720fbed905f96313b007997ada76c
* Introduce netd_client, a dynamic library that talks to netd.Sreeram Ramachandran2014-05-131-2/+2
| | | | | | | | | | | The library exists outside bionic. It is dynamically loaded, to replace selected standard socket syscalls with versions that talk to netd. Change connect() to use the library if available. (cherry picked from commit 3a6b627a14df8111b03e452f2df4b5f4938e0e49) Change-Id: Ib6198e19dbc306521a26fcecfdf6e8424d163fc9
* Implement _Exit(3).Elliott Hughes2014-04-081-0/+3
| | | | Change-Id: Ida6ac844cc87d38c9645b197dd8188bb73e27dbe
* Add accept4() syscallAndrei Emeltchenko2014-03-261-0/+14
| | | | | | Add accept4() using SYSCALLS.TXT and gensyscall Change-Id: I6f19f29144186d15d46423e10f2cc4b4223719c6
* Add recvmmsg and sendmmsg syscalls.Guillaume Ranquet2014-02-272-0/+36
| | | | | | | | | Also add the corresponding constant, struct, and function declarations to <sys/socket.h>, and perfunctory tests so we know that the symbols actually exist. Signed-off-by: Guillaume Ranquet <guillaumex.ranquet@intel.com> Change-Id: Ib0d854239d3716be90ad70973c579aff4895a4f7
* Fix build by avoiding the _C_LABEL macro.Elliott Hughes2014-02-182-4/+4
| | | | Change-Id: Ide367c2b65071388bd95fbc81a4ed6ae94aec4e4
* Implement some of the missing LFS64 support.Elliott Hughes2014-02-182-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This gives us: * <dirent.h> struct dirent64 readdir64, readdir64_r, alphasort64, scandir64 * <fcntl.h> creat64, openat64, open64. * <sys/stat.h> struct stat64 fstat64, fstatat64, lstat64, stat64. * <sys/statvfs.h> struct statvfs64 statvfs64, fstatvfs64. * <sys/vfs.h> struct statfs64 statfs64, fstatfs64. This also removes some of the incorrect #define hacks we've had in the past (for stat64, for example, which we promised to clean up way back in bug 8472078). Bug: 11865851 Bug: 8472078 Change-Id: Ia46443521918519f2dfa64d4621027dfd13ac566
* Add fallocate/fallocate64/posix_fallocate/posix_fallocate64.Elliott Hughes2014-02-031-0/+22
| | | | | | Bug: 5287571 Bug: 12612860 Change-Id: I4501b9c6cdf9a830336ce0b3afc4ea716b6a0f6f
* Fix <sys/resource.h>.Elliott Hughes2014-01-091-0/+14
| | | | | | | | | | | | | | | | | | The situation here is a bit confusing. On 64-bit, rlimit and rlimit64 are the same, and so getrlimit/getrlimit64, setrlimit/setrlimit64, and prlimit/prlimit64 are all the same. On 32-bit, rlimit and rlimit64 are different. 32-bit architectures other than MIPS go one step further by having an even more limited getrlimit system call, so arm and x86 need to use ugetrlimit instead of getrlimit. Worse, the 32-bit architectures don't have 64-bit getrlimit- and setrlimit-equivalent system calls, and you have to use prlimit64 instead. There's no 32-bit prlimit system call, so there's no easy implementation of that --- what should we do if the result of prlimit64 won't fit in a struct rlimit? Since 32-bit survived without prlimit/prlimit64 for this long, I'm not going to bother implementing prlimit for 32-bit. We need the rlimit64 functions to be able to build strace 4.8 out of the box. Change-Id: I1903d913b23016a2fc3b9f452885ac730d71e001
* Clean up <sched.h>.Elliott Hughes2014-01-021-0/+14
| | | | | | | | This patch switches to using the uapi constants. It also adds the missing setns system call, fixes sched_getcpu's error behavior, and fixes the gensyscalls script now ARM is uapi-only too. Change-Id: I8e16b1693d6d32cd9b8499e46b5d8b0a50bc4f1d
* Add cfi directives to all arm assembly.Christopher Ferris2013-12-0225-22/+174
| | | | | | | | | | | | | | | | | | | | | | Since the ENTRY/END macros now have .cfi_startproc/.cfi_endproc, most of the custom arm assembly has no unwind information. Adding the proper cfi directives for these and removing the arm directives. Update the gensyscalls.py script to add these cfi directives for the generated assembly. Also fix the references to non-uapi headers to the proper uapi header. In addition, remove the kill.S, tkill.S, tgkill.S for arm since they are not needed at all. The unwinder (libunwind) is able to properly unwind using the normal abort. After this change, I can unwind through the system calls again. Bug: 11559337 Bug: 11825869 Bug: 11321283 Change-Id: I18b48089ef2d000a67913ce6febc6544bbe934a3
* Clean up forking and cloning.Elliott Hughes2013-11-191-17/+0
| | | | | | | | | The kernel now maintains the pthread_internal_t::tid field for us, and __clone was only used in one place so let's inline it so we don't have to leave such a dangerous function lying around. Also rename files to match their content and remove some useless #includes. Change-Id: I24299fb4a940e394de75f864ee36fdabbd9438f9
* Fix pthread_join.Elliott Hughes2013-11-181-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | Let the kernel keep pthread_internal_t::tid updated, including across forks and for the main thread. This then lets us fix pthread_join to only return after the thread has really exited. Also fix the thread attributes of the main thread so we don't unmap the main thread's stack (which is really owned by the dynamic linker and contains things like environment variables), which fixes crashes when joining with an exited main thread and also fixes problems reported publicly with accessing environment variables after the main thread exits (for which I've added a new unit test). In passing I also fixed a bug where if the clone(2) inside pthread_create(3) fails, we'd unmap the child's stack and TLS (which contains the mutex) and then try to unlock the mutex. Boom! It wasn't until after I'd uploaded the fix for this that I came across a new public bug reporting this exact failure. Bug: 8206355 Bug: 11693195 Bug: https://code.google.com/p/android/issues/detail?id=57421 Bug: https://code.google.com/p/android/issues/detail?id=62392 Change-Id: I2af9cf6e8ae510a67256ad93cad891794ed0580b
* Stop using the non-uapi <linux/err.h> header file.Elliott Hughes2013-11-07191-573/+191
| | | | | | | We only need it for MAX_ERRNO, and it's time we had somewhere to put the little assembler utility macros we've been putting off writing. Change-Id: I9354d2e0dc47c689296a34b5b229fc9ba75f1a83
* Clean up the 32-bit kernel support, fix LP64 fcntl declaration.Elliott Hughes2013-11-061-16/+0
| | | | | | | | | | | | | | In practice, thanks to all the registers the stubs don't actually change, but it's confusing to have an incorrect declaration. I suspect that fcntl remains broken for aarch64; it happens to work for x86_64 because the first vararg argument gets placed in the right register anyway, but I have no reason to believe that's true for aarch64. This patch adds a unit test, though, so we'll be able to tell when we get as far as running the unit tests. Change-Id: I58dd0054fe99d7d51d04c22781d8965dff1afbf3
* Fix the exit syscall stub's name.Elliott Hughes2013-10-241-2/+2
| | | | | | | | | | | | | I've left the exit_group syscall as _exit because otherwise we'd have to convince the compiler that our _exit (which just calls __exit_group) is actually "noreturn", and it seems like that would be less clean than just cutting out the middleman. We'll just have to trust ourselves not to add anything to SYSCALLS.TXT that ought to be private but that only has a single leading underscore. Hopefully we can manage that. Change-Id: Iac47faea9f516186e1774381846c54cafabc4354
* Remove dependencies on obsolete __ARCH_WANT_SYSCALL_DEPRECATED system calls.Elliott Hughes2013-10-247-63/+21
| | | | | | (aarch64 kernels don't have these system calls.) Change-Id: I6f64075aa412f71520f2df71c3d69b647f91c1ca