Commit Graph

3739 Commits

Author SHA1 Message Date
kamil
869dfc9042 Add support for multiple threads in kcov(4)
Reuse the fd_clone() API to associate kcov descriptors (KD) with a file
descriptor. Each fd (/dev/kcov) can be reused for a single LWP.

Add new ATF regression tests and cleanup existing code there. All tests
pass.

Refresh the kcov(4) man page documentation.

Developed with help from <maxv>.
2019-03-10 12:54:39 +00:00
kamil
37db6ba904 Remove expected fail in various ATF t_ptrace_wait* tests
Tests for trap signal scenarios no longer fail.
2019-03-08 23:35:01 +00:00
msaitoh
659e7a3c69 s/ are are / are /
s/ a a / a /
2019-03-08 08:35:58 +00:00
christos
f0d208fdc0 add joins 2019-03-06 01:20:15 +00:00
kamil
adcf58e010 Refactor signal6-8 tests in t_ptrace_wait*
Transform original tests into new ones:
 - fork_singalmasked
 - fork_singalignored
 - vfork_singalmasked
 - vfork_singalignored
 - vforkdone_singalmasked
 - vforkdone_singalignored

All the signalignored ones pass, the remaining ones of them fail.
2019-03-02 01:01:20 +00:00
isaki
4229f721ac Revert previous hack.
Now all libc have __sync_and_and_fetch functions.
2019-03-01 05:39:01 +00:00
christos
600c236c7b Make the _and_and_ have-nots compile. 2019-02-27 15:32:11 +00:00
maxv
7a4f551dcf Change the layout of the SEG state:
- Reorder it, to match the CPU encoding. This is the universal order,
   also used by Qemu. Drop the seg_to_nvmm[] tables.

 - Compress it. This divides its size by two.

 - Rename some of its fields, to better match the x86 spec. Also, take S
   out of Type, this was a NetBSD-ism that was likely confusing to other
   people.
2019-02-26 12:23:12 +00:00
isaki
8116c33ceb Add ATF tests for __sync_* functions instead of all_sync_ops_linkable.c 2019-02-26 10:01:40 +00:00
kamil
0e39f4bfc0 Fix build of t_kcov
Correct the syntax that used to work in earlier uncommitted version.
2019-02-25 10:23:01 +00:00
kamil
9dee33b7ea Add KCOV_LOAD() and KCOV_STORE() - new helper macros
New macros prefer 64-bit atomic operations whenever accessible.

As a fallback they use volatile move operations that are not known
to have negative effect in KCOV even if interrupted in the middle of
operation.

Enable kcov_basic and kcov_thread tests on targets without
__HAVE_ATOMIC64_OPS.
2019-02-24 21:14:43 +00:00
kamil
c5cd46777b Drop signal5 test-case from ATF t_ptrace_wait*
This test is now duplicated with traceme_signalmasked_exec.
2019-02-23 20:52:42 +00:00
kamil
71299c6f1d Add signal masked and ignored variations of traceme_exec in ATF tests
All tests pass.
2019-02-23 20:46:27 +00:00
kamil
0327411d8a Add signal masked and ignored variations of traceme_vfork_exec in ATF tests
All tests pass.
2019-02-23 18:07:47 +00:00
kamil
5577155981 Fix build of kcov tests on CPUs without 64-bit atomics
Restrict the 64-bit atomics to ports defining __HAVE_ATOMIC64_OPS.

Using 64-bit atomics is still good for i586 fuzzing, but the tests are
build for earlier CPUs. This makes this code to be disabled in i386 builds.

There is a similar situation with few other ports that offer 64-bit atomics
in certain CPU models and ABIs.
2019-02-23 08:03:24 +00:00
kamil
0fe7e51662 Add KCOV - kernel code coverage tracing device
The KCOV driver implements collection of code coverage inside the kernel.
It can be enabled on a per process basis from userland, allowing the kernel
program counter to be collected during syscalls triggered by the same
process.

The device is oriented towards kernel fuzzers, in particular syzkaller.

Currently the only supported coverage type is -fsanitize-coverage=trace-pc.

The KCOV driver was initially developed in Linux. A driver based on the
same concept was then implemented in FreeBSD and OpenBSD.

Documentation is borrowed from OpenBSD and ATF tests from FreeBSD.

This patch has been prepared by Siddharth Muralee, improved by <maxv>
and polished by myself before importing into the mainline tree.

All ATF tests pass.
2019-02-23 03:10:05 +00:00
kamil
a3c646ca3f Unify the style of t_ubsan tests
Apply similar change for load_invalid_value_bool in
test_load_invalid_value_enum.

Follow up of PR bin/53968 by Michael van Elst
2019-02-20 11:40:41 +00:00
kamil
dc43916dcf Try to make load_invalid_value_bool portable to Big-Endian
PR bin/53968 by Michael van Elst
2019-02-20 09:50:09 +00:00
kamil
b07a2df4fa Replace signal4 (PT_STEP) test with refactored ones with extra asserts
New tests: step_signalmasked and step_signalignored.

