Commit graph

25129 commits

Author SHA1 Message Date
Josh Gao
6fcba93b17 Filter out reserved signals in functions that take sigset_t.
Prevent processes from blocking libc-reserved signals by filtering them
out.

Bug: http://b/73144101
Test: 32/64-bit bionic-unit-tests-glibc
Test: 32/64-bit bionic-unit-tests on taimen
Change-Id: Ibadcaa7f668ed8be885cc61b67fb4b611fce8b17
2018-02-27 14:12:30 -08:00
Elliott Hughes
a9050686c4 Merge "Move sigprocmask into its own file." 2018-02-27 05:49:46 +00:00
Elliott Hughes
7ae39129e1 Move sigprocmask into its own file.
Otherwise clang inlines it into pthread_sigmask(3), which breaks libsigchain.

Bug: http://b/73344857
Test: ran tests, plus the app this broke
Change-Id: Ie4a1dc8f9c6ba58d1a2fa69aeff961c70b74767d
2018-02-26 16:59:37 -08:00
Treehugger Robot
9c85408d95 Merge changes Idc5da0f8,I64223714
* changes:
  Reject exit-time destructors in libc
  Remove non-trivial constructors/destructors from SystemProperties
2018-02-22 06:48:12 +00:00
Ryan Prichard
8f419579ed Reject exit-time destructors in libc
Test: m libc
Bug: b/73485611
Change-Id: Idc5da0f8a21e3f58fc68085577fa5fca40057276
2018-02-21 15:10:24 -08:00
Tom Cherry
ee8e3dd67c Remove non-trivial constructors/destructors from SystemProperties
With the goal of disallowing exit time destructors, SystemProperties's
non-trivial destructor needs to be removed.  This means replacing the
union hack with yet another hack as we don't want to allocate anything
despite relying on some polymorphism.

Bug: 73485611
Test: boot bullhead
Change-Id: I64223714c9b26c9724bfb8f3e2b0168e47b56bc8
2018-02-21 15:10:17 -08:00
Tom Cherry
44c7b6ad0a Merge changes Ibcd45e9b,I1ff5c0fa
* changes:
  Do not munmap in MmapFile::~MmapFile
  Build bionic/tests with cpp_std experimental.
2018-02-21 04:41:21 +00:00
Treehugger Robot
d27a3d7853 Merge "Fix mmap leak in MmapFile" 2018-02-21 02:14:21 +00:00
Tom Cherry
5fe73268f3 Do not munmap in MmapFile::~MmapFile
Having any destructor with a global variable in bionic is causing
some issues. Since we don't actually need to munmap in this case, we
remove the destructor to work around that issue.

A small class is used to still munmap during tests.

Bug: 73485611
Test: bionic unit tests
Change-Id: Ibcd45e9b1ab22d187ecfc2738bb87244250d81ea
2018-02-20 16:02:13 -08:00
Tom Cherry
cb4d42173e Fix mmap leak in MmapFile
If the mmap'ed file doesn't end in a new line, previously we'd leak
the mmap'ed region.  This change now munmap's the region.

Test: unit tests
Change-Id: If28d3d9a6b1b9c54123beecb3bbbe8ed984ca81d
2018-02-20 15:50:04 -08:00
Tom Cherry
60ddedff0b Build bionic/tests with cpp_std experimental.
Test: bionic unit tests still pass.
Change-Id: I1ff5c0fa391ae111ac19e863ef0f7f29868406e6
2018-02-20 15:40:02 -08:00
Treehugger Robot
e510d9c369 Merge "Fix RTLD_NEXT/DEFAULT lookup" 2018-02-20 22:24:37 +00:00
dimitry
153168c855 Fix RTLD_NEXT/DEFAULT lookup
RTLD_NEXT/DEFAULT lookup should not skip handle lookup
in the case when the load group is RTLD_GLOBAL.

Note that there is a difference between load group is local group.
The local group includes externally referenced libraries where
the load group does not. The external reference in this context is a
DT_NEEDED library that belongs to a previously loaded group.

Bug: http://b/72237367
Test: bionic-unit-tests --gtest_filter=dl*
Change-Id: I8997cc961c13a5396f1756161798b45ed1cab16c
2018-02-20 17:10:00 +01:00
Treehugger Robot
0da2523570 Merge "Remove obsolete debuggerd32/debuggerd64 hack." 2018-02-16 23:34:35 +00:00
Elliott Hughes
e2d6c1e76c Merge "The VDSO soname varies by architecture." 2018-02-16 21:51:54 +00:00
Elliott Hughes
4e6bf9e9fa Remove obsolete debuggerd32/debuggerd64 hack.
Bug: N/A
Test: builds
Change-Id: I159eea4e1c0d88e5e51184479ed020e7597390ba
2018-02-16 10:53:03 -08:00
Elliott Hughes
da1bb11340 The VDSO soname varies by architecture.
From http://man7.org/linux/man-pages/man7/vdso.7.html:

       user ABI   vDSO name
       ─────────────────────────────
       aarch64    linux-vdso.so.1
       arm        linux-vdso.so.1
       ia64       linux-gate.so.1
       mips       linux-vdso.so.1
       ppc/32     linux-vdso32.so.1
       ppc/64     linux-vdso64.so.1
       s390       linux-vdso32.so.1
       s390x      linux-vdso64.so.1
       sh         linux-gate.so.1
