Commit graph

173 commits

Author SHA1 Message Date
Yuanyuan Zhong
9d150dd9a0 bionic: arm64: generic: strcmp: align to 64B cache line
Align strcmp to 64B. This will ensure the preformance critical
loop is within one 64B cache line.

Change-Id: I88eef2f12b2a6442cacec9cdbdffbf17293e7d32
Signed-off-by: Yuanyuan Zhong <zyy@motorola.com>
Reviewed-on: https://gerrit.mot.com/902536
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver <sltawvr@motorola.com>
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Yi-Wei Zhao <gbjc64@motorola.com>
Reviewed-by: Igor Kovalenko <igork@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
2017-03-20 17:54:29 +00:00
Jake Weinstein
372f19e9e2 libc: ARM64: update memset/strlen/memcpy/memmove to newlib/cortex-strings
* Bionic benchmarks results at the bottom

* This is a squash of the following commits:

libc: ARM64: optimize memset.

 This is an optimized memset for AArch64.  Memset is split into 4 main
 cases: small sets of up to 16 bytes, medium of 16..96 bytes which are
 fully unrolled.  Large memsets of more than 96 bytes align the
 destination and use an unrolled loop processing 64 bytes per
 iteration.  Memsets of zero of more than 256 use the dc zva
 instruction, and there are faster versions for the common ZVA sizes 64
 or 128.  STP of Q registers is used to reduce codesize without loss of
 performance.

Change-Id: I0c5b5ec5ab8a1fd0f23eee8fbacada0be08e841f

libc: ARM64: improve performance in strlen

Change-Id: Ic20f93a0052a49bd76cd6795f51e8606ccfbf11c

libc: ARM64: Optimize memcpy.

 This is an optimized memcpy for AArch64.  Copies are split into 3 main
 cases: small copies of up to 16 bytes, medium copies of 17..96 bytes
 which are fully unrolled.  Large copies of more than 96 bytes align
 the destination and use an unrolled loop processing 64 bytes per
 iteration.  In order to share code with memmove, small and medium
 copies read all data before writing, allowing any kind of overlap.  On
 a random copy test memcpy is 40.8% faster on A57 and 28.4% on A53.

Change-Id: Ibb9483e45bbc0e8ca3d5ce98a31c55dfd8a5ac28

libc: AArch64: Tune memcpy

* Further tuning for performance.

Change-Id: Id08eaab885f9743fa7575077924a947c1b88e4ff

libc: ARM64: optimize memmove for Cortex-A53

* Sadly does not work on Denver or Kryo, so can't go to generic

 This is an optimized memmove for AArch64.  All copies of up to 96
 bytes and all backward copies are done by the new memcpy.  The only
 remaining case is large forward copies which are done in the same way
 as the memcpy loop, but copying from the end rather than the start.

Tested on the Nextbit Robin with MSM8992 (Snapdragon 808):

Before
BM_string_memcmp/8                          1000k         27    0.286 GiB/s
BM_string_memcmp/64                           50M         20    3.053 GiB/s
BM_string_memcmp/512                          20M        126    4.060 GiB/s
BM_string_memcmp/1024                         10M        234    4.372 GiB/s
BM_string_memcmp/8Ki                        1000k       1726    4.745 GiB/s
BM_string_memcmp/16Ki                        500k       3711    4.415 GiB/s
BM_string_memcmp/32Ki                        200k       8276    3.959 GiB/s
BM_string_memcmp/64Ki                        100k      16351    4.008 GiB/s
BM_string_memcpy/8                          1000k         13    0.612 GiB/s
BM_string_memcpy/64                         1000k          8    7.187 GiB/s
BM_string_memcpy/512                          50M         38   13.311 GiB/s
BM_string_memcpy/1024                         20M         86   11.858 GiB/s
BM_string_memcpy/8Ki                           5M        620   13.203 GiB/s
BM_string_memcpy/16Ki                       1000k       1265   12.950 GiB/s
BM_string_memcpy/32Ki                        500k       2977   11.004 GiB/s
BM_string_memcpy/64Ki                        500k       8003    8.188 GiB/s
BM_string_memmove/8                         1000k         11    0.684 GiB/s
BM_string_memmove/64                        1000k         16    3.855 GiB/s
BM_string_memmove/512                         50M         57    8.915 GiB/s
BM_string_memmove/1024                        20M        117    8.720 GiB/s
BM_string_memmove/8Ki                          2M        853    9.594 GiB/s
BM_string_memmove/16Ki                      1000k       1731    9.462 GiB/s
BM_string_memmove/32Ki                       500k       3566    9.189 GiB/s
BM_string_memmove/64Ki                       500k       7708    8.501 GiB/s
BM_string_memset/8                          1000k         16    0.487 GiB/s
BM_string_memset/64                         1000k         16    3.995 GiB/s
BM_string_memset/512                          50M         37   13.489 GiB/s
BM_string_memset/1024                         50M         58   17.405 GiB/s
BM_string_memset/8Ki                           5M        451   18.160 GiB/s
BM_string_memset/16Ki                          2M        883   18.554 GiB/s
BM_string_memset/32Ki                       1000k       2181   15.022 GiB/s
BM_string_memset/64Ki                        500k       4563   14.362 GiB/s
BM_string_strlen/8                          1000k          8    0.965 GiB/s
BM_string_strlen/64                         1000k         16    3.855 GiB/s
BM_string_strlen/512                          20M         92    5.540 GiB/s
BM_string_strlen/1024                         10M        167    6.111 GiB/s
BM_string_strlen/8Ki                        1000k       1237    6.620 GiB/s
BM_string_strlen/16Ki                       1000k       2765    5.923 GiB/s
BM_string_strlen/32Ki                        500k       6135    5.341 GiB/s
BM_string_strlen/64Ki                        200k      13168    4.977 GiB/s

