Commit graph

1421 commits

Author SHA1 Message Date
Shih-wei Liao
8173d76740 Merge "Revert "Fix the clang build: this compiler doesn't support the gnu_inline function attribute"" 2012-08-06 10:05:15 -07:00
Shih-wei Liao
601a49d398 Merge "When compiling with clang, don't "fortify_source" the strlen." 2012-08-06 10:04:22 -07:00
Shih-wei Liao
9a3d53fad0 When compiling with clang, don't "fortify_source" the strlen.
At this point, FORTIFY_SOURCE and clang are just plain incompatible.
Need to solve the underlying incompatibility first.

Change-Id: I3366477d19461e1ec93b1c30e0c7e8145b391b9b
2012-08-06 09:50:56 -07:00
Elliott Hughes
7c92b6ca40 Merge "Remove an awkward #include that is no longer upstream." 2012-08-06 07:57:59 -07:00
Shih-wei Liao
2b7f68c03d Revert "Fix the clang build: this compiler doesn't support the gnu_inline function attribute"
This reverts commit 4f1f149c37.
2012-08-03 17:44:08 -07:00
Elliott Hughes
bbf094fdf5 Remove yet more SH4 cruft.
Surely this is the last piece?

Change-Id: I4bd43afb102334ec34d0e14a65c2b319826473d7
2012-08-03 14:58:18 -07:00
Jin Wei
c164f2a969 bionic: modify syscall to use 6 registers to pass parameter.
Kernel allows to use 6 registers(exclude eax) to pass parameter.
But in syscall's implementation, it only uses five registers.
It will lead to error when 6 parameters passed.

Change-Id: I92d663194e6334c3847f0c0c257ca3b9dee0edef
Author: Jin Wei <wei.a.jin@intel.com>
Signed-off-by: Xiaokang Qin <xiaokang.qin@intel.com>
Signed-off-by: Beare, Bruce J <bruce.j.beare@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 30838
2012-08-03 13:54:29 -07:00
Elliott Hughes
094651335e Upgrade to tzdata2012e.
Includes this change:

  * australasia (Pacific/Fakaofo): Tokelau is UTC+13, not UTC+14.
    (Thanks to Steffen Thorsen.)

Change-Id: I51bfab759f424b90daeb1960c6cfb2b55b78ff46
2012-08-03 12:26:06 -07:00
Shih-wei Liao
4f1f149c37 Fix the clang build: this compiler doesn't support the gnu_inline function attribute
Recent clang compiler doesn't have gnu_inline working. When frameworks/rs
is compiled with clang instead of gcc, it no longer works. Will be fixed
by this patch.

Change-Id: I8b281a1305151909e18958b73914ea27343cb4cd
2012-08-03 04:38:15 -07:00
Elliott Hughes
bdcc14d721 Remove an awkward #include that is no longer upstream.
This was causing trouble in https://android-review.googlesource.com/#/c/37590/.

Change-Id: Ib7cb4fbaef6e9c1470c59f67d24bd24c7ce90bcc
2012-08-02 18:12:36 -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
Raghu Gandham
405b8029a6 MIPS support for libc.
Change-Id: I2864dea04b3faf2d919165dcaa600af5b16c41c8
Signed-off-by: Chris Dearman <chris@mips.com>
Signed-off-by: Raghu Gandham <raghu@mips.com>
2012-08-02 16:07:26 -07:00
Elliott Hughes
ecb53eab4b Fix a ENOTUP/ENOTSUP typo.
Change-Id: Ifa347a09a2aa1f505965ae7c1383fd0caf95793c
2012-08-02 15:45:04 -07:00
Elliott Hughes
994935f64c Merge "Error numbers are target specific." 2012-08-02 15:42:48 -07:00
Chris Dearman
da2611084f Error numbers are target specific.
Use the system supplied error numbers when mapping error numbers to messages.

