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
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
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
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
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
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
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
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
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
This fixes the mips build broken by
I7d8a7d79585477d78da1f033c85f8d2cc3b34340.
Change-Id: Ib960bdb51ac81be068f1fdf702aa7c10b183f2a0
Test: lunch mips && cd bionic && mma
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
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