Commit graph

5685 commits

Author SHA1 Message Date
Elliott Hughes
c5999c1e03 Merge "Clean up SEEK_SET definitions." 2015-02-03 01:21:17 +00:00
Nick Kralevich
d80ec66121 Merge "Add fchmodat(AT_SYMLINK_NOFOLLOW) and fchmod O_PATH support" 2015-02-02 22:03:41 +00:00
Elliott Hughes
1ed337dbdf Clean up SEEK_SET definitions.
If we lose the #ifndef, the compiler will tell us if the definitions
of SEEK_SET and friends ever get out of sync.

Change-Id: I357cabec7c9cd451c604342344f210bba20fb6bc
2015-02-02 14:02:09 -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
Elliott Hughes
42084a2653 Small logging cleanup.
Don't send the trailing NUL bytes to the logger, call strlen if we already
know the length, or cast more specifically than we need to.

Change-Id: I68c9388a22bddea49120a1022dda8db8991360c1
2015-02-02 12:24:46 -08:00
Elliott Hughes
7f0f30c6e2 Merge "Fix clang build." 2015-02-02 18:23:28 +00:00
Elliott Hughes
30fbf5f44c Fix clang build.
Change-Id: I863137b5d35602267b4ef3a74399cf394c9994d6
2015-02-02 10:21:39 -08:00
Neil Fuller
d514d9bbae Merge "Fixes to the update-tzdata.py tool" 2015-02-02 17:52:48 +00:00
Neil Fuller
0662c3e5b3 Fixes to the update-tzdata.py tool
We build one too many times. Creating a missing directory
is sufficient.

The tz2icu needs some files in the CWD. Added symlinks.

Bug: 19230091
Change-Id: I58f9817af68b229f48139e56503f50a2b6dbb4fe
2015-02-02 17:42:41 +00:00
Elliott Hughes
4674e3899a Fortify poll and ppoll.
And remove the test for FD_ZERO fortification, which never made much
sense anyway.

Change-Id: Id1009c5298d461fa4722189e8ecaf22f0c529536
2015-02-02 09:15:19 -08:00
Elliott Hughes
cb0e70389e Include <malloc.h> for struct mallinfo.
GCC doesn't seem to care, but clang does.

Change-Id: I9884820339a9e6f142862928c357f1a538184ae0
2015-01-30 20:33:31 -08:00
Elliott Hughes
09c3382433 Merge "Break two incorrect transitive includes." 2015-01-31 04:18:10 +00:00
Dan Albert
94335cc8e2 Merge "Put back inline definitions if using an old API." 2015-01-30 17:18:49 +00:00
Elliott Hughes
4dcfccff8d Remove unused CONFIG_SECONDS.
Bug: https://code.google.com/p/android/issues/detail?id=65951
Change-Id: I8ae7057c68e16618de6dd06cf052426c6cad8a3d
2015-01-29 21:47:37 -08:00
Elliott Hughes
5038b19cef Break two incorrect transitive includes.
Change-Id: I95519caa5258cf5c6b8053f1c7e08ade2a824e49
2015-01-29 20:12:13 -08:00
Dan Albert
466dbe4444 Put back inline definitions if using an old API.
All these inlines were turned in to out of line definitions in L.
This brings us a step closer to being able to just use the current
bionic headers for the NDK, rather than having many old versions of
them.

Change-Id: Ie010bc727d78d3742abc577c70f6578db2e68625
2015-01-29 17:30:40 -08:00
Dan Albert
cd1959b0c5 Merge "Add primitive CPPLINT.cfg." 2015-01-29 21:54:55 +00:00
Dan Albert
6ac4dd8ba9 Add primitive CPPLINT.cfg.
We'll add more things to this as we discover other warnings we don't
care about.