Assert that signal context is not reset upon PT_STEP trap.

Mark new tests as expecting to fail.
2019-02-20 09:25:11 +00:00
kamil
a0995bf67f Add more tests for variations of unrelated_tracer_sees_crash in ATF
New tests:
 - unrelated_tracer_sees_signalmasked_crash_trap
 - unrelated_tracer_sees_signalmasked_crash_segv
 - unrelated_tracer_sees_signalmasked_crash_ill
 - unrelated_tracer_sees_signalmasked_crash_fpe
 - unrelated_tracer_sees_signalmasked_crash_bus
 - unrelated_tracer_sees_signalignored_crash_trap
 - unrelated_tracer_sees_signalignored_crash_segv
 - unrelated_tracer_sees_signalignored_crash_ill
 - unrelated_tracer_sees_signalignored_crash_fpe
 - unrelated_tracer_sees_signalignored_crash_bus

All these tests are failing with the current kernel.
2019-02-20 07:18:18 +00:00
kamil
383b4e94a2 Add minor improvements in unrelated_tracer_sees_crash in t_ptrace_wait*
Switch forkee commands with asserts to be aligned for the purpose of being
used by forkees.
2019-02-20 05:20:05 +00:00
isaki
ecae8bc568 Add ATF tests for atomic_ops(3). 2019-02-17 12:24:17 +00:00
kamil
144442f947 Add new ATF t_ptrace_wait* vfork(2) tests
Add traceme_vfork_signalmasked_crash and traceme_vfork_signalignored_crash
tests for crash signals (SIGTRAP, SIGSEGV, SIGILL, SIGFPE, SIGBUS).

These new scenario assert that signal masked/ignored are delivered to
vfork(2)ed child.

All tests pass.
2019-02-17 09:29:35 +00:00
kamil
f3e7347b92 Remove redundant test from ATF t_ptrace_wait*
signal3 duplicates traceme_signalmasked_crash(SIGSEGV)
2019-02-17 05:21:49 +00:00
kamil
94af723a9a Add additional assert in traceme_signalignored_crash t_ptrace_wait* tests
Check whether sigignore is not reset on a trapsignal under a debugger.
The expected behavior is to not reset it. A side effect of resetting
signal mask is noticable especially with a software/hardware breakpoint
that changes state of a process.

Mark these tests as failing.
2019-02-17 04:57:09 +00:00
kamil
f42cdc6585 Add additional assert in traceme_signalmasked_crash t_ptrace_wait* tests
Check whether signal mask is not reset on a trapsignal under a debugger.
The expected behavior is to not reset it. A side effect of resetting
signal mask is noticable especially with a software/hardware breakpoint
that changes state of a process.

Mark these tests as failing.
2019-02-17 04:19:39 +00:00
mgorny
f5c01693d5 Fix reporting EOF via kevent and add a test case
Fix the kernel pty driver to report closed slave via master's kevent
EVFILT_READ.  This behavior matches the behavior for pipes, is
consistent with how FreeBSD implements it and is relied upon by LLDB's
main loop implementation.

Includes feedback by kre and kamil (from tech-kern), commit approved
by kamil.
2019-02-15 18:57:15 +00:00
kamil
53cc2476a7 Add new ATF tests traceme_signal{ignored,masked}_crash* in t_ptrace_wait*
New tests verify that crashes (from trap signals) are delivered to tracer
regardless of the signal masking or signal ignoring option enabled in the
traced child.

All tests pass.

In close future these tests will obtain additional asserts.
2019-02-15 05:06:38 +00:00
kamil
d5a7a3281b Add new ATF tests traceme_raisesignal_ignored in t_ptrace_wait*
Verify that ignoring (with SIG_IGN) in tracee
does not stop tracer from catching this raised signal.

Cover crash signals and already covered ones in other tests.

All tests pass.
2019-02-15 04:11:39 +00:00
mrg
2358f4548e implement return_one for hppa, mips, ppc64, and vax. 2019-02-14 10:36:33 +00:00
kamil
c26a89103c Replace signal2 in t_ptrace_wait* with new tests
Add new tests traceme_raisesignal_masked[1-8].

New tests to verify that masking (with SIG_BLOCK) signal in tracee
stops tracer from catching this raised signal. Masked crash signals are
invisible to tracer as well.

All tests pass.
2019-02-14 06:47:32 +00:00
kamil
0c1b4f39e5 Add new regression scenarios for crash signals in t_ptrace_wait*
Verify correct behavior of crash signals (SIGTRAP, SIGBUS, SIGILL, SIGFPE,
SIGSEGV) in existing test scenarios:
 - traceme_raise
 - traceme_sendsignal_handle
 - traceme_sendsignal_masked
 - traceme_sendsignal_ignored
 - traceme_sendsignal_simple
 - traceme_vfork_raise