Change-Id: I520556fa3e2ff668fdc4eda36ad31491fbb48ea8
Signed-off-by: Chris Dearman <chris@mips.com>
Signed-off-by: Raghu Gandham <raghu@mips.com>
2012-08-01 17:53:07 -07:00
Raghu Gandham
c29f295d39 Updated the cleaned header file mman.h for MIPS.
Change-Id: I8b3734e535711ca07fbf4066e6d967d1ce0f30eb
2012-07-31 14:47:51 -07:00
Elliott Hughes
a513f70b43 Merge "bionic: Stack pointer/signal race condition." 2012-07-31 10:32:59 -07:00
Elliott Hughes
21372896ea Merge "fix __cxa_finalize() implementation to be thread safe." 2012-07-31 10:31:20 -07:00
Srinavasa Nagaraju
2270dfa0c4 fix __cxa_finalize() implementation to be thread safe.
__cxa_finalize() modifies the access permissions of __atexit
global variable without acquiring  _ATEXIT_LOCK(). Fix it prevent
any possible races.

Change-Id: I11939d0ebcbf6f360c14163222d40a449d96948e
2012-07-31 12:30:28 +02:00
Shih-wei Liao
fc0725ec5c Install crt(begin|end)_so.o to target library path.
BUG=6886348.

Change-Id: I176b2c4963d9731b06d10d4e0b92c010a0006b59
2012-07-28 00:33:28 -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
Ying Wang
6171d11e72 Replace ALL_PREBUILTS with BUILD_PREBUILT
(cherry-picked from 186b36b65bdfbf2c89a661539bf530359364eac9.)

Bug: 6857263
Change-Id: If787d84415dd2ac07105fe0d0b7a27c9be75df64
2012-07-27 13:44:01 -07:00
Elliott Hughes
12f411d9a6 Merge "Correction to use of TEMP_FAILURE_RETRY in send_prop_msg" 2012-07-27 10:02:59 -07:00
Jens Gulin
c20d0f3993 Correction to use of TEMP_FAILURE_RETRY in send_prop_msg
RETRY macro may retry command if result is -1. In this
case the command was "connect < 0" instead of just
connect. The comparison will not return -1 and thus
retry is never done. This is now corrected so that
interrupts will cause retry instead of fail.

(There was no other negative side effect of the bug.
The result code from RETRY was used in an if-statement
and it would be true for all negative connect results.
This was according to expectations.)

Change-Id: Ie206b39878e9befea4e3be9a4061ee39eb232d80
2012-07-27 15:18:23 +02:00
Peter Enderborg
3460db9490 bionic: Stack pointer/signal race condition.
Move the stackpointer so a captured signal does not corrupt
stack variables needed for __thread_entry.

Change-Id: I3e1e7b94a6d7cd3a07081f849043262743aa8064
2012-07-27 15:11:01 +02:00
Elliott Hughes
7d6c3f700b Merge "Remove the 'Factory' time zone by not processing the 'factory' file." 2012-07-26 17:36:21 -07:00
Elliott Hughes
541c225320 Remove the 'Factory' time zone by not processing the 'factory' file.
The factory file (and Factory time zone) was meant as a way to say
"not configured" that would give a clear error when running date(1).
For us it would just look like UTC, so it is of no value.

Bug: 2997381
Change-Id: I1a4b85dce97d1d9370b22ba79e8fe5dafff56541
2012-07-26 16:19:46 -07:00
Nick Kralevich
9145ad3f0a vfprintf: fix spelling.
Change-Id: I6dc611143fb1f3e9ccf0a77b40ee48a3c1d72ca9
2012-07-25 16:01:38 -07:00
Chris Dearman
00a66a6fe8 [MIPS] Use an aligned address to provoke SIGSEGV in abort()
Change-Id: I269c9ccc07058773fb0f9d70673673157ab38f6a
2012-07-24 17:42:06 -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
Elliott Hughes
5d967e43d0 Upgrade to tzdata2012d.
This upgrade involved rewriting the script; the data has moved to ftp.iana.org,
where it's slightly less convenient to access, so it's time to use something
that can talk FTP...