Change-Id: I408f688827cab0f74e055d8f1778069163663f0b
2015-01-29 11:41:59 -08:00
Yabin Cui
6a3ff01cd4 Rewrite __cxa_guard.cpp with <stdatomic.h>.
Bug: 19180923
Change-Id: If4912d01db43c72ef12f4b04270ddb5d76d09462
2015-01-29 11:19:15 -08:00
Elliott Hughes
05fc1d7050 Add missing includes.
Change-Id: Ibf549266a19a67eb9158d341a69dddfb654be669
2015-01-28 19:23:11 -08:00
Elliott Hughes
a9c3d0569f Merge "Modify MIPS64 stat structure to match a generic one in AOSP." 2015-01-29 01:31:59 +00:00
Raghu Gandham
86d2feef9f Modify MIPS64 stat structure to match a generic one in AOSP.
The kernel version of the stat structure is used during the syscalls. After the syscall,
the kernel stat structure is converted to match the generic one. Eventually we would like
the generic stat structure and related syscalls be added to MIPS64 kernel, removing the
thunks added to AOSP.

Change-Id: I7764e80278c1cc8254754c3531ec2dda7544a8ec
2015-01-28 16:12:17 -08:00
Yabin Cui
80e6d6d825 Switch pthread_once_t to stdatomic.h.
Bug: 17574610

Change-Id: I653f2aa4b5b38dbdaffe4a6c3deccfe6ad3b0e74
2015-01-27 19:49:12 -08:00
Elliott Hughes
e6099098a5 Fix mips build.
Move various mips-only things into the arch-mips directory. As soon as mips
writes assembler replacements, we can remove these.

Change-Id: Ia7308559bc361f5c8df3e1d456b381865e060b93
2015-01-27 11:09:27 -08:00
Elliott Hughes
192e169a40 Merge "x86 has an assembler bcopy implementation." 2015-01-27 05:46:56 +00:00
Elliott Hughes
1edfd9e36a x86 has an assembler bcopy implementation.
Change-Id: I4ed7af3c5b104f86550120401f773150c460f37b
2015-01-26 21:45:56 -08:00
Elliott Hughes
643a9be82e Merge "[Arm64] Fix overlapping fp fields in jmp_buf" 2015-01-27 04:56:20 +00:00
Elliott Hughes
5c7964c5f1 Merge "Clean up <stdlib.h> slightly." 2015-01-27 04:49:07 +00:00
Lorenzo Colitti
f2d02c38fb Merge "Make bionic compile even if resolver debugging is enabled." 2015-01-27 04:02:42 +00:00
Duane Sand
dbaab26021 [Arm64] Fix overlapping fp fields in jmp_buf
Change-Id: I9be9f118108f3f6e2bb02a5b01e0420fbfd15d85
2015-01-26 16:20:05 -08:00
Elliott Hughes
76f8916b90 Clean up <stdlib.h> slightly.
Interestingly, this mostly involves cleaning up our implementation of
various <string.h> functions.

Change-Id: Ifaef49b5cb997134f7bc0cc31bdac844bdb9e089
2015-01-26 14:28:41 -08:00
Christopher Ferris
419ed122aa Merge "Update kernel headers to v3.18.3." 2015-01-26 21:27:52 +00:00
Elliott Hughes
247cfe0382 Merge "Add <error.h>." 2015-01-26 20:38:46 +00:00
Elliott Hughes
b8a8cf0d1a Add <error.h>.
Bug: https://code.google.com/p/android/issues/detail?id=79170
Change-Id: Id91765fac45124545e2674a5b2c814707c1a448b
2015-01-26 11:57:11 -08:00
Christopher Ferris
82d7504cd7 Update kernel headers to v3.18.3.
Bug: 19127803
Change-Id: I67fa0832322ddd0032d909476047578be052bcf2
2015-01-26 10:57:07 -08:00
Lorenzo Colitti
616344d169 Make bionic compile even if resolver debugging is enabled.
The code now compiles with all combinations of DEBUG and
DEBUG_DATA except DEBUG_DATA=1, DEBUG=0, which is unsupported.