After
BM_string_memcmp/8                          1000k         21    0.369 GiB/s
BM_string_memcmp/64                         1000k         28    2.272 GiB/s
BM_string_memcmp/512                          20M        128    3.983 GiB/s
BM_string_memcmp/1024                         10M        234    4.375 GiB/s
BM_string_memcmp/8Ki                        1000k       1732    4.728 GiB/s
BM_string_memcmp/16Ki                        500k       3485    4.701 GiB/s
BM_string_memcmp/32Ki                        500k       7031    4.660 GiB/s
BM_string_memcmp/64Ki                        200k      14296    4.584 GiB/s
BM_string_memcpy/8                          1000k          5    1.458 GiB/s
BM_string_memcpy/64                         1000k          7    8.952 GiB/s
BM_string_memcpy/512                          50M         36   13.907 GiB/s
BM_string_memcpy/1024                         20M         80   12.750 GiB/s
BM_string_memcpy/8Ki                           5M        572   14.307 GiB/s
BM_string_memcpy/16Ki                       1000k       1165   14.053 GiB/s
BM_string_memcpy/32Ki                        500k       3141   10.430 GiB/s
BM_string_memcpy/64Ki                        500k       7008    9.351 GiB/s
BM_string_memmove/8                           50M          7    1.074 GiB/s
BM_string_memmove/64                        1000k          9    6.593 GiB/s
BM_string_memmove/512                         50M         37   13.502 GiB/s
BM_string_memmove/1024                        20M         80   12.656 GiB/s
BM_string_memmove/8Ki                          5M        573   14.281 GiB/s
BM_string_memmove/16Ki                      1000k       1168   14.018 GiB/s
BM_string_memmove/32Ki                      1000k       2825   11.599 GiB/s
BM_string_memmove/64Ki                       500k       6548   10.008 GiB/s
BM_string_memset/8                          1000k          7    1.038 GiB/s
BM_string_memset/64                         1000k          8    7.151 GiB/s
BM_string_memset/512                        1000k         29   17.272 GiB/s
BM_string_memset/1024                         50M         53   18.969 GiB/s
BM_string_memset/8Ki                           5M        424   19.300 GiB/s
BM_string_memset/16Ki                          2M        846   19.350 GiB/s
BM_string_memset/32Ki                       1000k       2028   16.156 GiB/s
BM_string_memset/64Ki                        500k       4514   14.517 GiB/s
BM_string_strlen/8                          1000k          7    1.120 GiB/s
BM_string_strlen/64                         1000k         16    3.918 GiB/s
BM_string_strlen/512                          50M         64    7.894 GiB/s
BM_string_strlen/1024                         20M        104    9.815 GiB/s
BM_string_strlen/8Ki                           5M        664   12.337 GiB/s
BM_string_strlen/16Ki                       1000k       1291   12.682 GiB/s
BM_string_strlen/32Ki                       1000k       2940   11.143 GiB/s
BM_string_strlen/64Ki                        500k       6440   10.175 GiB/s

Change-Id: I635bd2798a755256f748b2af19b1a56fb85a40c6
2016-11-28 19:35:12 +00:00
Elliott Hughes
beb8796624 Use ENTRY_PRIVATE in __bionic_clone assembler.
Bug: N/A
Test: bionic tests
Change-Id: Ic651d628be009487a36d0b2e5bcf900b981b1ef9
2016-10-26 17:01:58 -07:00
Colin Cross
7510c33b61 Remove deprecated Android.mk files
These directories all have Android.bp files that are always used now,
delete the Android.mk files.

