Commit graph

1243 commits

Author SHA1 Message Date
Pavel Labath
1faca6c95b Add a test exercising ptrace watchpoint functionality
This adds a test which verifies that watchpoints work on devices
which support them. It is motivated by issues experienced by Nexus
5 devices, where watchpoints work only sporadically.

These tests spawn a process, trace it, and verify it hits a
watchpoint of various sizes while executing on all available CPUs
(to help catch a recent bug, where some debugging functionality
was not available on non-boot CPUs). All x86(_64) targets are
expected to support this functionality. In case of arm(64),
watchpoints are expected to work on devices where the relevant
syscall indicates watchpoint presence. In case of mips, this test
is skipped as I could not verify that the test would work
correctly due to lack of hardware, and this test is intrinsically
hardware-dependend.

Change-Id: I035ac1822816cd1a3f3b56b985c2fb5fd664185d
2016-04-21 20:45:23 -07:00
Elliott Hughes
13d79abebe Fix ftw/nftw to only report unreadable directories once.
Also remove all the copy & paste.

Bug: http://b/28197840
Change-Id: Ia43e9ffd838dabb511a6e54403d6f62066383e4d
2016-04-18 12:05:18 -07:00
Dimitry Ivanov
aca299ac47 Remove dangling links in secondary namespaces
linker didn't remove link to the soinfo from shared
namespaces on soinfo_unload, because it didn't keep
record of all namespaces the library is added to.

This change adds test for this and also fixes the
problem by introducing list of secondary namespaces
to soinfo, which is used to remove soinfo in
soinfo::remove_all_links().

Bug: http://b/28115950
Change-Id: Ifbf6e54f92fa6e88f86b6a8dd6dc22d4553afd22
2016-04-14 11:52:16 -07:00
Elliott Hughes
4d098ca912 Add a test for pthread_setname_np on another thread in a PR_SET_DUMPABLE 0 process.
Bug: http://b/28051133
Change-Id: I9a578333815afa6bdfc1e3c3eea430a15957304f
2016-04-11 12:43:05 -07:00
Dimitry Ivanov
7c649411b6 Merge "Add test for IRELATIVE resolution with RTLD_LAZY" 2016-04-09 01:40:32 +00:00
Dimitry Ivanov
ba35b2d1b9 Add test for IRELATIVE resolution with RTLD_LAZY
Even though bionic linker does not support RTLD_LAZY - it
is good to know that its behavior matches glibc.

Bug: http://b/27930475
Change-Id: I1a47263aaa3dc44f9ac61fe77deb55a21e7f881a
2016-04-08 11:50:42 -07:00
Elliott Hughes
6cfb84b97e Add trivial no-op <nl_types.h>.
Needed to build OpenMP.

Bug: http://b/27617302
Change-Id: Iac15c84ead6f5d5274cfdb2d6d4a4ec0072244bb
2016-04-06 17:22:44 -07:00
Mark Salyzyn
8d387ee1ec fix oem_XXXX ids to incorporate both ranges
The XXXX now lines up to the underlying uid and has no offset.
Work with AID_OEM_RESERVED uids.

Test uses hard coded values to catch changes in the API expectations
that may occur in private/android_filesystem_config.h.

SideEffects: names change, some product dependencies.

Bug: 27999086
Change-Id: Ic2b4c36de74ae009a44e14711c75834293828207
2016-04-06 21:18:49 +00:00
Elliott Hughes
26fda778f7 Fix b64_pton.
This was fixed upstream years ago. While we're here, let's switch to the
OpenBSD copy (because that's our majority upstream BSD, not because they
found and fixed this bug first).

Bug: http://b/28035006
Change-Id: I53dd915a8122bfd7a6d58f01f9902d1586a47e23
2016-04-06 12:08:45 -07:00
Elliott Hughes
37b23cbff5 Merge "Add <sys/quota.h>." 2016-04-06 18:08:34 +00:00
Elliott Hughes
eafad49bd6 Add <sys/quota.h>.
It turns out that at least the Nexus 9 kernel is built without CONFIG_QUOTA.
If we decide we're going to mandate quota functionality, I'm happy for us to
be a part of CTS that ensures that happens, but I don't want to be first, so
there's not much to test here other than "will it compile?". The strace
output looks right though.

