Commit graph

82 commits

Author SHA1 Message Date
Nick Kralevich
927d904d52 am 91bc5865: am 8d01c055: am 1271cdc1: Merge "Revert "stack protector: use AT_RANDOM""
* commit '91bc5865a333212e7cac934b0a2ac7c522911d58':
  Revert "stack protector: use AT_RANDOM"
2013-01-16 13:58:04 -08:00
Nick Kralevich
91bc5865a3 am 8d01c055: am 1271cdc1: Merge "Revert "stack protector: use AT_RANDOM""
* commit '8d01c0557bb2b7ea30f4038b6c84b816800073a7':
  Revert "stack protector: use AT_RANDOM"
2013-01-16 13:55:55 -08:00
Nick Kralevich
8d01c0557b am 1271cdc1: Merge "Revert "stack protector: use AT_RANDOM""
* commit '1271cdc1c91c6ae688917bc8f4ae59d2a97b3e99':
  Revert "stack protector: use AT_RANDOM"
2013-01-16 13:53:25 -08:00
Nick Kralevich
bcd18c0485 am 27ff1ae4: am de666485: am ba117e41: Merge "stack protector: use AT_RANDOM"
* commit '27ff1ae414915789b27d0a485ff6d856ae742aad':
  stack protector: use AT_RANDOM
2013-01-16 13:34:46 -08:00
Nick Kralevich
27ff1ae414 am de666485: am ba117e41: Merge "stack protector: use AT_RANDOM"
* commit 'de666485b8123ac35be94109336f7c56a7e9e3c2':
  stack protector: use AT_RANDOM
2013-01-16 13:31:24 -08:00
Nick Kralevich
36bd371e26 Revert "stack protector: use AT_RANDOM"
The AT_RANDOM changes broke setuid / setgid executables
such as "ping". When the linker executes a setuid program,
it cleans the environment, removing any invalid environment
entries, and adding "NULL"s to the end of the environment
array for each removed variable. Later on, we try to determine
the location of the aux environment variable, and get tripped
up by these extra NULLs.

Reverting this patch will get setuid executables working again,
but getauxval() is still broken for setuid programs because of
this bug.

This reverts commit e3a49a8661.

Change-Id: I05c58a896b1fe32cfb5d95d43b096045cda0aa4a
2013-01-16 13:16:42 -08:00
Nick Kralevich
de666485b8 am ba117e41: Merge "stack protector: use AT_RANDOM"
* commit 'ba117e4172fe6f160bf5f4d58b37e12c08c34245':
  stack protector: use AT_RANDOM
2013-01-16 11:31:00 -08:00
Elliott Hughes
b989c9ceda Revert "DO NOT MERGE Revert "Add the libcutils localtime_tz and mktime_t extensions to bionic.""
This reverts commit f4b34b6c39.
2013-01-16 10:34:33 -08:00
Nick Kralevich
e3a49a8661 stack protector: use AT_RANDOM
Populate the stack canaries from the kernel supplied
AT_RANDOM value, which doesn't involve any system calls.
This is slightly faster (6 fewer syscalls) and avoids
unnecessarily reading /dev/urandom, which depletes entropy.

Bug: 7959813

Change-Id: If2b43100a2a9929666df3de56b6139fed969e0f1
2013-01-16 10:09:52 -08:00
Elliott Hughes
acb907fb0d Revert "DO NOT MERGE Revert "Add the libcutils localtime_tz and mktime_t extensions to bionic.""
This reverts commit f4b34b6c39.

The revert was only meant to apply to the jb-mr1 branch, but accidentally
leaked out into AOSP. This revert-revert gets AOSP master and internal
master back in sync.
2013-01-15 11:12:18 -08:00
Nick Kralevich
8ffe08c86b am fdd6dfa8: am 2c5153b0: libc: add getauxval()
* commit 'fdd6dfa863ea73251b5d59990e239854c31ecee3':
  libc: add getauxval()
2013-01-11 17:04:04 -08:00
Nick Kralevich
2c5153b043 libc: add getauxval()
Add support for getauxval().  This method allows a program an easy way
to retrieve information from the kernel auxiliary vector, and will
hopefully replace other clumsy ways of accessing this same information.

This particular function was also added to glibc in glibc 2.16.
See the following URLs for more details.

  * http://lwn.net/Articles/519085/
  * http://www.gnu.org/software/libc/manual/html_node/Auxiliary-Vector.html

This change is a prerequisite for bug 7959813.

Bug: http://code.google.com/p/android/issues/detail?id=38441
Change-Id: Iba19d899df334bddc6f4899077ece2fc87564ea8
2013-01-11 16:44:15 -08:00
Elliott Hughes
73dd37d8fe am 34c7a3c2: am 0d3700d9: Merge "Only have one copy of the kernel_sigset_t hack, and add more tests."
* commit '34c7a3c2b0ec50a749e25bd786e670025a6f1c5b':
  Only have one copy of the kernel_sigset_t hack, and add more tests.
