Commit graph

3785 commits

Author SHA1 Message Date
Nick Kralevich
532d6f09b1 Use __predict_false on some fortify methods.
Give the compiler some hints that these error conditions
are unlikely to occur in practice.

Change-Id: Ifaf7322a12120ef663c8315c1a18c2dcbe4bda23
2013-05-02 14:31:51 -07:00
Nick Kralevich
e4ac8feb58 Merge "libc: cleanup strchr" 2013-05-02 21:17:16 +00:00
Nick Kralevich
4f40e511b0 libc: cleanup strchr
Move strchr to a .cpp file, and change to bionic directory.

Change-Id: I64ade7df326c0a9a714aca4caf5647b6833b1c97
2013-05-02 13:58:03 -07:00
Nick Kralevich
5e3b502b6b Merge "keep test names consistent with other tests." 2013-05-01 22:06:15 +00:00
Nick Kralevich
277226bf43 keep test names consistent with other tests.
Change-Id: I23dc4d963af40406b270af83cd17f6c8c95f1de3
2013-05-01 15:05:01 -07:00
Nick Kralevich
8c00c91aa0 Merge "add strrchr -D_FORTIFY_SOURCE=2 test." 2013-05-01 22:01:20 +00:00
Nick Kralevich
80541922e3 add strrchr -D_FORTIFY_SOURCE=2 test.
Change-Id: I1b95bb0086ae9f2f506f3cc90cee834c0ce3b1d8
2013-05-01 14:55:33 -07:00
Nick Kralevich
bee0ab16e4 Merge "libc: upgrade strrchr to FORTIFY_SOURCE=2" 2013-04-30 23:13:04 +00:00
Nick Kralevich
3b2e6bc9ac libc: upgrade strrchr to FORTIFY_SOURCE=2
Change-Id: I4c34c2ce22c5092c4446dc1ab55f37604c1c223f
2013-04-30 14:19:23 -07:00
Nick Kralevich
c46871302e Merge "libc: upgrade some libc functions to _FORTIFY_SOURCE=2" 2013-04-30 18:51:22 +00:00
Nick Kralevich
9020fd503c libc: upgrade some libc functions to _FORTIFY_SOURCE=2
Upgrade the following functions:

* vsnprintf
* vsprintf
* snprintf
* fgets
* strcpy
* strcat
* strncat
* strlcpy
* strlcat
* strlen
* strchr

Change-Id: Icc036fc7f0bb317e05f7c051617887a1601271aa
2013-04-30 11:31:35 -07:00
Nick Kralevich
b94b2851d7 Merge "libc: upgrade sprintf to _FORTIFY_SOURCE=2" 2013-04-29 23:50:46 +00:00
Nick Kralevich
78d6d9888c libc: upgrade sprintf to _FORTIFY_SOURCE=2
Upgrade sprintf to fortify_source level 2, to catch
additional security bugs.

Change-Id: Ibc957d65e4cb96152de84b3745a04e00fa22659e
2013-04-29 16:41:54 -07:00
Nick Kralevich
382a775378 Merge "strncpy: implement _FORTIFY_SOURCE=2" 2013-04-29 23:07:33 +00:00
Nick Kralevich
1aae9bd170 strncpy: implement _FORTIFY_SOURCE=2
Add support for fortify source level 2 to strncpy.
This will enable detection of more areas where strncpy
is used inappropriately. For example, this would have detected
bug 8727221.

Move the fortify_source tests out of string_test.cpp, and
put it into fortify1_test.cpp.

Create a new fortify2_test.cpp file, which copies all
the tests in fortify1_test.cpp, and adds fortify_source level
2 specific tests.

Change-Id: Ica0fba531cc7d0609e4f23b8176739b13f7f7a83
2013-04-29 15:22:10 -07:00
Nick Kralevich
c6dc62f09c Merge "[NETFILTER]: Fix iptables ABI breakage" 2013-04-29 19:44:30 +00:00
Nick Kralevich
e66ad7809e [NETFILTER]: Fix iptables ABI breakage
Pick up Linux kernel patch 2748e5dec7ca8a3804852c7c4171f9156384d15c
from 2007

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=2748e5dec7ca8a3804852c7c4171f9156384d15c