Change-Id: Ib0ba2d28bff88483b505426ba61606da314e03ab
2016-05-26 16:41:57 -07:00
Elliott Hughes
eafad49bd6 Add <sys/quota.h>.
It turns out that at least the Nexus 9 kernel is built without CONFIG_QUOTA.
If we decide we're going to mandate quota functionality, I'm happy for us to
be a part of CTS that ensures that happens, but I don't want to be first, so
there's not much to test here other than "will it compile?". The strace
output looks right though.

Bug: http://b/27948821
Bug: http://b/27952303
Change-Id: If667195eee849ed17c8fa9110f6b02907fc8fc04
2016-04-06 11:06:09 -07:00
Elliott Hughes
7f72ad4d6c Add sync_file_range to <fcntl.h>.
Bug: http://b/27952303
Change-Id: Idadfacd657ed415abc11684b9471e4e24c2fbf05
2016-04-05 12:17:22 -07:00
Elliott Hughes
afe835d540 Move math headers in with the other headers.
Keeping them separate is a pain for the NDK, and doesn't help the platform.

Change-Id: I96b8beef307d4a956e9c0a899ad9315adc502582
2016-04-02 08:36:33 -07:00
Greg Hackmann
e2faf07d65 Add {get,set}domainname(2)
{get,set}domainname aren't in POSIX but are widely-implemented
extensions.

The Linux kernel provides a setdomainname syscall but not a symmetric
getdomainname syscall, since it expects userspace to get the domain name
from uname(2).

Change-Id: I96726c242f4bb646c130b361688328b0b97269a0
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-25 14:16:58 -07:00
Josh Gao
0c3655a864 Add a checksum to jmp_buf on AArch64.
Bug: http://b/27417786
Change-Id: I17c22dc28a46dd6b678b449b506b0da978f3793e
2016-03-03 12:45:08 -08:00
Elliott Hughes
784609317d Mandate optimized __memset_chk for arm and arm64.
This involves actually implementing assembler __memset_chk for arm64,
but that's easily done.

Obviously I'd like this for all architectures (and all the string functions),
but this is low-hanging fruit...

Change-Id: I70ec48c91aafd1f0feb974a2555c51611de9ef82
2016-03-02 11:58:41 -08:00
Elliott Hughes
3c6016f04a Improve diagnostics from the assembler __memcpy_chk routines.
Change-Id: Iec16c92ed80beee505cba2121ea33e3550197b02
2016-03-01 14:45:58 -08:00
Elliott Hughes
b83d6747fa Improve FORTIFY failure diagnostics.
Our FORTIFY _chk functions' implementations were very repetitive and verbose
but not very helpful. We'd also screwed up and put the SSIZE_MAX checks where
they would never fire unless you actually had a buffer as large as half your
address space, which probably doesn't happen very often.

Factor out the duplication and take the opportunity to actually show details
like how big the overrun buffer was, or by how much it was overrun.

Also remove the obsolete FORTIFY event logging.

Also remove the unused __libc_fatal_no_abort.

This change doesn't improve the diagnostics from the optimized assembler
implementations.

Change-Id: I176a90701395404d50975b547a00bd2c654e1252
2016-02-26 22:06:17 -08:00
Elliott Hughes
5f26c6bc91 Really add adjtimex(2), and add clock_adjtime(2) too.
Change-Id: I81fde2ec9fdf787bb19a784ad13df92d33a4f852
2016-02-03 13:19:10 -08:00
Greg Hackmann
3f3f6c526b Add adjtimex
Change-Id: Ia92d35b1851e73c9f157a749dba1e98f68309a8d
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-01-28 13:41:22 -08:00
Elliott Hughes
42d949ff9d Defend against -fstack-protector in libc startup.
Exactly which functions get a stack protector is up to the compiler, so
let's separate the code that sets up the environment stack protection
requires and explicitly build it with -fno-stack-protector.

Bug: http://b/26276517
Change-Id: I8719e23ead1f1e81715c32c1335da868f68369b5
2016-01-06 20:06:08 -08:00
Daniel Micay
4200e260d2 fix the mremap signature
The mremap definition was incorrect (unsigned long instead of int) and
it was missing the optional new_address parameter.

Change-Id: Ib9d0675aaa098c21617cedc9b2b8cf267be3aec4
2015-11-06 13:14:43 -08:00
Dan Willemsen
268a673bd1 Switch to LOCAL_SRC_FILES_EXCLUDE
This moves the generic arm/arm64/x86 settings into the main makefiles
and makes the rest of them derivatives. This better aligns with how
soong handles arch/cpu variants.