Bug: http://b/27948821
Bug: http://b/27952303
Change-Id: If667195eee849ed17c8fa9110f6b02907fc8fc04
2016-04-06 11:06:09 -07:00
Elliott Hughes
3735539fc3 Rename the <grp.h>/<pwd.h> tests to reflect that they're no longer in stubs.cpp.
Bug: http://b/27999086
Change-Id: I3255ad5861a705beeb9b462e22f79ae1e5a85a79
2016-04-06 09:04:17 -07:00
Dimitry Ivanov
0a2ab0203c Do not test ifunc on mips
This commit fixes mips build

Bug: http://b/28009632
Change-Id: I5c657b31947791aea4cc02a2fc4ede6d0ecde851
2016-04-05 17:37:45 -07:00
Elliott Hughes
7f72ad4d6c Add sync_file_range to <fcntl.h>.
Bug: http://b/27952303
Change-Id: Idadfacd657ed415abc11684b9471e4e24c2fbf05
2016-04-05 12:17:22 -07:00
Elliott Hughes
55147ada3c Add missing prototype for readahead in <fcntl.h>.
Change-Id: Icfe85e9cf95c657b495c4e9cd10dec50b0b8f6db
2016-04-05 11:06:02 -07:00
Elliott Hughes
c9291e1bb5 Merge "Add POSIX getsubopt(3)." 2016-04-05 18:03:56 +00:00
Elliott Hughes
df143f8576 Add POSIX getsubopt(3).
Bug: http://b/27952303
Change-Id: I8a816477545dadcbd5c055714e76263574446b6f
2016-04-04 17:34:04 -07:00
Greg Hackmann
5375bf6398 Add SysV signal handling
Implement the legacy SysV signal handling functions sighold(),
sigignore(), sigpause(), sigrelse(), and sigset() in terms of the newer
POSIX signal APIs.  As of POSIX 2013 the SysV signal APIs are deprecated
but still required.

Change-Id: I4ca40e3d706605a7d1a30dc76c78b2b24586387d
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-04-04 16:33:29 -07:00
Dimitry Ivanov
04c7d3d257 Merge "Enable ifunc test for arm" 2016-04-04 20:25:21 +00:00
Elliott Hughes
e5f79381db Merge "Remove a workaround from stack_protector_test that's not needed in master." 2016-04-04 19:46:18 +00:00
Elliott Hughes
6b19f35f68 Merge "Move math headers in with the other headers." 2016-04-04 18:41:05 +00:00
Dimitry Ivanov
c967d89245 Enable ifunc test for arm
Bug: http://b/27930475
Change-Id: I1f9e7c5b9ffabfd77ae6ebd534938aef39ec7987
2016-04-04 11:28:41 -07:00
Daniel Micay
126ab12882 tests: allow brk to fail with ENOMEM
Any caller of brk needs to handle failure by falling back to mmap as
there's no guarantee that other mappings are not placed above the brk
heap. Since jemalloc starts with mmap in the first place and dlmalloc
knows how to fall back to mmap, it's already a legacy API in Android.

Forcing it to succeed rules out stronger ASLR implementations where the
brk heap might not have any room to grow. It's also valid for the brk
implementation to simply return -1 with errno set to ENOMEM in every
case and that's a good way of finding anything relying on it. It would
make sense for it to be an optional kernel feature.

The brk heap is also not guaranteed to be initially page aligned. PaX
ASLR randomizes the internal bits. It was only mentioned in a comment to
explain the design of the test though.

Bug: 24233096
Change-Id: I16e9bc8677e796c73915b830b99b0ce39c02b31d
2016-04-03 15:31:58 +00:00
Elliott Hughes
afe835d540 Move math headers in with the other headers.
Keeping them separate is a pain for the NDK, and doesn't help the platform.

Change-Id: I96b8beef307d4a956e9c0a899ad9315adc502582
2016-04-02 08:36:33 -07:00
Elliott Hughes
17fdd028da Remove a workaround from stack_protector_test that's not needed in master.
The compiler in master doesn't leave a gap between the buffer and the stack
guard canary.