As for tzdata2012d, it's just updating Morocco for this weekend's changes, now
they've been decided at the last minute (as usual).

Change-Id: I772df57a6e09b3bf3d9541bfc08930d6f18633b4
2012-07-20 16:53:32 -07:00
Nick Pelly
0351955a68 Update time.h for CLOCK_BOOTTIME.
(cherry-pick of 8958a38329)

Change-Id: Ie8de6b32fa81566db53ad7e9fd4b197f4cede628
2012-07-19 17:10:14 -07:00
Elliott Hughes
fabddfe833 Merge "limits.h: Include page.h when relying on PAGE_SIZE" 2012-07-16 09:39:24 -07:00
Nick Kralevich
c37fc1ab6a FORTIFY_SOURCE: revert memcpy changes.
Performance regressions.  Hopefully this is a temporary
rollback.

Bug: 6821003
Change-Id: I84abbb89e1739d506b583f2f1668f31534127764
2012-07-13 17:58:37 -07:00
Nick Kralevich
9b6cc223a3 FORTIFY_SOURCE: introduce __BIONIC_FORTIFY_UNKNOWN_SIZE macro
Replace all occurances of "(size_t) -1" with a
__BIONIC_FORTIFY_UNKNOWN_SIZE macro.

Change-Id: I0b188f6cf31417d2dbef0e1bd759de3f9782873a
2012-07-13 14:49:33 -07:00
Nick Kralevich
260bf8cfe0 FORTIFY_SOURCE: strlen check.
This test is designed to detect code such as:

int main() {
  char buf[10];
  memcpy(buf, "1234567890", sizeof(buf));
  size_t len = strlen(buf); // segfault here with _FORTIFY_SOURCE
  printf("%d\n", len);
  return 0;
}

or anytime strlen reads beyond an object boundary. This should
help address memory leakage vulnerabilities and make other
unrelated vulnerabilities harder to exploit.

Change-Id: I354b425be7bef4713c85f6bab0e9738445e00182
2012-07-13 13:49:59 -07:00
Nick Kralevich
b2060b027c FORTIFY_SOURCE: restore __memcpy_chk()
In our previous FORTIFY_SOURCE change, we started using a custom
inline for memcpy(), rather than using GCC's __builtin_memcpy_chk().
This allowed us to delete our copy of __memcpy_chk(), and replace it
by __memcpy_chk2().

Apparently GCC uses __memcpy_chk() outside of __builtin_memcpy_chk().
Specifically, __memcpy_chk() is used by __builtin__memMOVE_chk() under
certain optimization levels.

Keep the old __memcpy_chk() function around, and have it call into
__memcpy_chk2().

Change-Id: I2453930b24b8a492a3b6ed860e18d92a6b762b80
2012-07-13 13:49:45 -07:00
Nick Kralevich
f3913b5b68 FORTIFY_SOURCE: enhanced memcpy protections.
Two changes:

1) Detect memory read overruns.

For example:

int main() {
  char buf[10];
  memcpy(buf, "abcde", sizeof(buf));
  sprintf("%s\n", buf);
}

because "abcde" is only 6 bytes, copying 10 bytes from it is a bug.
This particular bug will be detected at compile time.  Other similar
bugs may be detected at runtime.

2) Detect overlapping buffers on memcpy()

It is a bug to call memcpy() on buffers which overlap. For
example, the following code is buggy:

  char buf3[0x800];
  char *first_half  = &buf3[0x400];
  char *second_half = &buf3[1];
  memset(buf3, 0, sizeof(buf3));
  memcpy(first_half, second_half, 0x400);
  printf("1: %s\n", buf3);

We now detect this at compile and run time.

Change-Id: I092bd89f11f18e08e8a9dda0ca903aaea8e06d91
2012-07-12 15:38:15 -07:00
Nick Kralevich
e64259e860 memmove: Don't call memcpy if regions overlap
memmove() unconditionally calls memcpy() if "dst" < "src". For
example, in the code below, memmove() would end up calling memcpy(),
even though the regions of memory overlap.