These tests verify signals out of the context of CPU trap. These new tests
will help to retain expected behavior in future changes in semantics of
the trapsignals in the kernel.
2019-02-14 05:38:45 +00:00
kamil
e3a629e53f Rename signal1 to signal_mask_unrelated in t_ptrace_wait*
No functional change intended.
2019-02-12 21:35:35 +00:00
kamil
7439bd598d Refactor lwp_create1 and lwp_exit1 into trace_thread* in ptrace(2) tests
New tests:
 - trace_thread1
 - trace_thread2
 - trace_thread3
 - trace_thread4

These tests verify _lwp_create(2) and _lwp_exit(2) events. They are
currently skipped as not reliable.
2019-02-12 06:00:05 +00:00
kamil
2d4745f8b2 Rename the siginfo4 test in ATF t_ptrace_wait*
The siginfo group of ptrace(2) tests has been replaced with new individual
tests or merged into existing ones. This is the last siginfo* test that
has been renamed.

New name: traceme_exec.
2019-02-11 05:59:00 +00:00
kamil
32c33d29c1 Merge siginfo6 into other PT_STEP tests in t_ptrace_wait* 2019-02-11 05:51:20 +00:00
kamil
bfae04bf15 Drop siginfo5 from ATF tests in t_ptrace_wait*
siginfo5 duplicates older tests verifying PTRACE_FORK.
2019-02-11 04:20:06 +00:00
kamil
bc00947fe2 Initial refactoring of siginfo* tests in t_ptrace_wait*
Drop test siginfo1 as duplicated with earlier tests.

Rework and rename siginfo2 and siginfo3 into a single test body.

New tests:
 - siginfo_set_unmodified (replaces siginfo2)
 - siginfo_set_faked (replaces siginfo3)

All new tests pass.
2019-02-11 04:13:28 +00:00
mlelstv
82fe3e95ba provide a test function, avoids crashing tests with SIGSEGV. 2019-02-10 09:54:39 +00:00
kamil
5a04cbf366 Link t_ptrace_wait* tests with -pthread
While there, bump (c) for ATF ptrace(2) tests.

Add __used in infinite_thread() for consistency with other functions in
the file.
2019-02-10 02:13:45 +00:00
kamil
8ac77c305d Add initial pthread(3) tests in ATF t_prace_wait* tests
There were tested few scenarios with native _lwp_create(2) functions, using
this interface is not needed and it's easier to manage tests with
high-level pthread(3) API.

Rewrite original lwpinfo1 and lwpinfo2 tests into 8 new tests:
 - traceme_lwpinfo0 (0 spawned additional threads)
 - traceme_lwpinfo1 (1 spawned additional thread)
 - traceme_lwpinfo2 (2 spawned additional threads)
 - traceme_lwpinfo3 (3 spawned additional threads)
 - attach_lwpinfo0 (0 spawned additional threads)
 - attach_lwpinfo1 (1 spawned additional thread)
 - attach_lwpinfo2 (2 spawned additional threads)
 - attach_lwpinfo3 (3 spawned additional threads)

These tests verify primarily the PT_LWPINFO interface.

Build the t_ptrace_wait* tests with -pthread.

All tests pass.
2019-02-10 02:04:06 +00:00
kamil
fb7fe14f74 Add infinite_thread() for ptrace(2) ATF tests
infinite_thread() is designed to be spawned as a pthread(3) function.

It will be used soon in new tests.
2019-02-09 23:10:42 +00:00
scole
a253ff12d9 use HAVE_FPREGS not HAVE_FPGPREGS and move some register_t inside proper #define. fixes ia64 build. ok <kamil> 2019-02-09 23:03:01 +00:00
mrg
01ef24fd3f fix hello_profile's hello_profile_head function name. 2019-02-09 02:36:28 +00:00
mrg
f4fc04f995 add $NetBSD$ tags. 2019-02-09 00:13:19 +00:00
mrg
9ca42b4c5e add very simple test that you can link -fopenmp.
currently fails, but should work soon...
2019-02-09 00:12:14 +00:00
kamil
120dbb13e3 Refactor kill* test in t_ptrace_wait*
Drop original scenario of kill1 (PT_CONTINUE(SIGKILL)) as it duplicates
traceme_sendsignal_simple1.

New kill tests:
 - kill1: ptrace(PT_KILL) (previously kill2)
 - kill2: kill(SIGKILL)
 - kill3: killpg(SIGKILL)

All kill* tests share the same function body.

All tests pass.
2019-02-08 03:08:00 +00:00
kamil
fe7f44d815 Correct a style in description of PT_STEP tests in t_ptrace_wait* 2019-02-08 00:31:46 +00:00
kamil
60980e6752 Refactor definition of PT_STEP tests into single macro
No functional change intended.
2019-02-08 00:29:41 +00:00
kamil
c18cba814b Refactor GPR and FPR tests in t_ptrace_wait* tests
This change deduplicates the code and puts all the test into shared
function body.

No functional change except ranaming tests regs* to access_regs* and
fpregs* to access_fpregs*.
2019-02-07 23:03:33 +00:00