*      i386       linux-gate.so.1
*      x86-64     linux-vdso.so.1
       x86/x32    linux-vdso.so.1

Note that Android "x86" is Linux's "i386", which is the odd one out
amongst Android's supported architectures.

Bug: http://b/72831787
Test: ran tests
Change-Id: I0a28127af042e2fd7673f24bbb30f8a50556cf96
2018-02-16 10:05:08 -08:00
Treehugger Robot
d5172fced0 Merge "Add __fseterr." 2018-02-15 02:36:38 +00:00
Elliott Hughes
665ce210fa Merge "Add remaining _l function stubs." 2018-02-15 01:26:17 +00:00
Elliott Hughes
457852666c Add __fseterr.
Trivial, obvious counterpart to the standard ferror(3) and clearerr(3),
and lets us build bison out of the box.

Bug: http://b/64273806
Test: ran tests
Change-Id: I20affabddb71210051165c41e86adfe5ae04f77f
2018-02-14 15:25:21 -08:00
Elliott Hughes
38a78728c3 Merge "Add uc_sigmask64." 2018-02-14 21:24:11 +00:00
Elliott Hughes
3376c23dac Add remaining _l function stubs.
Bug: http://b/65595804
Test: ran tests
Change-Id: I3bea3af20b354d1f0d3e05fd35421a9045f29020
2018-02-13 23:14:12 -08:00
Elliott Hughes
23415fc60d Add uc_sigmask64.
Added to each ucontext_t for source compatibility between platforms where
sigset_t and sigset64_t differ (arm, x86) and where they're the same
(all the rest).

Bug: http://b/72493232
Test: ran tests
Change-Id: I65a37bfa177933701bbe6c2350448885fd0f9c43
2018-02-13 19:09:04 -08:00
Treehugger Robot
2d1e1011cf Merge "Switch the rest of our internal headers to #pragma once." 2018-02-14 02:53:37 +00:00
Christopher Ferris
af8d54a7d7 Merge "Implement malloc hooks." 2018-02-14 00:49:48 +00:00
Elliott Hughes
cbc80ba9d8 Switch the rest of our internal headers to #pragma once.
We've been using #pragma once for new internal files, but let's be more bold.

Bug: N/A
Test: builds
Change-Id: I7e2ee2730043bd884f9571cdbd8b524043030c07
2018-02-13 14:27:17 -08:00
Christopher Ferris
db478a6274 Implement malloc hooks.
Use the malloc debug framework to implement the malloc debug hooks
since it can introduce a performance issue.

Also, modify the bionic/tests/utils.h slightly to dump an error message
when the exe failed.

Bug: 30561479

Test: Ran malloc hook unit tests.
Test: Ran malloc debug unit tests.
Test: Enabled malloc hooks and ran bionic unit tests and verified no
Test: unexpected failures.
Test: Enabled malloc debug and malloc hooks and verified malloc debug wins.
Test: Enabled malloc debug using env, property, and property with name
Test: still works.

Change-Id: Ib50046a0493c5c2050cf831befb812310bdcc249
(cherry picked from commit d6a1dc2379)
2018-02-13 13:37:30 -08:00
Treehugger Robot
3374d0cabb Merge "Switch x86 begin.c to asm; align ESP correctly" 2018-02-13 16:17:27 +00:00
Elliott Hughes
f99b7a34c8 Merge "Better backwards compatibility for stat64." 2018-02-13 15:42:55 +00:00
Treehugger Robot
a8b179bcdd Merge "Revert "Remove a check for AIDs in the OEM range."" 2018-02-13 07:09:27 +00:00
Ryan Prichard
f857d59635 Switch x86 begin.c to asm; align ESP correctly
Every other architecture already uses an assembly file here.

The previous code aligned ESP incorrectly, but it doesn't really matter
because everything is built with Clang's -mstackrealign, which realigns
ESP in every function prologue.

Bug: http://b/73140672#comment4
Test: lunch aosp_x86-eng; m; emulator; device boots
Test: manual
Change-Id: I921fd7848cdc611b4f8f13d1176d1983ffea952d
2018-02-12 21:43:12 -08:00
Elliott Hughes
25f17e48df Better backwards compatibility for stat64.
Caused problems for some Google source switching to unified headers
because the legacy headers just used #define instead.

Bug: http://b/73210428
Test: builds
Change-Id: If8a36f284031e57af419903610029a8c34a23d91
2018-02-12 15:48:01 -08:00
Tom Cherry
41986a013a Revert "Remove a check for AIDs in the OEM range."
We now have a proper mechanism for OEMs to create new AIDs via
config.fs and /vendor/etc/{passwd,group}.  This means that there is no
reason for OEMs to add AIDs by modifying android_filesystem_config.h,
and therefore we can add this check back.