[NETFILTER]: Fix iptables ABI breakage on (at least) CRIS
With the introduction of x_tables we accidentally broke compatibility
by defining IPT_TABLE_MAXNAMELEN to XT_FUNCTION_MAXNAMELEN instead of
XT_TABLE_MAXNAMELEN, which is two bytes larger.

On most architectures it doesn't really matter since we don't have
any tables with names that long in the kernel and the structure
layout didn't change because of alignment requirements of following
members. On CRIS however (and other architectures that don't align
data) this changed the structure layout and thus broke compatibility
with old iptables binaries.

Changing it back will break compatibility with binaries compiled
against recent kernels again, but since the breakage has only been
there for three releases this seems like the better choice.

Change-Id: Ie9552b25892109c7042b9752132dc8ebd3552dc3
2013-04-29 12:31:01 -07:00
Andrew Hsieh
f7153fd13f Merge "Remove redundant space within square brackets" 2013-04-26 01:54:38 +00:00
Elliott Hughes
9ff1ffd805 Merge "Improve diagnostics in the face of bad tzdata." 2013-04-25 22:31:14 +00:00
Elliott Hughes
e7aaad8b83 Improve diagnostics in the face of bad tzdata.
Bug: 8373554
Change-Id: If8df5e956105e01cce95221ff0a7fa9d2b474db3
2013-04-25 14:02:59 -07:00
Nick Kralevich
5f28fde8ae Merge "linker: only re-open std* for setuid programs." 2013-04-25 20:31:41 +00:00
Nick Kralevich
8d3e91d4f8 linker: only re-open std* for setuid programs.
get_AT_SECURE() was getting called before linker_env_init() had
been called, and returning the default value ("true"). This was
causing us to reopen closed stdin, stdout, and stderr for ALL
processes, not just privileged (setuid) processes.

Calling path:
  - __linker_init
    - soinfo_link_image
      - get_AT_SECURE
    - __linker_init_post_relocation
      - linker_env_init

This change restores the intended behavior of only re-opening
stdin, stdout, and stderr for privileged processes.

