Commit graph

19 commits

Author SHA1 Message Date
Evgeny Eltsin
bd1c63065e Fix sys_ptrace_test feature check on arm64
The code was checking PTRACE_GETREGSET output even in case of error.
This seems not correct. Though ptrace can still write some output in
case of EINVAL, implementation should still check updated iov_len before
reading it.

Change the code to avoid checking output in case of error at all.

Test: bionic-unit-tests --gtest_filter=sys_ptrace.watchpoint_stress
Change-Id: I7b1ca18ac64f81055ff89f56b453aff0ce8e1057
2019-12-11 15:42:04 +01:00
Christopher Ferris
103b998a52 Stop executing if skip occurs.
Bug: 141358530

Test: Forced a skip and verified it registers as a skip.
Change-Id: I9915c67ebae4389a26f28e16375ad4a41f3e4837
2019-09-23 09:41:13 -07:00
Yi Kong
358603a409 Modernise code to use override specifier
Generated by clang-tidy.

Test: m checkbuild
Change-Id: I8e23da6b8af31b291be2eefe9937ca222ea8a8c3
2019-03-29 14:27:27 -07:00
Elliott Hughes
bcaa454d32 bionic tests: use GTEST_SKIP.
Also be a bit more to the point in our messages, focusing on "why" not
"what".

Test: ran tests
Change-Id: I297806c7a102bd52602dcd2fcf7a2cd34aba3a11
2019-03-12 10:26:39 -07:00
Evgenii Stepanov
7cc6706370 Cleanup bionic tests with hwasan.
The tests were patched earlier to run with tagging heap allocator.
This change enables hwasan code instrumentation in the tests themselves,
and fixes the issues that arise, mainly in the code that:
* compares addresses of unrelated stack variables
* compares address of a stack variable with stack limits as found in
  /proc/self/maps
* writes address of a stack variable to a hardware watchpoint register
etc.

Note that static tests are broken at the moment, like all static
binaries. Dynamic tests pass 100% with this change.

Bug: 114279110, 124007027
Test: SANITIZE_TARGET=hwaddress; run dynamic bionic tests

Change-Id: I68b8df9dd3e30b47734ddc083811a75a7f27deaa
2019-02-06 13:59:16 -08:00
Luis Hector Chavez
7300d83b2e Make sys_ptrace_test.cpp Yama LSM-aware
This change enables the tracer process to be able to call ptrace(2) on
the worker process, which is does not have a direct-ancestor dependency.

Bug: 77146512
Test: adb shell \
      /data/nativetest{,64}/bionic-unit-tests{,-static}/bionic-unit-tests-{,-static} \
      --gtest_filter='spawn*'  # aosp_sailfish and Chrome OS
Test: cts-tradefed run singleCommand cts --skip-preconditions \
      -m CtsBionicTestCases --test 'PtraceResumptionTest*'  # aosp_sailfish
                                                            # and Chrome OS
Change-Id: I9e41b3ddde64c0623ba9299cede9d5b2001c8e30
2018-04-04 14:10:57 -07:00
Yabin Cui
143b454ae5 Remove timeout signal in ptrace test.
Bionic gtest runner kills a test when it runs over 90s, so there
is no need to use timeout signal in ptrace test.

Bug: http://b/69525592
Test: run bionic-unit-tests.
Change-Id: I767b81a412724ee40fb0f031103a1f05bd7358c4
2017-11-29 11:05:57 -08:00
Elliott Hughes
cabc77f917 Always wrap waitpid in TEMP_FAILURE_RETRY.
Strictly not needed in the WNOHANG case, but it's probably best to have
every waitpid wrapped for future copy & pasters.

Bug: https://issuetracker.google.com/69525592
Test: ran tests
Change-Id: I013b0a52d2753e3d32638e9b84c79af7327fb405
2017-11-28 12:55:19 -08:00
Pavel Labath
95d8fb1e84 sys_ptrace_test: Better detect missing HW support
If the hardware debug support is missing from the CPU, the kernel can
end up in the state where it reports that it supports N(>0) watchpoints,
but the "maximum supported watchpoint size" is zero.

This is not a really sensible API, but it is what we have. I'm going to
speak to folks upstream about whether we can have it report something
more sensible, but that will take a while (if ever).