Bug: 27999086
Test: pwd and grp tests pass with custom AIDs in config.fs

This reverts commit a14485adde.

Change-Id: I74a28ff267a595e83cf692b27fd8b5170a021f54
2018-02-12 10:49:13 -08:00
Treehugger Robot
919dd9dcb4 Merge "MIPS32: Make sigset64_t equal to sigset_t" 2018-02-12 18:49:12 +00:00
Tom Cherry
ab8c861597 Merge "Add ability to read /etc/passwd and /etc/group" 2018-02-12 16:27:20 +00:00
Goran Jakovljevic
379666996d MIPS32: Make sigset64_t equal to sigset_t
sigset_t is already large enough on mips so use the same principle
as on LP64 architectures: typedef sigset_t sigset64_t

Also prevent accessing sa_restorer field for architectures which
don't define SA_RESTORER in signal_test.

This allows compilation of signal_test.

Test: bionic-unit-tests in QEMU (MIPS32)
Change-Id: I965e202c9a7f7d109e4ec25ad87172dc7c1b8806
2018-02-12 09:03:10 +01:00
Treehugger Robot
4362da8076 Merge "Remove __overloadable/__RENAME_CLANG" 2018-02-10 02:30:37 +00:00
Treehugger Robot
6fa9bddbc7 Merge "linker_memory: return success in enable_fallback_allocator." 2018-02-10 01:44:07 +00:00
Treehugger Robot
5bf2c20f43 Merge "crtbegin: Correctly align ESP to 16 for __i386__" 2018-02-09 06:56:31 +00:00
Treehugger Robot
59a0a37b9d Merge "Add _FORCE_CRT_ATFORK config for crtbegin." 2018-02-09 05:41:31 +00:00
Ryan Prichard
a0d177d010 crtbegin: Correctly align ESP to 16 for __i386__
The (lowest) address of the argument area (aka ESP immediately prior to
the call instruction) must be aligned to 0 mod 16. Here, it is aligned to
12 mod 16.

From the SysV ABI doc (2.2.2 The Stack Frame)

"""The end of the input argument area shall be aligned on a 16 (32, if
__m256 is passed on stack) byte boundary. In other words, the value
(%esp + 4) is always a multiple of 16 (32) when control is transferred to
the function entry point."""

Test: extract code into a separate C file and verify stack alignment in a
  "start_main" function
Test: use the upcoming NDK r17-beta1 (with new Bionic crtbegin*.o files)
  with an M-23 x86 system image, check alignment in main (compiled with
  Clang not GCC, compiled w/o -mstackrealign)
Bug: b/73140672

Change-Id: Ia8d93fe5668d0a514a9fd22c40bf8362805111e6
2018-02-08 20:55:57 -08:00
Elliott Hughes
3d6b2e78a9 Merge "Document the rules of thumb for "should I add a syscall wrapper?"." 2018-02-09 03:33:43 +00:00
Tom Cherry
6034ef85d8 Add ability to read /etc/passwd and /etc/group
Add the capability to read /etc/passwd and /etc/group for getpw* and
getgr* functions.

Bug: 27999086
Test: pwd, grp, grp_pwd_file unit tests
Test: Read in custom users/groups from /etc/{passwd,group}
Change-Id: Idc1f054af8a7ca34743a90493495f0ccc775a0d8
2018-02-08 12:38:57 -08:00
Elliott Hughes
1a1b57cb83 Document the rules of thumb for "should I add a syscall wrapper?".
This isn't well known, and causes confusion for at least a couple of
people each year.

Bug: N/A
Test: N/A
Change-Id: I43127d937ee81d0c79bbc496638a1b1b6003dd80
2018-02-08 09:53:59 -08:00
Treehugger Robot
aac0dd9891 Merge "Don't use SA_RESTORER if it is not defined" 2018-02-08 07:47:21 +00:00
Treehugger Robot
1a5737a48f Merge "Fix __gnu_Unwind_Find_exidx again." 2018-02-07 20:10:01 +00:00
Treehugger Robot
13dec2354d Merge "Add a few more legacy inlines for strto*_l." 2018-02-07 19:55:43 +00:00
Treehugger Robot
dd1742aca5 Merge "Add aligned_alloc to libc." 2018-02-07 17:00:20 +00:00
Goran Jakovljevic
87c6aac6d2 Don't use SA_RESTORER if it is not defined
This is a follow up to I47b0560a30aa33a9b1f1978dfb7f84d2e3d389b8.
This fixes MIPS32 build.

Test: successful build and boot aosp_mips-eng
Change-Id: Ia5b245f5536d8fd037f1798bbdf6215c5f059045
2018-02-07 16:56:33 +01:00
Christopher Ferris
cae21a9b53 Add aligned_alloc to libc.
Bug: 72969374

Test: Bionic unit tests pass.
Test: Malloc debug unit tests pass.
Change-Id: I235985bbc638855d94249c97c98f14ab2924bda0
(cherry picked from commit d69ee59594)
2018-02-07 06:57:14 -08:00