int main() {
  char buf3[0x800];
  char *dst  = &buf3[1];
  char *src = &buf3[0x400];
  memset(buf3, 0, sizeof(buf3));
  memmove(dst, src, 0x400);
  printf("1: %s\n", buf3);
  return 0;
}

Calling memcpy() on overlaping regions only works if you assume
that memcpy() copies from start to finish. On some architectures,
it's more efficient to call memcpy() from finish to start.

This is also triggering a failure in some of my code.

More reading:
* http://lwn.net/Articles/414467/
* https://bugzilla.redhat.com/show_bug.cgi?id=638477#c31 (comment 31)

Change-Id: I65a51ae3a52dd4af335fe5c278056b8c2cbd8948
2012-07-11 17:46:03 -07:00
Nick Kralevich
6334c662ca Don't use -fstack-protector on ssp.c
libc's stack protector initialization routine (__guard_setup)
is in bionic/ssp.c. This code deliberately modifies the stack
canary.  This code should never be compiled with -fstack-protector-all
otherwise it will crash (mismatched canary value).

Force bionic/ssp.c to be compiled with -fno-stack-protector

Change-Id: Ib95a5736e4bafe1a460d6b4e522ca660b417d8d6
2012-07-10 10:51:41 -07:00
Arun Raghavan
6331db3fd2 limits.h: Include page.h when relying on PAGE_SIZE
limits.h relies on PAGE_SIZE being defined without actually including
page.h. Make sure this is included to avoid compilation failures.

Signed-off-by: Arun Raghavan <arun.raghavan@collabora.co.uk>
2012-07-10 10:36:37 +05:30
Nick Kralevich
8f08e1c902 Merge "FORTIFY_SOURCE: Add openat, fix bug" 2012-07-09 12:55:32 -07:00
Nick Kralevich
a3e230d1fa FORTIFY_SOURCE: Add openat, fix bug
Add fortify_source support for openat(). This change requires that
an argument be supplied when using O_CREAT.

Fix unnecessary call to __open_2. If, at compile time, we know that
"flags" is constant and DOESN'T contain O_CREAT, the call to __open_2
is useless.

Change-Id: Ifcd29c4fb25e25656961d7552d672e161f0cfdbd
2012-07-09 12:30:40 -07:00
Nick Kralevich
965dbc6405 FORTIFY_SOURCE: add fgets support.
Change-Id: I8c3410a90c71a3336c4ac8581618fa9330edf5e3
2012-07-09 09:57:18 -07:00
Rebecca Schultz Zavin
2ddf77b377 Merge "Modify ion header" 2012-06-28 14:16:10 -07:00
Nick Kralevich
bd73eede46 Merge "FORTIFY_SOURCE: add open() checks" 2012-06-27 12:56:52 -07:00
Nick Kralevich
cb228fb4a9 libc: cleanups
Prefix private functions with underscores, to prevent name
conflicts.

Use __error__ instead of error, since occasionally programs will
create their own "#define error ...".

Change-Id: I7bb171df58aec5627e61896032a140db547fd95d
2012-06-26 16:05:19 -07:00
Nick Kralevich
8118f62a7d FORTIFY_SOURCE: add open() checks
Add a FORTIFY_SOURCE check which requires that you pass a
"mode" argument when calling open(..., O_CREAT). If a mode isn't
passed, then the file is created with "undefined" permissions.

Change-Id: I4427be4f9ce170c69da01af5b00fb05b03613a28
2012-06-26 15:19:12 -07:00
Andy McFadden
f2ba5c9afa am 63c4179f: am 4d0128f1: Merge "Minor tweak to get memory around corrupted heap chunks dumped." into jb-dev
* commit '63c4179f5951edc2d68700fe75659fbd34febe63':
  Minor tweak to get memory around corrupted heap chunks dumped.
2012-06-19 11:33:19 -07:00