Also updates the Android.bp to make it consistent with the make
versions.

Change-Id: I5a0275d992bc657459eb6fe1697ad2336731d122
2015-10-20 11:58:28 -07:00
Josh Gao
54db0df8d6 Implement setjmp cookies on AArch64.
Bug: http://b/23942752
Change-Id: I81408ef0dd53010140b51e3083d357d3f2961112
2015-09-17 14:07:24 -07:00
Elliott Hughes
6f4594d5dc Add preadv/pwritev.
Bug: http://b/12612572
Change-Id: I38ff2684d69bd0fe3f21b1d371b88fa60d5421cb
2015-08-26 14:48:55 -07:00
Jake Weinstein
2926f9a31e libc: remove bcopy from memmove on 64-bit architectures
* bcopy is deprecated on LP64 by the following commit:

  ce9ce28e5d

Change-Id: I6849916f0ec4a2d0db9a360999ad1dc8edda952b
2015-08-17 22:06:12 +00:00
Elliott Hughes
5891abdc66 Invalidate cached pid in vfork.
Bug: http://b/23008979
Change-Id: I1dd900ac988cdbe10aad3abc53240c5d352891d5
2015-08-07 19:44:12 -07:00
Tim Murray
9876aa273d Merge "Add support for cortex-a53 in bionic." 2015-06-16 19:04:14 +00:00
Tim Murray
a73b2c961f Add support for cortex-a53 in bionic.
allows -mcpu=cortex-a53 to be passed as part of a command line.

Change-Id: Id4203a9fd197f4c3b661bad21ac58c32819fd687
2015-06-15 21:43:30 -07:00
Elliott Hughes
b1304935b6 Hide accidentally-exposed __clock_nanosleep.
Bug: http://b/21858067
Change-Id: Iaa83a5e17cfff796aed4f641d0d14427614d9399
2015-06-15 19:39:04 -07:00
Elliott Hughes
be57a40d29 Add process_vm_readv and process_vm_writev.
Bug: http://b/21761353
Change-Id: Ic8ef3f241d62d2a4271fbc783c8af50257bac498
2015-06-10 17:24:20 -07:00
Nick Kralevich
e1d0810cd7 Add O_PATH support for flistxattr()
A continuation of commit 2825f10b7f.

Add O_PATH compatibility support for flistxattr(). This allows
a process to list out all the extended attributes associated with
O_PATH file descriptors.

Change-Id: Ie2285ac7ad2e4eac427ddba6c2d182d41b130f75
2015-06-06 11:25:41 -07:00
Nick Kralevich
2825f10b7f libc: Add O_PATH support for fgetxattr / fsetxattr
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

Change-Id: Ic0cdf9f9dd0e35a63b44a4c4a08400020041eddf
2015-06-01 15:51:56 -07:00
Yabin Cui
40a8f214a5 Hide rt_sigqueueinfo.
Bug: 19358804
Change-Id: I38a53ad64c81d0eefdd1d24599e769fd8a477a56
2015-05-18 11:29:20 -07:00
Chih-Hung Hsieh
33f33515b5 Use unified syntax to compile with both llvm and gcc.
All arch-arm and arch-arm64 .S files were compiled
by gcc with and without this patch. The output object files
were identical. When compiled with llvm and this patch,
the output files were also identical to gcc's output.

BUG: 18061004
Change-Id: I458914d512ddf5496e4eb3d288bf032cd526d32b
2015-05-11 17:15:03 -07:00
Dan Albert
7c2c01d681 Revert "Fix volantis boot."
Bug: http://b/20065774
This reverts commit 76e1cbca75.
2015-05-07 15:12:24 -07:00
Dan Albert
6f0d7005f9 Revert "Fix clang build."
Bug: http://b/20065774
This reverts commit 0975a5d9d2.
2015-05-07 15:12:16 -07:00
Dan Albert
f920f821e2 Revert "Try again to fix clang build."
Bug: http://b/20065774
This reverts commit dffd3c5838.

Change-Id: I5dd095ff4ab133baa2afcbd4c79fbee55d05c459
2015-05-07 15:11:48 -07:00
Dmitriy Ivanov
ea295f68f1 Unregister pthread_atfork handlers on dlclose()
Bug: http://b/20339788
Change-Id: I874c87faa377645fa9e0752f4fc166d81fd9ef7e
2015-04-24 17:57:37 -07:00
Dimitry Ivanov
6c63ee41ac Merge "Revert "Unregister pthread_atfork handlers on dlclose()"" 2015-04-24 03:49:30 +00:00
Dimitry Ivanov
094f58fb2a Revert "Unregister pthread_atfork handlers on dlclose()"
The visibility control in pthread_atfork.h is incorrect.
 It breaks 64bit libc.so by hiding pthread_atfork.

 This reverts commit 6df122f852.