2013-01-11 10:54:25 -08:00
Elliott Hughes
c5d028fc91 Only have one copy of the kernel_sigset_t hack, and add more tests.
Change-Id: I377522fcba6fb4b5fd2754ab15b091014bd7c16f
2013-01-10 14:42:14 -08:00
Nick Kralevich
1c88362021 am 8717c3db: am 7a34ed2b: Merge "clean up FORTIFY_SOURCE handling."
* commit '8717c3db2f864226bb68c7e26ad73fcff1212b31':
  clean up FORTIFY_SOURCE handling.
2012-12-05 08:25:37 -08:00
Nick Kralevich
326ea5413d clean up FORTIFY_SOURCE handling.
Avoid duplicating huge chunks of code.

Change-Id: Id6145cdfce781c5ffba2abaaa79681d25a7ab28f
2012-12-04 15:27:30 -08:00
Nick Kralevich
59b8677562 am 4140d90c: am 3acc908c: Merge "FORTIFY_SOURCE: fortify strchr"
* commit '4140d90c60e0a9b5b2f1b8ad3d17e169f7288ae9':
  FORTIFY_SOURCE: fortify strchr
2012-11-30 18:47:06 -08:00
Nick Kralevich
049e58369c FORTIFY_SOURCE: fortify strchr
Detect when strchr reads off the end of a buffer.

Change-Id: I0e952eedcff5c36d646a9c3bc4e1337b959224f2
2012-11-30 15:19:15 -08:00
Robert Greenwalt
6f3222ea42 Add search domain to dns interface data.
This doesn't currently use this info - it's still using the system
property based data-passing.  That change is comming.

bug:6799630
Change-Id: I725463209855447cd04bf1457281f3084fffd692
2012-11-13 11:50:57 -08:00
Elliott Hughes
0f96dd8dcb am df7f24f3: am 7b68e3f7: Merge "Per-thread -fstack-protector guards for x86."
* commit 'df7f24f310ee3ceb1dc9413d59d5a8816eb584ef':
  Per-thread -fstack-protector guards for x86.
2012-10-25 12:23:56 -07:00
Elliott Hughes
df7f24f310 am 7b68e3f7: Merge "Per-thread -fstack-protector guards for x86."
* commit '7b68e3f799d87e84c56687033326924fd8fec84c':
  Per-thread -fstack-protector guards for x86.
2012-10-25 12:22:34 -07:00
Elliott Hughes
ad88a08631 Per-thread -fstack-protector guards for x86.
Based on a pair of patches from Intel:

  https://android-review.googlesource.com/#/c/43909/
  https://android-review.googlesource.com/#/c/44903/

For x86, this patch supports _both_ the global that ARM/MIPS use
and the per-thread TLS entry (%gs:20) that GCC uses by default. This
lets us support binaries built with any x86 toolchain (right now,
the NDK is emitting x86 code that uses the global).

I've also extended the original tests to cover ARM/MIPS too, and
be a little more thorough for x86.

Change-Id: I02f279a80c6b626aecad449771dec91df235ad01
2012-10-25 12:04:03 -07:00
Elliott Hughes
4cdc426207 am 60c7ac26: am d0f2b7e7: Merge "More upstream NetBSD upgrades."
* commit '60c7ac262241588f7942ca068f33d706c8fe5cc4':
  More upstream NetBSD upgrades.
2012-10-23 17:29:47 -07:00
Elliott Hughes
60c7ac2622 am d0f2b7e7: Merge "More upstream NetBSD upgrades."
* commit 'd0f2b7e7e65f19f978c59abcbb522c08e76b1508':
  More upstream NetBSD upgrades.
2012-10-23 17:15:07 -07:00
Elliott Hughes
ab44f52202 More upstream NetBSD upgrades.
Change-Id: Idb781d37de3b05585271d7d258ecffd5ba87d0b8
2012-10-23 16:05:09 -07:00
Elliott Hughes
9eaa953642 am 06abe13c: am a2f596b6: Merge "Make dlerror(3) thread-safe."
* commit '06abe13c5f7a318eef316268d0d25d92ff128c19':
  Make dlerror(3) thread-safe.
2012-10-17 11:05:19 -07:00
Elliott Hughes
06abe13c5f am a2f596b6: Merge "Make dlerror(3) thread-safe."
* commit 'a2f596b65075db7916ffffa2f5059e7953719578':
  Make dlerror(3) thread-safe.