Change-Id: I8b085ea6597710ac4c1a3c93f1bf8b81eecb08c0
2013-04-25 13:15:24 -07:00
Andrew Hsieh
e8f46e8edd Remove redundant space within square brackets
The new "as" in binutils-2.23 (with gcc4.8) is more picky:
it expects register right after [

Change-Id: I876124841582070ab2083ffafe38bc333b5812d0
2013-04-25 15:05:03 +08:00
Elliott Hughes
87efcd2e63 Merge "Don't avoid IPv6 when looking for new tzdata." 2013-04-24 17:52:29 +00:00
Elliott Hughes
85aeb49144 Don't avoid IPv6 when looking for new tzdata.
Our internal IPv6 FTP networking problems have been fixed.

Change-Id: I9949a13fa20a3b0f3845e565e1461320078d3f14
2013-04-24 10:50:45 -07:00
Elliott Hughes
c705daa0a2 Merge "Disable IPv6 when looking for tzdata updates." 2013-04-22 23:41:37 +00:00
Elliott Hughes
21da42ea91 Disable IPv6 when looking for tzdata updates.
My problems connecting to ftp.iana.org are only via IPv6.

Change-Id: I42e4bae7981ec4b64822f745a7a15544d77ef22d
2013-04-22 13:44:50 -07:00
Elliott Hughes
2c60c18c50 Merge "Upgrade to tzdata2013c." 2013-04-22 19:10:08 +00:00
Elliott Hughes
bda2fb5efa Merge "Add signature checking to HTTP tzdata updates." 2013-04-22 19:03:06 +00:00
Elliott Hughes
676e66db25 Add signature checking to HTTP tzdata updates.
Change-Id: Idcfd217eb215d6a170e6884be8d8ad28cd4fe70d
2013-04-22 11:41:57 -07:00
Elliott Hughes
2379088a90 Upgrade to tzdata2013c.
From the release notes:

  Changes affecting current and future time stamps:

    Palestine observed DST starting March 29, 2013.  (Thanks to
    Steffen Thorsen.)  From 2013 on, Gaza and Hebron both observe DST,
    with the predicted rules being the last Thursday in March at 24:00
    to the first Friday on or after September 21 at 01:00.

    Assume that the recent change to Paraguay's DST rules is permanent,
    by moving the end of DST to the 4th Sunday in March every year.
    (Thanks to Carlos Raúl Perasso.)

  Changes affecting past time stamps:

    Fix some historical data for Palestine to agree with that of
    timeanddate.com, as follows:

          The spring 2008 change in Gaza and Hebron was on 00:00 Mar 28, not
          00:00 Apr 1.

          The fall 2009 change in Gaza and Hebron on Sep 4 was at 01:00, not
          02:00.

          The spring 2010 change in Hebron was 00:00 Mar 26, not 00:01 Mar 27.

          The spring 2011 change in Gaza was 00:01 Apr 1, not 12:01 Apr 2.

          The spring 2011 change in Hebron on Apr 1 was at 00:01, not 12:01.

          The fall 2011 change in Hebron on Sep 30 was at 00:00, not 03:00.

    Fix times of habitation for Macquarie to agree with the Tasmania
    Parks & Wildlife Service history, which indicates that permanent
    habitation was 1899-1919 and 1948 on.

  Changing affecting metadata only:

    Macquarie Island is politically part of Australia, not Antarctica.
    (Thanks to Tobias Conradi.)

    Sort Macquarie more-consistently with other parts of Australia.
    (Thanks to Tim Parenti.)

Change-Id: I3df146d046eda26dbc6ce2a0a26ad9214ec4eaca
2013-04-22 11:33:14 -07:00
Elliott Hughes
70e0bd3a44 Merge "Rename the tzdata update tool, and add HTTP support." 2013-04-22 18:28:49 +00:00
Elliott Hughes
f8dff7d449 Rename the tzdata update tool, and add HTTP support.
The FTP server is currently unavailable, but the HTTP server is working
fine.

Change-Id: If7f2f396e89aca022a60af531f3604523b7bf95c
2013-04-22 11:11:43 -07:00
Elliott Hughes
8c181aa8fe Merge "Use hidden visibility for internal-use-only functions" 2013-04-15 17:51:24 +00:00
Christopher Ferris
516a897053 Merge "Rewrite memset for cortexa15 to use strd." 2013-04-12 19:16:44 +00:00
Elliott Hughes
b3c8c4d865 Merge "Switch to current FreeBSD qsort." 2013-04-12 19:12:29 +00:00
Christopher Ferris
796cbe249b Rewrite memset for cortexa15 to use strd.
Merge from internal master.

(cherry-picked from commit 7ffad9c120)

Change-Id: Ia67f2a545399f4fa37b63d5634a3565e4f5482f9
2013-04-12 10:58:25 -07:00
Kito Cheng
ea489745dc Use hidden visibility for internal-use-only functions
- malloc_debug_init and malloc_debug_fini

Change-Id: I4261ff428a50d8f0371415cda71bcc0a9487ce67
2013-04-12 16:34:38 +08:00
Elliott Hughes
0b25f633a2 Switch to current FreeBSD qsort.
Change-Id: Ic46cd0b663dc5fa78c99dd38db0bfe849a25e789
2013-04-11 18:08:34 -07:00
Elliott Hughes
ed36d95fac Merge "Start moving to current FreeBSD stdio." 2013-04-11 21:18:14 +00:00
Elliott Hughes
6b05c8e280 Start moving to current FreeBSD stdio.
This only touches the easy stuff.

Change-Id: Iecee57f1681dba5c56bff59f0e9a89811a71f0ca
2013-04-11 13:55:01 -07:00
Elliott Hughes
b632857a50 Merge "Add missing include and function prototype for sched_getaffinity." 2013-04-11 00:45:33 +00:00
Kito Cheng
4ca685e36e Add missing include and function prototype for sched_getaffinity.
Change-Id: I649633c8d074def5d05bd0c8b92fb680d9d11d51
2013-04-10 17:44:29 -07:00
Christopher Ferris
fc76c7d394 Merge "Add missing branch in memcpy.S dst aligned case." 2013-04-11 00:23:46 +00:00
Christopher Ferris
bf0d1ad72b Add missing branch in memcpy.S dst aligned case.
Merge from internal master.

(cherry-picked from commit 6ffaa931c3)

Change-Id: Ifdcf01fd122866cf0d4c5b5f7a997803561d7889
2013-04-10 17:21:29 -07:00
Christopher Ferris
68fd78efa0 Merge "Update to latest cortexa15 memcpy code." 2013-04-11 00:18:04 +00:00
Christopher Ferris
185ce72d00 Update to latest cortexa15 memcpy code.
This uses the new code original submitted as memcpy.a15.S as
the base. However, the old code handled unaligned src/dst better
so that was spliced in. I optimized the original unaligned code by
removing a few unnecessary instructions. I optimized the a15 code by
rewriting the pre and post code. I also modified the main loop to add
a pld so that larger copies would not stall waiting for memory.

Test cases for the new memcpy:

- Copy all sized values from 0 to 1024 bytes, using whatever alignment
  is returned by malloc.
For each alignment case described below, the test copied from 0 to 128
bytes.
- Src and dst pointers are both aligned to the same value, starting
  at one going through every power of two up to and including 128.
- Src aligned to double word boundary, dst aligned to word boundary.
- Src aligned to word boundary, dst aligned to double word boundary.
- Src aligned to 16 bit boundary, dst aligned to word boundary.
- Src aligned to word boundary, dst aligned to 16 byte boundary.
- Src aligned to word boundary, dst aligned to 1 byte from a word
  boundary.
- Src aligned to word boundary, dst aligned to 2 bytes from a word
  boundary.
- Src aligned to word boundary, dst aligned to 3 bytes from a word
  boundary.
- Src aligned to 1 byte from a word boundary, dst aligned to a word
  boundary.
- Src aligned to 2 bytes from a word boundary, dst aligned to a word
  boundary.
- Src aligned to 3 bytes from a word boundary, dst aligned to a word
  boundary.

Cases to verify the unaligned source code properly aligns to a 16 bit
boundary.
- Src aligned to 1 byte from a 128 bit boundary, dst aligned to
  4 + 128 bit boundary.
- Src aligned to 1 byte from a 128 bit boundary, dst aligned to
  8 + 128 bit boundary.
- Src aligned to 1 byte from a 128 bit boundary, dst aligned to
  12 + 128 bit boundary.
- Src aligned to 1 byte from a 128 bit boundary, dst aligned to
  16 + 128 bit boundary.

In all cases, a two byte fencepost was placed at the end of the
destination to verify that only the requested number of bytes were copied.

Bug: 8005082

Merge from internal master.

(cherry-picked from commit 21ede92d79)

Change-Id: Ief70c9e6dc8c6473ae245b6570b2c266fed9618c
2013-04-08 18:13:35 -07:00
Elliott Hughes
240fb8623b Merge "Make abort messages available to debuggerd." 2013-04-05 18:25:21 +00:00
Elliott Hughes
0d787c1fa1 Make abort messages available to debuggerd.
This adds __libc_fatal, cleans up the internal logging code a bit more,
and switches suitable callers over to __libc_fatal. In addition to logging,
__libc_fatal stashes the message somewhere that the debuggerd signal handler
can find it before calling abort.

In the debuggerd signal handler, we pass this address to debuggerd so that
it can come back with ptrace to read the message and present it to the user.

Bug: 8531731
Change-Id: I416ec1da38a8a1b0d0a582ccd7c8aaa681ed4a29
2013-04-05 11:24:19 -07:00
Elliott Hughes
014c75c78b Merge "Prevent name conflict for eventfd.cpp and eventfd.s when building libc.a" 2013-04-03 18:11:30 +00:00