Bug: http://b/27815668
Change-Id: Iae6681683881055c2719d661a2179f5305c23135
2016-04-01 21:02:25 -07:00
Elliott Hughes
6057d184f5 Fix the stack-protector test for x86/x86-64.
Built for fugu this was working fine, but built for generic x86/x86-64
the compiler was (a) optimizing out all the stack writes and (b) inserting
enough padding on x86-64 for the canary to be safely out of the way.

While here, let's tighten up this test so we test that it's sufficient to
only overwrite the buffer by one byte...

(cherry-pick of 6f90c1ac59eb4e7811b7b0e408615049c935c0a9.)

Bug: http://b/27815668
Change-Id: I80a646de4b30fd5c78df20fdaa7e3eb163585caf
2016-04-01 20:08:03 -07:00
Josh Gao
eaf50be332 Merge "Add a checksum to jmp_buf on mips and mips64." 2016-03-30 02:27:00 +00:00
Josh Gao
a42789f9d2 Merge changes from topic 'setjmp_checksum_x86'
* changes:
  Add a checksum to jmp_buf on x86_64.
  Delete lies from x86_64 setjmp implementation.
  Add a checksum to jmp_buf on x86.
2016-03-30 00:58:30 +00:00
Josh Gao
c244fcb8a3 Delete lies from x86_64 setjmp implementation.
Previously, the implementation of setjmp on x86_64 claimed that
sigprocmask would write to two longs' worth of bytes.

Bug: http://b/27856501
Change-Id: I9f32b40ac773a0cd91a976aace5bfba6e67fb0f8
2016-03-29 17:28:32 -07:00
Yabin Cui
78f5eb0498 Fix test getauxval.arm_has_AT_HWCAP2.
Bug: 27874785
Change-Id: Ibb39087c5353a0cca7783d39498b370e478fe91c
2016-03-29 15:41:49 -07:00
Dimitry Ivanov
19f5f6fcb7 Merge "linker: hide the pointer to soinfo" 2016-03-28 22:32:31 +00:00
Dimitry Ivanov
d88e1f3501 linker: hide the pointer to soinfo
Handle no longer is a pointer to soinfo of
a corresponding library. This is done to
prevent access to linker internal fields.

Bug: http://b/25593965
Change-Id: I62bff0d0e5b2dc842e6bf0babb30fcc4c000be24
2016-03-28 13:15:40 -07:00
Elliott Hughes
33a66222fa Merge "Don't bother insisting on AT_HWCAP2 for 32-bit devices." 2016-03-28 19:33:48 +00:00
Elliott Hughes
900a4dc5a8 Don't bother insisting on AT_HWCAP2 for 32-bit devices.
Bug: http://b/27874785
Change-Id: I9dcf345ae1221f665f267cba3ed9279435671b75
2016-03-28 11:53:12 -07:00
Greg Hackmann
d15dfb2ff5 clock_nanosleep: add CLOCK_THREAD_CPUTIME_ID special case
POSIX makes "the CPU-time clock of the calling thread" (i.e.,
CLOCK_THREAD_CPUTIME_ID) a special case which returns EINVAL instead of
ENOTSUP.

However, the clock_nanosleep syscall treats this clock just like any
other, and returns -EOPNOTSUPP to indicate an unimplemented nanosleep
handler.  So we need to handle this ourselves in userspace.

This change fixes the LTP clock_nanosleep01 testcase.

Change-Id: If3bed940d276834bcd114d8c17f96197e9384711
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-28 10:29:16 -07:00
Predrag Blagojevic
3299590dfe Add a checksum to jmp_buf on mips and mips64.
Make it easier to diagnose applications mucking with the contents of
jmp_buf by checksumming its contents.