2012-10-17 11:03:12 -07:00
Elliott Hughes
5419b94747 Make dlerror(3) thread-safe.
I gave up trying to use the usual thread-local buffer idiom; calls to
calloc(3) and free(3) from any of the "dl" functions -- which live in
the dynamic linker -- end up resolving to the dynamic linker's stubs.
I tried to work around that, but was just making things more complicated.
This alternative costs us a well-known TLS slot (instead of the
dynamically-allocated TLS slot we'd have used otherwise, so no difference
there), plus an extra buffer inside every pthread_internal_t.

Bug: 5404023
Change-Id: Ie9614edd05b6d1eeaf7bf9172792d616c6361767
2012-10-16 17:58:17 -07:00
Elliott Hughes
66d71c8f13 am ab4e2ed1: am db4fdf1a: Merge "Fix dlerror(3)."
* commit 'ab4e2ed182011998751ff5d6c321ff5bae20c6cd':
  Fix dlerror(3).
2012-10-12 10:49:08 -07:00
Elliott Hughes
ab4e2ed182 am db4fdf1a: Merge "Fix dlerror(3)."
* commit 'db4fdf1aafb63b09ee967066d9b8107a9812db2d':
  Fix dlerror(3).
2012-10-12 10:47:59 -07:00
Elliott Hughes
3b297c4079 Fix dlerror(3).
Add unit tests for dlerror(3) in various situations. I think We're at least
as good as glibc now.

Also factor out the ScopedPthreadMutexLock and use it here too.

Bug: http://code.google.com/p/android/issues/detail?id=38398
Change-Id: I040938b4366ab836e3df46d1d8055b92f4ea6ed8
2012-10-11 16:08:51 -07:00
Elliott Hughes
b28c547aa4 am 6ed5bc12: am b650111a: am cd195eba: Merge "Upgrade to the current NetBSD rand implementation."
* commit '6ed5bc12dac544004f8e79b6393b2a8e260a7cc1':
  Upgrade to the current NetBSD rand implementation.
2012-10-01 14:16:53 -07:00
Elliott Hughes
6ed5bc12da am b650111a: am cd195eba: Merge "Upgrade to the current NetBSD rand implementation."
* commit 'b650111a11b84d7c91145c4f29b58b5742afa572':
  Upgrade to the current NetBSD rand implementation.
2012-10-01 14:15:36 -07:00
Elliott Hughes
774c7f54ff Upgrade to the current NetBSD rand implementation.
Also add basic unit tests.

Change-Id: I7fc7ef61d47c1e8fdf8b8eff67a635220c3afd56
2012-10-01 13:53:41 -07:00
Elliott Hughes
f4b34b6c39 DO NOT MERGE Revert "Add the libcutils localtime_tz and mktime_t extensions to bionic."
This reverts commit 3a936a4980.

We don't want this in jb-mr1.
2012-09-24 10:13:12 -07:00
Elliott Hughes
3a936a4980 Add the libcutils localtime_tz and mktime_t extensions to bionic.
Bug: 7012465
Change-Id: Ib66f061e29199ba134545111dc79f9b50c8f4a21
2012-09-11 11:15:53 -07:00
Andrew Hsieh
048569be54 Rename __dso_handle_so.c to __dso_handle_so.h
Also chang libc/arch-arm/bionic/crtbegin_so.c to include it
as a header.

Change-Id: Ib91b0b8caf5c8b936425aa8a4fc1a229b2b27929
2012-09-07 12:49:41 +08:00
Ard Biesheuvel
f3cfcd869d ARM: make CRT_LEGACY_WORKAROUND work as intended
To properly support legacy ARM shared libraries, libc.so needs
to export the symbols __dso_handle and atexit, even though
these are now supplied by the crt startup code.

This patch reshuffles the existing CRT_LEGACY_WORKAROUND
conditionally compiled code slightly so it works as the
original author likely intended.

Change-Id: Id6c0e94dc65b7928324a5f0bad7eba6eb2f464b9
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@gmail.com>
2012-08-28 10:27:02 +02:00
Elliott Hughes
4688279db5 Clean up the linker a bit, remove prelinking support.
Also make the errors more readable, since none of us seemed to know
what they actually meant. The new style is still as verbose as the
old, but that's probably necessary in the absence of chained exceptions
in C. Here's what you'd see if you try to boot after removing
libsurfaceflinger.so:

  32267 32267 E AndroidRuntime: java.lang.UnsatisfiedLinkError: Cannot load library: (linker.c:1629, pid 32259) soinfo_link_image: could not load library "libsystem_server.so" needed by "libandroid_servers.so"; caused by (linker.c:1629, pid 32259) soinfo_link_image: could not load library "libsurfaceflinger.so" needed by "libsystem_server.so"; caused by (linker.c:709, pid 32259) load_library: library "libsurfaceflinger.so" not found

This patch also fixes almost all of the compiler warnings.