So, for the time being, detect this situation and treat it as if no
hardware watchtpoints/breakpoints are supported.

Test: bionic-unit-tests --gtest_filter="sys_ptrace.*"
Change-Id: Id6a013c9bec8d8b450b4a36c28431f6b7fd15879
Bug: 63116544
2017-07-10 12:52:35 +00:00
Pavel Labath
4a6202683a watchpoint_imprecise test: set 4-byte watchpoints on 32-bit arches
8-byte watchpoints are not supported on 32-bit kernels (at least on x86,
probably arm as well). 8-byte watchpoints are not required for this
test, so just decrease the size of watchpoints on these architectures.

Change-Id: Ie96b4bc8ce0ad8c924ac737083cf9fe0182aee4d
Test: bionic-unit-tests-static --gtest_filter=sys_ptrace.*
Bug: 37662849
2017-04-26 11:33:17 +01:00
Josh Gao
bc055cae45 Add more ptrace process resumption tests.
Add tests to verify that ptrace unlink happens immediately for unreaped
processes.

Test: /data/nativetest/bionic-unit-tests/bionic-unit-tests --gtest_filter="Ptrace*"
Test: /data/nativetest64/bionic-unit-tests/bionic-unit-tests --gtest_filter="Ptrace*"
Change-Id: I9803ee5be2a0686c21556598ecf17348df09f601
2017-03-29 15:02:18 -07:00
Pavel Labath
fb5a6396dc Silence a compiler warning due to unused variable on mips
oops, I did it again.

Test: lunch mips && cd bionic && mma
Change-Id: I1fe2cb847d0698b34766869f9626398dbcf81960
2017-02-24 10:20:54 +00:00
Pavel Labath
3dad8d5d07 Add "imprecise" watchpoint ptrace test
This tests for the presence of a kernel bug that meant that the kernel
would sometimes fail to report the watchpoint hit if the hardware
reported a address which did not exactly match the address range being
watched (which it is allowed to do per ARM spec if the instruction
accesses a larger block of memory than the region being watched). This
bug was fixed in linux kernel 4.9, and has been backported to older
android kernels.

Bug: 30802222
Bug: 30919905
Test: bionic-unit-tests --gtest_filter="sys_ptrace.*"
Change-Id: I80c35b29eaf28e2dbacb9e8ee5317fdea653fc87
2017-02-24 09:16:06 +00:00
Josh Gao
5e3fe9506c Add tests for ptrace resumption behavior.
Add tests that ensure that the kernel behaves properly w.r.t.
resumption of ptraced processes when the tracer dies.

Bug: http://b/34516140
Test: /data/nativetest/bionic-unit-tests/bionic-unit-tests --gtest_filter="PtraceResumption*"
Change-Id: Id35e069a7e5edd6964637dd3f6358ad59db19792
2017-02-16 14:15:42 -08:00
Pavel Labath
bb9713dd91 Silence unused variable warning in sys_ptrace_test
This fixes the mips build broken by
I7d8a7d79585477d78da1f033c85f8d2cc3b34340.

Change-Id: Ib960bdb51ac81be068f1fdf702aa7c10b183f2a0
Test: lunch mips && cd bionic && mma
2017-01-27 13:06:22 +00:00
Pavel Labath
fb082ee00c Add hardware breakpoint ptrace test
This adds a ptrace test which tests the hardware breakpoint
functionality of the ptrace api.

I've also renamed the test case to sys_ptrace to better match the naming
scheme in the other files. I've ran the tests on angler (32 and 64 bit)
and fugu.

Test: run the test
Change-Id: I7d8a7d79585477d78da1f033c85f8d2cc3b34340
2017-01-27 12:39:32 +00:00
Josh Gao
b36efa4343 Fix instances of '#if __LP64__'.
Triggers -Wundef, which is on in -Weverything.

Bug: http://b/31496165
Change-Id: Ib06107073f7dd1d584c19c222d0430da9d35630b
2016-09-15 14:21:28 -07:00
Chih-Hung Hsieh
62e3a078aa Fix google-explicit-constructor warnings.
Bug: 28341362
Change-Id: I84effbdfa1b9b39328a909b7f70fe17e7ee316c8
2016-05-03 12:08:05 -07:00
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