Bug: http://b/27417786
Change-Id: I473bc2871dece23a9b9d02481945246160d671c6
2016-03-28 14:54:49 +00:00
Greg Hackmann
d132099e05 Merge "Add hasmntopt(3)" 2016-03-25 22:43:01 +00:00
Greg Hackmann
76640d5555 Merge "Add {get,set}domainname(2)" 2016-03-25 22:02:07 +00:00
Greg Hackmann
3679ade533 Add hasmntopt(3)
bionic has the Linux-specific mntent.h but is missing hasmntopt().

Change-Id: I0ab7b83626c969704add4e64b37a6fc715d4a723
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-25 14:16:58 -07:00
Greg Hackmann
e2faf07d65 Add {get,set}domainname(2)
{get,set}domainname aren't in POSIX but are widely-implemented
extensions.

The Linux kernel provides a setdomainname syscall but not a symmetric
getdomainname syscall, since it expects userspace to get the domain name
from uname(2).

Change-Id: I96726c242f4bb646c130b361688328b0b97269a0
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-25 14:16:58 -07:00
Greg Hackmann
2846ae70fb Merge "epoll_create: reject size <= 0" 2016-03-25 19:35:01 +00:00
Greg Hackmann
61cb584f9f Merge "clone: check for NULL child stack" 2016-03-25 19:34:44 +00:00
Elliott Hughes
d4c9112490 Fix the AT_HWCAP2 test.
"I have none of these capabilities" is a legitimate response, and
distinct from "I don't know what my capabilities are". It's the latter
I meant to test for.

Bug: http://b/27810985
Change-Id: Id165423e62390051cbf23fdda54f28d94566cbe7
2016-03-25 08:29:05 -07:00
Greg Hackmann
a03c62b469 epoll_create: reject size <= 0
Even though the size parameter to epoll_create(2) is (otherwise) unused,
passing in size <= 0 is explicitly documented as an error.

This change fixes the LTP epoll01 testcase.

Change-Id: I044a38be823c2fa956b57e77cc66571dfae8a4bb
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-24 16:37:20 -07:00
Greg Hackmann
fb23fa3046 clone: check for NULL child stack
The clone syscall accepts NULL child stacks, interpreting this to mean
the child gets a copy of the parent's stack with copy-on-write
semantics.  However clone(2) is explicitly documented to treat this an
an error.

"Fortunately" every architecture's __bionic_clone implementation pushes
something onto the child stack before making the clone syscall.  So we
know fixing this won't break legacy apps, because any app that tried
using a NULL child stack would have died with SIGSEGV.

This change fixes the LTP clone04 testcase.

Change-Id: I663b34f34bc8dad2aa405c46e4eed4418cccca0d
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-24 16:37:20 -07:00
Elliott Hughes
725b2a96a7 Add pthread_getname_np.
Also guard both these GNU extensions with _GNU_SOURCE.

Also improve the tests to test each case on both the current thread and
another thread, since the code paths are totally different.

Bug: http://b/27810459
Change-Id: I72b05bca5c5b6ca8ba4585b8edfb716a1c252f92
2016-03-23 17:40:25 -07:00
Yabin Cui
68a2f12304 Merge "Fix pthread.pthread_barrier_smoke test." 2016-03-23 02:32:41 +00:00
Yabin Cui
722072d65a CloseArchive() to free memory when OpenArchive fails.
Bug: 26962895
Change-Id: I42418eee320ddae857b42572690316c53f638e85
2016-03-22 16:43:24 -07:00
Yabin Cui
81d2797e33 Fix pthread.pthread_barrier_smoke test.
pthread_barrier_smoke test uses WaitUntilThreadSleep() to wait until
BarrierTestHelper threads sleep in pthread_barrier_wait(). But this
is flaky as there a two futex_wait places in pthread_barrier_wait.
This patch modifies this test to avoid using WaitUntilThreadSleep().

Bug: 27780937
Change-Id: I4c36b82cce9345d5088f8854b289dc5bf7a08e8c
2016-03-22 13:45:55 -07:00
Elliott Hughes
ebb4895c68 Add a CTS test to ensure AT_HWCAP2 is reported.
This is important for performance of 32-bit ARM crypto code in apps.

Bug: http://b/27750752
Change-Id: If1cebc4d562aeb2ae0cc2834135af16e9bd0f79a
2016-03-21 11:13:16 -07:00