Change-Id: I64bb59aed6d4e039c15ea45be2367f319ef879f8
2012-08-07 11:41:10 -07:00
Raghu Gandham
1c30398143 [MIPS] Support for TLS register
Change-Id: I6b5194e5e379b573e3b1203d8015e20fb3edd647
Signed-off-by: Chris Dearman <chris@mips.com>
2012-08-02 18:01:05 -07:00
Elliott Hughes
52d6233296 Report errors to the log, not just stderr.
In particular this affects assert(3) and __cxa_pure_virtual, both of
which have managed to confuse people this week by apparently aborting
without reason. (Because stderr goes nowhere, normally.)

Bug: 6852995
Bug: 6840813
Change-Id: I7f5d17d5ddda439e217b7932096702dc013b9142
2012-07-27 17:43:38 -07:00
Chris Dearman
958dad705a Fix implementation of generic atomic operations
Change-Id: Ie1ea5aacc561e2d6d40125d2952ed0e9116b7b0d
2012-07-24 13:56:38 -07:00
Raghu Gandham
f7fb9e1ef1 [MIPS] Add atomic routines
Change-Id: I2cb20ce44dd230d222b7fc1ede2e1e3dce6e692b
2012-07-24 10:30:22 -07:00
Robert Greenwalt
8f88aa7d38 am c5cab345: am 028ccf5d: Merge "Avoid multiple dns lookups for the same query"
* commit 'c5cab3452d5ced55474e56497594579108670b51':
  Avoid multiple dns lookups for the same query
2012-06-12 15:56:29 -07:00
Robert Greenwalt
c5cab3452d am 028ccf5d: Merge "Avoid multiple dns lookups for the same query"
* commit '028ccf5d40dd9a945ea92aa79822c08c6f6aa1d2':
  Avoid multiple dns lookups for the same query
2012-06-12 15:52:56 -07:00
Geremy Condra
009f38478e Added actual event logging calls to the FORTIFY_SOURCE methods.
Change-Id: I3bf4fa8678c33187cb8ce4b75e666ddcd24403ab
2012-06-11 11:30:56 -07:00
Geremy Condra
8b11c4cec2 Adding event logging to libc.
I've basically just copied the relevant bits out of liblog and
EventLog.cpp. While this will let us do the uid logging we want
to address the concerns in 245c07027f78565858dd489eb0d94c3d48743e9d
it doesn't give us much else.

Change-Id: Icac6ff20bc0a3ade5927f6f76fedffe1ae6f8522
2012-06-08 12:14:48 -07:00
Nick Kralevich
9d40326830 arm: rewrite crtbegin* as C files.
Rewrite
 crtbegin.S     -> crtbegin.c
 crtbegin_so.S  -> crtbegin_so.c

This change allows us to generate PIC code without relying
on text relocations.

As a consequence of this rewrite, also rewrite
  __dso_handle.S    -> __dso_handle.c
  __dso_handle_so.S -> __dso_handle_so.c
  atexit.S          -> atexit.c

In crtbegin.c _start, place the __PREINIT_ARRAY__, __INIT_ARRAY__,
__FINI_ARRAY__, and __CTOR_LIST__ variables onto the stack, instead of
passing a pointer to the text section of the binary.

This change appears sorta wonky, as I attempted to preserve,
as much as possible, the structure of the original assembly.
As a result, you have C files including other C files, and other
programming uglyness.

Result: This change reduces the number of files with text-relocations
from 315 to 19 on my Android build.

Before:
  $ scanelf -aR $OUT/system | grep TEXTREL | wc -l
  315

After:
  $ scanelf -aR $OUT/system | grep TEXTREL | wc -l
  19

Change-Id: Ib9f98107c0eeabcb606e1ddc7ed7fc4eba01c9c4
2012-06-01 14:41:27 -07:00
Mattias Falk
a59cfcfd08 Avoid multiple dns lookups for the same query
If two or more rapid dns requests for the same server are done
from different threads it turns into separate dns reques, if
the response of the request isn't found in the cache.

This patch avoid multiple request for the same server by
letting subsequents request wait until the first request
has finished.

Change-Id: Ic72ea0e7d3964a4164eddf866feb4357ec4dfe54
2012-05-07 18:04:25 -07:00
Evgeniy Stepanov
1a78fbb5c8 Initialize TLS before any application code is run.
Since e19d702b8e, dlsym and friends use recursive mutexes that
require the current thread id, which is not available before the libc
constructor. This prevents us from using dlsym() in .preinit_array.

This change moves TLS initialization from libc constructor to the earliest
possible point - immediately after linker itself is relocated. As a result,
pthread_internal_t for the initial thread is available from the start.

As a bonus, values stored in TLS in .preinit_array are not lost when libc is
initialized.

Change-Id: Iee5a710ee000173bff63e924adeb4a4c600c1e2d
2012-04-13 00:08:11 +04:00