Change-Id: I21e4b344d500c6f6de0ccb7420b916c4e233dd34
2015-04-24 03:46:57 +00:00
Elliott Hughes
3da9373fe0 Merge "Simplify close(2) EINTR handling." 2015-04-23 21:14:25 +00:00
Elliott Hughes
3391a9ff13 Simplify close(2) EINTR handling.
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
2015-04-23 08:41:45 -07:00
Dmitriy Ivanov
6df122f852 Unregister pthread_atfork handlers on dlclose()
Change-Id: I326fdf6bb06bed12743f08980b5c69d849c015b8
2015-04-22 19:19:37 -07:00
Elliott Hughes
dffd3c5838 Try again to fix clang build.
I got the condition the wrong way round in the previous change.

Bug: http://b/20065774
Change-Id: I218b224b37f5fb2f7c7ec2f9af27472b340c4b15
2015-04-03 13:37:18 -07:00
Elliott Hughes
0975a5d9d2 Fix clang build.
Apparently clang really doesn't want you to take the address of a builtin.
Since this is only a temporary hack, let's just shrug and accept that
clang-built volantis images won't work until we have new NVIDIA blobs.

Bug: http://b/20065774
Change-Id: I4c8e893b15a1af8f9c54d3f89bfef112b63d09b4
2015-04-03 13:10:04 -07:00
Elliott Hughes
76e1cbca75 Fix volantis boot.
NVIDIA binary blobs are assuming that __cache_clear, _Unwind_Backtrace,
and _Unwind_GetIP are all in some library that they link, but now we've
cleaned up this leakage, they're no longer getting it. Deliberately leak
the symbols from libc.so until we get new blobs.

Bug: http://b/20065774
Change-Id: I92ef07b2bce8d1ad719bf40dab41d745cd6904d4
2015-04-03 12:37:03 -07:00
Christopher Ferris
24958514b9 Use ALIAS_SYMBOL for assembler aliasing.
Change-Id: I8d04d2da0a1ac440cc9044fc819c9a8eda5ff17d
2015-03-25 09:12:00 -07:00
Christopher Ferris
fa5faa0ce6 Make gensyscalls.py use the ALIAS_SYMBOL macro.
Change-Id: Ib94c0abb6fc85126ecc5ed3f1962b2b8b90b9952
2015-03-24 21:08:26 -07:00
Elliott Hughes
fa495d51b0 Hide statfs/fstatfs' ST_VALID flag from userspace.
Spotted while debugging the strace 4.10 upgrade.

Change-Id: I1af1be9c9440151f55f74a835e1df71529b0e4fe
2015-03-18 15:46:48 -07:00
Nick Kralevich
35778253a5 Fix "faccessat ignores flags"
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
2015-02-24 13:40:43 -08:00
Elliott Hughes
41ef902379 Fix memchr overflow.
The overflow's actually in the generic C implementation of memchr.

While I'm here, let's switch our generic memrchr to the OpenBSD version too.

Bug: https://code.google.com/p/android/issues/detail?id=147048
Change-Id: I296ae06a1ee196d2c77c95a22f11ee4d658962da
2015-02-14 13:21:22 -08:00
Colin Cross
da2c0a708e Merge changes Ib87855e8,I4b46ae20,I66364a5c,Id3fcf680
* changes:
  Use LOCAL_LDFLAGS_64 instead of enumerating 64-bit architectures
  Fix typo in cpu variant makefile depenendency for arm64
  Remove libc_static_common_src_files
  Share LP32 makefile settings between arches
2015-02-05 01:57:28 +00:00
Colin Cross
a6b6ed5fe9 Fix typo in cpu variant makefile depenendency for arm64
cpu_variank_mk -> cpu_variant_mk

Change-Id: I4b46ae20de72ed2dc8820d62ac35ddc6b915a195
2015-02-04 17:38:27 -08:00
Nick Kralevich
00490ae3f3 Ensure raw fchmod/fchmodat syscalls are hidden.
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
2015-02-03 12:10:30 -08:00
Nick Kralevich
3cbc6c627f Add fchmodat(AT_SYMLINK_NOFOLLOW) and fchmod O_PATH support
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
2015-02-02 13:17:17 -08:00