Change-Id: I9035a65c649df73092f1fc0864ae1cdd9a14aa3b
2015-01-26 16:05:27 +09:00
Dan Albert
6eb5dc1d9c Merge "Fix coverage build after adding clang coverage." 2015-01-25 22:51:37 +00:00
Dan Albert
6e9e6ad3bf Fix coverage build after adding clang coverage.
Static libraries are painful. Details are in the comment. I'll try to
get prebuilts in to the tree so I can fix this on Monday. Until then,
this isn't actually a regression because we've not had coverage
available for this library until now anyway.

Bug: 17574078
Change-Id: I7505c8a94007203e15a6cf192caa06004849d7d9
2015-01-25 14:27:51 -08:00
Elliott Hughes
c5dc02a91e Reduce <stdlib.h> namespace pollution.
<stdlib.h> shouldn't drag in all of <string.h>.

Change-Id: I949172f7ff17e329e411e5054e50f79c13775444
2015-01-24 15:22:57 -08:00
Elliott Hughes
6466292a7e Reduce <signal.h> namespace pollution.
<signal.h> shouldn't drag in all of <string.h>.

Change-Id: I57aea36dad5e89ea2f9541c35594ca6225e532be
2015-01-24 14:18:16 -08:00
Elliott Hughes
6e15edcca5 Merge "Say "Bad file descriptor" rather than "Bad file number"." 2015-01-24 22:08:20 +00:00
Elliott Hughes
d309877eee Say "Bad file descriptor" rather than "Bad file number".
This text is actually in POSIX (though it's not mandatory) and it's what glibc
says. Who says "file number" anyway?

Change-Id: Icc91ac24587c2bc692e0b97c19d32ac1bdda4ea7
2015-01-24 13:38:57 -08:00
Elliott Hughes
e6bb5a2776 Fix optimized fread.
gcov does writes after reads on the same stream, but the bulk read optimization
was clobbering the FILE _flags, causing fwrite to fail.

Bug: 19129055
Change-Id: I9650cb7de4bb173a706b502406266ed0d2b654d7
2015-01-24 12:35:41 -08:00
Dan Albert
ab58559a9c Merge "Add a basic NDK compatibility library." 2015-01-23 00:46:54 +00:00
Elliott Hughes
c56af08c21 Use a more specific return type for app_id_from_name.
I suspect we can simplify this code, but I don't know enough about it
to get involved now.

Change-Id: I1c39761ae31beb70d41ffa6f0e396a4f17529d46
2015-01-22 11:02:59 -08:00
Dan Albert
9c3fd59b00 Add a basic NDK compatibility library.
We know we can safely statically link `libm`, since it doesn't have
any dependencies on the OS or the layout of a data type that has
changed between releases (like `pthread_t`).

We can safely statically link `libc_syscalls` because the user can
check for and handle `ENOSYS`.

Update `ndk_missing_symbols.py` to account for symbols that are in the
compatibility library.

Improve `symbols.py` to be able to pull symbols from a static library.

Change-Id: Ifb0ede1e8b4a8f0f33865d9fed72fb8b4d443fbc
2015-01-21 18:12:15 -08:00
Elliott Hughes
d1668a71df Merge "Turn on -Wold-style-cast and fix the errors." 2015-01-22 01:52:06 +00:00
Dan Albert
4f11c59b3f Merge "Add ndk_missing_symbols.py." 2015-01-22 01:25:57 +00:00
Elliott Hughes
8b5df3920f Turn on -Wold-style-cast and fix the errors.
A couple of dodgy cases where we cast away const, but otherwise pretty boring.

Change-Id: Ibc39ebd525377792b5911464be842121c20f03b9
2015-01-21 17:09:58 -08:00
Dan Albert
169eb66451 Add ndk_missing_symbols.py.
ndk_missing_symbols.py pulls libc.so and libm.so off a running device
or emulator and shows the list of symbols that are in the current
bionic that aren't available on the target.

Change-Id: Ia92c315a6a0ce2e5c33db0b62c8fab41c08a4c31
2015-01-21 17:09:50 -08:00