Commit Graph

3637 Commits

Author SHA1 Message Date
maya b4dd0f8b48 Test for FE_INVALID in a way that works for powerpc too.
powerpc seems to return FE_INVALID | FE_VXSOFT rather than just FE_INVALID.
XXX need extra careful reading of standards
2018-06-14 21:11:08 +00:00
yamaguchi c9cc6dd9e6 Update the error message in t_vlan (ENXIO => EINVAL)
ok ozaki-r@
2018-06-14 08:38:24 +00:00
yamaguchi 9de5f4c04e Add test cases for multicast address handling of vlan(4)
ok ozaki-r@
2018-06-14 08:22:52 +00:00
kamil 00a8c5e713 Add 2 new expr(1) ATF tests
Assert that -9223372036854775808 % -1 and -9223372036854775808 / -1 return
message about overflow / underflow detected.

These tests pass correctly.

Sponsored by <The NetBSD Foundation>
2018-06-12 18:54:39 +00:00
ozaki-r 9da465c4ef Add tests of vlan with bridge
The tests trigger a panic reported in PR kern/53357.
2018-06-12 04:21:22 +00:00
kamil 082a177931 Fix previous
The failing tests are for vfork(2), not fork(2).
2018-06-06 13:18:44 +00:00
kamil 396963258b Mark sigbus ATF tests in t_ptrace_wait as expected failure
They are breaking right now on all ports.

lib/53343
2018-06-06 13:16:32 +00:00
maya 3ca192b76c Blindly add __TEST_FENV in the hope of fixing the vax build.
(So we can include fenv.h, and then not use it - we ifdef vax out
for OS-portability reasons.)
2018-06-04 09:13:47 +00:00
maya 0161d86987 use ATF_CHECK instead of ATF_REQUIRE
(continue on failure, to see the rest of the failures)

From Ngie Cooper in PR bin/51834
2018-06-03 08:48:37 +00:00
maya 2b3568b36a Test and clear exception around scalbn calls.
Second part of PR bin/51834.

ifdef out vax to avoid netbsd-specific macros.
2018-06-03 08:39:00 +00:00
kre 8c02aa5477 80 column police. Some KNF and whitespace corrections (until I got bored...)
NFCI.
2018-06-01 05:48:29 +00:00
mrg 5d873ca56c make 'clean' and/or 'cleandir' actually clean all the things. 2018-05-31 09:08:25 +00:00
kamil 6abbe0506f Add a comment for the workaround in trigger_bus()
Explain PROT_READ|PROT_WRITE.
2018-05-30 17:48:13 +00:00
kamil 398835f368 Make the trigger_bus() test compatible with more CPUs (at least ALPHA)
If we write a byte character into a pointer, a compiler can emit a
read-modify-write operation, especially when a CPU cannot access directly
a character wide address.

In this scenario calling mmap(2) with PROT_WRITE, without PROT_READ will
emit unexpected trap.

There are two possible workarounds for this issue:
 - write register wide memory without rmw sequence,
 - mark the region with additional protection PROT_READ

Both work for NetBSD/alpha.

Go for the latter as perhaps more safe for dump compilers emitting rmw
sequences.

Investigated by <martin>
2018-05-30 17:31:34 +00:00
kre 64d884c8fc The bytes_transfer_piod_read_auxv test uses 4096 for the size param
to bytes_transfer() which asserted that the size is < the size of 512 AuxInfo
structs.   On a 32 bit system, an AuxInfo is 8 bytes, and 512 AuxInfo
structs is thus 4096 bytes, and 4096 is not < 4096, so the assertion
failed.   It would probably work as a <= assert, but I am not confident
enough with this test case to make that call, so instead increase the
array size to be 513 instead, 4096 is < 513*8 so happiness should return
and all should be right with the world.   At least for this one test.
(There was no problem on 64 bit systems as AuxInfo is bigger there.)
2018-05-30 05:09:11 +00:00
kamil fa04ee6693 Add new ATF ptrace(2) tests verifying crash signal handling
Add new tests:
 - traceme_crash_trap
 - traceme_crash_segv
 - traceme_crash_ill (temporarily disabled)
 - traceme_crash_fpe
 - traceme_crash_bus
 - unrelated_tracer_sees_crash_trap
 - unrelated_tracer_sees_crash_segv
 - unrelated_tracer_sees_crash_ill (temporarily disabled)
 - unrelated_tracer_sees_crash_fpe
 - unrelated_tracer_sees_crash_bus

These tests verify two subtle kernel paths that differ internally:
 - for a tracer that is a parent of a traced program (and not vforked)
   real parent == tracer
 - for a tracer that is an unrelated process of a traced program
   real parent != tracer

Regressions in the signal code can cause to break one of the scenarios, and
keep working the other one. It might be propagated to a scenario like:
 - attaching to a process with a debugger (over pid)
 - starting a process inside a debugger

We can assert on the ATF level that both will be functional.

While there, cover all the crash signals as testing is done practically
for free. While the Machine Independent signal routing code for crash
signals is mostly the same in the kernel, we can verify whether Machine
Dependent parts works as expected emitting the proper signal number and
signal code (si_code).

There have been already caught an unexpected behavior on Alpha, that
instead of SIGBUS we receive SIGSEGV.

Another benefit is that it's easier to catch races, as they pop up more
frequently. (This already helped to catch bugs more quickly)

These tests will help assert correctness of future kernel changes in the
signal routines.

All tests pass.

Sponsored by <The NetBSD Foundation>
2018-05-29 10:40:54 +00:00
kamil 52922ac661 Correct the t_ptrace_wait*:signal5 ATF test case
This functionality now works.
Correct the code path in this test.
Add additional sanity check with PT_GET_SIGINFO and validating si_code.

Sponsored by <The NetBSD Foundation>
2018-05-28 11:35:50 +00:00
kamil ccd167ce5f Drop trailing white space 2018-05-28 11:15:48 +00:00
martin 6ad8477b8b PR port-amd64/53316: two int don't make a long (when passed to
a C variadic function)
2018-05-28 07:55:56 +00:00
kamil d93c7a0a6b Try to fool $CC harder in ATF ptrace(2) tests in trigger_fpe()
A function that returns a value that is not used, can be optimized out by
a compiler. Try to fool the compiler with calling libc functions that shall
trigger a division by zero crash.

Sponsored by <The NetBSD Foundation>
2018-05-27 17:16:39 +00:00
kamil 49994bfcd7 Handle FPE and BUS scenarios in the ATF t_trapsignal tests
These crash signals are crucial for proper handling of abnormal conditions
in a program. The additional purpose of these tests it to assure the proper
handling of these signals for the coming ptrace(2)-related changes in the
signal routing code.

Add a stub for ILL scenarios.

All tests pass (on amd64).

The shell ATF script contains duplicated code. There should be a way to
deduplicate it, without rewrite to C.

Sponsored by <The NetBSD Foundation>
2018-05-27 17:04:45 +00:00
kamil 223c019e6d Fix ATF ptrace(2) bytes_transfer_piod_read_auxv test
Make the initial buffer larger to stop triggering the runtime assert about
its size.

Its size is probably larger than all real use cases, but it's good enough
for the purpose of ATF tests and immune of potential AUXV size.

Sponsored by <The NetBSD Foundation>
2018-05-27 08:08:24 +00:00
christos d25ad815ca alloca, bad; stack protector, good. 2018-05-27 00:36:56 +00:00
kamil 4ee7ae6051 Port the CVE 2018-8897 mitigation to i386 ATF ptrace(2) tests
On i386 there is no need to switch execution mode.
Use 0x23 SS selector for i386, amd64 used 0x4f.

Based on pointers from <maxv>.

Sponsored by <The NetBSD Foundation>
2018-05-26 20:27:48 +00:00
kamil 1aca04ce92 Refactor the PT_WRITE*/PT_READ* and PIOD_* ATF ptrace(2) tests
Merge all the PT_WRITE*/PT_READ* and PIOD_* the test cases into the common
body.

Changes:
 - treat D and I variations exactly the same
 - stop testing 2-3-4 attempts to perform the same read/write operation
 - stop testing interlocked (handshake) read/write operations
 - rename the tests
 - test write to .text section (with D and I type of operations)

New tests:
 - bytes_transfer_piod_read_d_8
 - bytes_transfer_piod_read_d_16
 - bytes_transfer_piod_read_d_32
 - bytes_transfer_piod_read_d_64
 - bytes_transfer_piod_read_i_8
 - bytes_transfer_piod_read_i_16
 - bytes_transfer_piod_read_i_32
 - bytes_transfer_piod_read_i_64
 - bytes_transfer_piod_write_d_8
 - bytes_transfer_piod_write_d_16
 - bytes_transfer_piod_write_d_32
 - bytes_transfer_piod_write_d_64
 - bytes_transfer_piod_write_i_8
 - bytes_transfer_piod_write_i_16
 - bytes_transfer_piod_write_i_32
 - bytes_transfer_piod_write_i_64
 - bytes_transfer_read_d
 - bytes_transfer_read_i
 - bytes_transfer_write_d
 - bytes_transfer_write_i
 - bytes_transfer_piod_read_d_8_text
 - bytes_transfer_piod_read_d_16_text
 - bytes_transfer_piod_read_d_32_text
 - bytes_transfer_piod_read_d_64_text
 - bytes_transfer_piod_read_i_8_text
 - bytes_transfer_piod_read_i_16_text
 - bytes_transfer_piod_read_i_32_text
 - bytes_transfer_piod_read_i_64_text
 - bytes_transfer_piod_write_d_8_text
 - bytes_transfer_piod_write_d_16_text
 - bytes_transfer_piod_write_d_32_text
 - bytes_transfer_piod_write_d_64_text
 - bytes_transfer_piod_write_i_8_text
 - bytes_transfer_piod_write_i_16_text
 - bytes_transfer_piod_write_i_32_text
 - bytes_transfer_piod_write_i_64_text
 - bytes_transfer_read_d_text
 - bytes_transfer_read_i_text
 - bytes_transfer_write_d_text
 - bytes_transfer_write_i_text
 - bytes_transfer_piod_read_auxv

These tests are now covering all usual code paths.

All tests pass.
The PaX MPROTECT violating ones automatically detect whether to be skipped.

Eliminated 4x more code than removed.

Sponsored by <The NetBSD Foundation>
2018-05-26 15:32:31 +00:00
kamil 49ea5747bf Introduce can_we_write_to_text() to ATF ptrace(2) tests
The purpose of this function is to detect whether a tracer can write to the
.text section of its tracee.

Sponsored by <The NetBSD Foundation>
2018-05-26 15:15:17 +00:00
martin 14167a96a3 Fix typo in local macro name, pointed out by uwe 2018-05-25 16:30:03 +00:00
martin b11873986d Add a test to verify syscall() and/or __syscall() are working.
This used to trigger a panic (see PR kern/53261) on arm.
2018-05-25 15:42:30 +00:00
kamil 5b4f05b5be Try to fix 32-bit build
Cast pointer to uintptr_t rather than uintmax_t.
2018-05-24 08:28:40 +00:00
kamil e73d44d16d Merge the eventmask[1-6] ATF ptrace(2) tests into a shared function body
While there, rename the tests to:
 - eventmask_preserved_empty
 - eventmask_preserved_fork
 - eventmask_preserved_lwp_create
 - eventmask_preserved_lwp_exit
 - eventmask_preserved_vfork
 - eventmask_preserved_vfork_done

Sponsored by <The NetBSD Foundation>
2018-05-23 23:56:07 +00:00
kamil 7060760a3a Extend traceme_vfork_breakpoint in ATF ptrace(2) tests for more scenarios
traceme_vfork_breakpoint used to test SIGTRAP event. Reuse its code for:
SIGSEGV, SIGILL, SIGFPE and SIGBUS.

The SIGILL case is disabled as of now as it required addition of
PTRACE_ILLEGAL_ASM in MD ptrace(2) headers.

Added tests:
 - traceme_vfork_crash_trap
 - traceme_vfork_crash_segv (renamed from traceme_vfork_breakpoint)
 - traceme_vfork_crash_ill (disabled)
 - traceme_vfork_crash_fpe
 - traceme_vfork_crash_bus

All enabled tests pass.

Sponsored by <The NetBSD Foundation>
2018-05-23 13:51:27 +00:00
kamil 20c82f105a Add new auxiliary functions in ATF ptrace(2) tests
Introduce:
 - trigger_trap()
 - trigger_segv()
 - trigger_ill()
 - trigger_fpe()
 - trigger_bus()

These functions generate appropriate signals caused by crashes.

A debugger is required to collect the crashes regardless of signal masking,
catching or ignoring rules.

While there, append __used argument to can_we_set_dbregs().

Sponsored by <The NetBSD Foundation>
2018-05-23 13:18:09 +00:00
kamil 9b1435470a Refactor the attach[1-8] and race1 ATF t_ptrace_wait* tests
Share code in: attach1, attach2 and race1 in the same function body.
Rename thsee tests to more verbose names:
 - tracer_sees_terminaton_before_the_parent
 - tracer_sysctl_lookup_without_duplicates
 - unrelated_tracer_sees_terminaton_before_the_parent

Rename attach3 to parent_attach_to_its_child.

Rename attach4 to child_attach_to_its_parent.

Share code in attach5, attach6 and attach7 in the same function body and
reanem the tests to:
 - tracee_sees_its_original_parent_getppid
 - tracee_sees_its_original_parent_sysctl_kinfo_proc2
 - tracee_sees_its_original_parent_procfs_status

Reduce the code by around 50%.

No functional change intended. All tests pass.

Sponsored by <The NetBSD Foundation>
2018-05-23 01:29:43 +00:00
kamil 7cc9be7372 Add new ATF ptrace(2) tests: traceme_sendsignal_{masked,ignored}[1-3]
These tests emit signal from a tracer/parent to the child and verify the
behavior in the case of SIG_BLOCK (masked) and SIG_IGN (ignored).

The signal is not reported by the child process.

These tests pass.

While there, rename for consistency with other tests:
 - traceme_sighandler_catch[1-3] -> traceme_sendsignal_handle[1-3]
 - traceme_signal_nohandler[1-5] -> traceme_sendsignal_simple[1-5]

Sponsored by <The NetBSD Foundation>
2018-05-22 10:48:06 +00:00
kamil aaef92583a Extend ATF tests in t_trapsignal.sh to verify software breakpoint traps
There are at least four types of SIGTRAP events:
 - software/hardware single step (trace trap)
 - software breakpoint
 - hardware breakpoint/watchpoint
 - kernel event (exec, fork, vfork, vfork-done, lwp-create, lwp-exit)

A program can execute software breakpoint without the context of being
traced and this is a regular crash signal emitting SIGTRAP (TRAP_BRKPT).

Rename original trap_* tests (trap_simple, trap_handle, trap_mask,
trap_handle_recurse and trap_ignore) to segv_* tests and restrict them for
SIGSEGV.

Add new tests: trap_* testing the same scenarios as segv_ ones, however
verifying the software breakpoint trap (SIGTRAP).

Keep the original name of h_segv.c, and extend it for software breakpoint
events.

The purpose of these tests is to verify SIGTRAP kernel paths without the
ptrace(2) context.

All tests pass.

Sponsored by <The NetBSD Foundation>
2018-05-22 04:32:56 +00:00
kamil 5607b39231 Add new ATF test: t_trapsignal:trap_ignore
Test ignored trap with right exit code.

This test passes.

Sponsored by <The NetBSD Foundation>
2018-05-21 08:49:03 +00:00
kamil 8e107b0ecc Refactor and enable the signal3 ATF ptrace(2) test
Adapt the test to be independent from the software breakpoint trap
behavior, whether the Program Counter is moved or not. Just kill the
process after catching the expected signal, instead of pretending to resume
it.

This test passes.

Sponsored by <The NetBSD Foundation>
2018-05-20 23:47:16 +00:00
kamil 7f2cb72e7e Fix and enable traceme_signal_nohandler2 in ATF ptrace(2) tests
traceme_signal_nohandler2 checks emitting SIGSTOP to a traced process
with the PT_CONTINUE operation.

The expected behavior is to simulate a behavior of receiving SIGSTOP,
generating SIGCHLD to its parent (in this case the debugger) and ability
to call wait(2)-like function receiving the stopped child event.

The previous behavior was unstopping the process and it has been adjusted
in the kernel code.

FreeBSD keeps unstopping a process for emitting SIGSTOP.
Linux handles this scenario in the same way as NetBSD now.

While there, implement the missing bits in the userland ATF test for
traceme_signal_nohandler2: receiving and validating 2nd SIGSTOP event and
continuing the process, followed by its normal termination.

Sponsored by <The NetBSD Foundation>
2018-05-20 03:51:31 +00:00
kamil 2a5f5c09bb Cover SIGTSTP, SIGTTIN and SIGTTOU in traceme_vfork_raise ATF tests
SIGTSTP, SIGTTIN and SIGTTOU are special case signals ignored in a
vfork(2)ed child. Assert the behavior of raise(2) after calling
PT_TRACE_ME.

Renumber existing traceme_vfork_raise tests.

Sponsored by <The NetBSD Foundation>
2018-05-19 05:25:21 +00:00
kamil aa6024affb Reflect reality in the comment
The watcher process is emitting SIGKILL, not SIGTERM.

Sponsored by <The NetBSD Foundation>
2018-05-19 05:10:16 +00:00
kamil 8c5954ee47 Enable traceme_vfork_raise2 in ATF ptrace(2) tests
raise(SIGSTOP) is now handled correctly by the kernel, in a child that
vfork(2)ed and called PT_TRACE_ME.

Implement a helper process emitting SIGKILL to a stopped child of a
vfork(2)ed process.

Sponsored by <The NetBSD Foundation>
2018-05-19 05:07:42 +00:00
kamil c1819337b0 Add new auxiliary functions in t_ptrace_wait.h
New functions:
 - FORKEE_ASSERT_NEQ()
 - await_stopped_child()

Both will be used soon in a new ATF ptrace(2) test.

Sponsored by <The NetBSD Foundation>
2018-05-19 05:04:09 +00:00
kamil 73bcea99d7 Stop masking SIGSTOP in a vfork(2)ed child
Keep the traditional BSD behavior masking SIGTSTP, SIGTTIN and SIGTTOU in
a vfork(2)ed child before exec(3)/exit(3). This is useful in shells and
prevents deadlocking, when a parent cannot unstop the sleeping child.

Change the behavior for SIGSTOP. This signal is by design not maskable and
this property shall be obeyed without exceptions. The STOP behavior is
expected in the context of debuggers and useful in standalone programs.

It is still possible to stop a vfork(2)ed child, however it requires
proc.curproc.stopfork=1, but it is not a flexible solution.

FreeBSD and OpenBSD keep masking SIGSTOP in a vfork(2)ed child.
Linux does not mask stop signals in the same scenarios.

This fixes ATF test: t_vfork:raise2.
No known regressions reported in the existing ATF tests.

Discussed with <kre>

Sponsored by <The NetBSD Foundation>
2018-05-19 02:42:58 +00:00
kamil 497013ad4b Add new ATF tests: t_fork and t_vfork
Test behavior of raise(signal) in either fork(2)ed or vfork(2)ed child.

Tests:
 - raise1 SIGKILL
 - raise2 SIGSTOP
 - raise3 SIGTSTP
 - raise4 SIGTTIN
 - raise5 SIGTTOU
 - raise6 SIGABRT
 - raise7 SIGHUP
 - raise8 SIGCONT

t_vfork:raise2 fails ignoring non-maskable SIGSTOP.

The remaining ones pass.

Sponsored by <The NetBSD Foundation>
2018-05-18 06:39:58 +00:00
kamil ed68aafd9d Correct assert in ATF t_zombie test
A failure is reported with -1, not 1.

Sponsored by <The NetBSD Foundation>
2018-05-18 00:25:30 +00:00
kamil ea78951cdc Add extra asserts in three ATF ptrace(2) tests
In traceme* tests after validate_status_stopped() include additional check
the verify the received signal with PT_GET_SIGINFO.

All tests passes.

Sponsored by <The NetBSD Foundation>
2018-05-16 03:52:35 +00:00
kamil fee84111f1 Improve the description of traceme_vfork_breakpoint (ATF ptrace(2) test)
Sponsored by <The NetBSD Foundation>
2018-05-16 03:18:38 +00:00
kamil 98c4cd6bac Add a new ATF ptrace(2) test: traceme_vfork_exec
Verify PT_TRACE_ME followed by exec(3) in a vfork(2)ed child.

This tests passes correctly.

Sponsored by <The NetBSD Foundation>
2018-05-16 02:47:25 +00:00
kamil 983fb9900d Improve the description of traceme_vfork_raise in ATF ptrace(2) tests
Set new description to:
 - "Verify PT_TRACE_ME followed by raise of " #sig " in a vfork(2)ed "
   "child"

The previous one was copy pasted from a different ATF test and not changed.

Sponsored by <The NetBSD Foundation>
2018-05-16 01:36:29 +00:00
kamil 78ed479f2f Add a new ATF ptrace(2) test: traceme_vfork_breakpoint
Verify software breakpoint in a vfork(2)ed child.

The expected behavior is not to route this signal to the parent, even if
that parent is a tracer. The parent cannot handle it and it would lead to
the deadlock.

This test passes correctly.

Sponsored by <The NetBSD Foundation>
2018-05-16 01:27:27 +00:00
kamil 108bf35cd1 Correct handling of: vfork(2) + PT_TRACE_ME + raise(2)
Follow the FreeBSD approach of not routing signals to the parent that is
a became tracer after calling PT_TRACE_ME by the vfork(2)ed child (before
exec(3)/exit(3)).

Now if a child calls raise(3), the signal is processed directly to this
child.

Add new ATF ptrace(2) tests:
 - traceme_vfork_raise1 (SIGKILL)
 - traceme_vfork_raise2 (SIGSTOP) // temporarily disabled
 - traceme_vfork_raise3 (SIGABRT)
 - traceme_vfork_raise4 (SIGHUP)
 - traceme_vfork_raise5 (SIGCONT)

The FreeBSD implementation introduces P_PPTRACE for this special case.
Right know keep opencoding check of this case in the kernel. It might be
refactored in future.

The Linux kernel does not follow this approach and causes dead locking of
the processes (parent and child).

Defer handling SIGSTOP into future.

This is an intermediate step towards correct handling of fork(2) and
vfork(2) in the context of ptrace(2).

All new tests pass.
There are no regressions in existing ATF ptrace(2) tests.

Sponsored by <The NetBSD Foundation>
2018-05-16 00:42:15 +00:00
kamil a312b16739 Revert previous change in t_ptrace.c
By a mistake this file started to include <sys/mman.h>
This is not needed.

The include was intended to be add just in t_ptrace_wait.c.

Sponsored by <The NetBSD Foundation>
2018-05-14 12:44:40 +00:00
kamil ca1c59ed43 Simplify the x86_64_cve_2018_8897 ATF ptrace(2) test
Do not call _exit() from the child, ad this code shall not be reached.
Put there assert().

No functional change. The test still passes.

Sponsored by <The NetBSD Foundation>
2018-05-14 12:42:34 +00:00
kamil 334427c45d Add a new ptrace(2) ATF exploit for: CVE-2018-8897 (POP SS debug exception)
The original expolit and mitigation have been developed by Maxime Villard.

I've reworked the shared code and adapted for the ATF context.
I've included PIE-aware version (RIP/EIP relative) and introduced
additional comments to the explanation how to trigger the flaw.

This test passes on NetBSD/8.99.17.

Sponsored by <The NetBSD Foundation>
2018-05-13 23:14:47 +00:00
kamil 2439331646 Refactor code in ATF ptrace(2) tests
Move the can_we_set_dbregs() auxiliary function from t_ptrace_x86_wait.h
to a common file t_ptrace_wait.h. This allows using this function for
checking whether the DBREGS set operations in ptrace(2) are accessible for
a user.

Sponsored by <The NetBSD Foundation>
2018-05-13 23:01:25 +00:00
joerg b5dbde748d Handle the GCC restriction like the set list by explicitly checking for
HAVE_GCC. When using EXTERNAL_TOOLCHAIN with LLVM, it would still be
picked up otherwise.
2018-05-09 13:18:02 +00:00
mrg 2fc9ba62ad don't print "long" with "%zu". 2018-05-09 08:45:03 +00:00
martin 3198bde1a4 Make the getrusage_maxrss test more stable by preventing the compiler to
optimize out a dummy loop. While there print more details when failing.
2018-05-09 06:32:52 +00:00
christos ccca93f2fc add tests for maxrss, msgsnd 2018-05-08 01:02:38 +00:00
kamil 410141583e Improve wording for non-native speakers of English
Improve wording in t_ubsan tests in for c++.

No functional change intended.

Follow the changed in cc/ by <martin>
2018-05-04 12:51:18 +00:00
kamil 1560a24938 Explain VLA in c++/t_ubsan_vla_out_of_bounds.sh (ATF test)
VLA - Variable Length Array

Requested by <martin>
2018-05-04 12:27:58 +00:00
kamil 15009a7646 Explain VLA in t_ubsan_vla_out_of_bounds.sh (ATF test)
VLA - Variable Length Array

Requested by <martin>
2018-05-04 12:26:53 +00:00
martin d3941ea9b2 Use more formal speech in messages 2018-05-04 10:44:24 +00:00
kamil e308425ef5 Add new ATF Undefined Behavior Sanitizer tests
Add new cc and c++ tests to check whether UBSan works.
These tests are prepared for GCC (in base) and Clang (with external patches).

Enable these tests for all ports by default, just verify whether we are
using GCC/Clang or a compatible compiler.

Add five equivalent C and C++ tests:
 - Integer addition overflow
 - Integer divide by zero
 - Integer negation overflow
 - Integer subtraction overflow
 - VLA out of bounds

All tests pass on NetBSD/amd64.

Patch submitted by <Harry Pantazis>
Minor cleanup by <myself>
2018-05-02 18:46:05 +00:00
kamil 385d9c8955 Implement PTRACE_VFORK
Add support for tracing vfork(2) events in the context of ptrace(2).

This API covers other frontends to fork1(9) like posix_spawn(2) or clone(2),
if they cause parent to wait for exec(2) or exit(2) of the child.

Changes:
 - Add new argument to sigswitch() determining whether we need to acquire
   the proc_lock or whether it's already held.
 - Refactor fork1(9) for fork(2) and vfork(2)-like events.
   Call sigswitch() from fork(1) for forking or vforking parent, instead of
   emitting kpsignal(9). We need to emit the signal and suspend the parent,
   returning to user and relock proc_lock.
 - Add missing prototype for proc_stop_done() in kern_sig.c.
 - Make sigswitch a public function accessible from other kernel code
   including <sys/signalvar.h>.
 - Remove an entry about unimplemented PTRACE_VFORK in the ptrace(2) man page.
 - Permin PTRACE_VFORK in the ptrace(2) frontend for userland.
 - Remove expected failure for unimplemented PTRACE_VFORK tests in the ATF
   ptrace(2) test-suite.
 - Relax signal routing constraints under a debugger for a vfork(2)ed child.
   This intended to protect from signaling a parent of a vfork(2)ed child that
   called PT_TRACE_ME, but wrongly misrouted other signals in vfork(2)
   use-cases.

Add XXX comments about still existing problems and future enhancements:
 - correct vfork(2) + PT_TRACE_ME handling.
 - fork1(2) handling of scenarios when a process is collected in valid but
   rare cases.

All ATF ptrace(2) fork[1-8] and vfork[1-8] tests pass.

Fix PR kern/51630 by Kamil Rytarowski (myself).

Sponsored by <The NetBSD Foundation>
2018-05-01 16:37:23 +00:00
kamil 66a7857d57 Add two new ptrace(2) ATF tests
Added:

 - traceme_pid1_parent
   Assert that a process cannot mark its parent a debugger twice

 - traceme_twice
   Verify that PT_TRACE_ME is not allowed when our parent is PID1

All tests pass.

Sponsored by <The NetBSD Foundation>
2018-04-29 13:56:00 +00:00
kamil 7c9ce7b74f Enable traceme_raise1 in the ATF ptrace(2) tests
This test checks raise(SIGKILL). If we enter the kernel with this signal
we report a signaled child in a debugger, not stopped with an option to
make an action.

FreeBSD behaves differently and allows intercepting this event in a tracer.
Follow the Linux behavior.

If we really want to prevent raise(SIGKILL) from signaling the tracee, we
still can breakpoint raise(3) and alter the syscall arguments (or use
the PT_SYSCALL mode). If we are already in the kernel, SIGKILL always means
killing the process, whether or not traced and the source of SIGKILL.

This tests passes on NetBSD without kernel changes.

Sponsored by <The NetBSD Foundation>
2018-04-28 19:00:25 +00:00
kamil 736f73b24b Refactor the traceme3 ATF ptrace(2) test
Replace traceme3 with new ATF tests using diverse signals:

 - traceme_signal_nohandler1 SIGKILL
 - traceme_signal_nohandler2 SIGSTOP (temporarily disabled)
 - traceme_signal_nohandler3 SIGABRT (emits core dump)
 - traceme_signal_nohandler4 SIGHUP
 - traceme_signal_nohandler5 SIGCONT

These SIGSTOP test does not work properly right now as it unstops the
traccee.

Sponsored by <The NetBSD Foundation>
2018-04-28 18:07:15 +00:00
kamil f738c48337 Handle core dumps in ATF ptrace(2) tests easier
Cast WCOREDUMP() to either 1 or 0.

It could be changed to a boolean type, but it's already good enough.

Sponsored by <The NetBSD Foundation>
2018-04-28 17:56:55 +00:00
kamil 5abe8ef7df Refactor the traceme2 ATF ptrace(2) tests
Replace traceme2 with 3 tests:
 - traceme_sighandler_catch1
 - traceme_sighandler_catch2
 - traceme_sighandler_catch3

These tests are verified with PT_TRACE_ME for: SIGHUP, SIGCONT and SIGABRT.

We don't want tests all signals (this is a domain for a fuzzer), but we want
to cover tests with signals from different groups.

All tests pass.

Sponsored by <The NetBSD Foundation>
2018-04-28 00:14:37 +00:00
kamil 0165d5af91 Refactor the traceme1 and traceme4 ATF ptrace(2) tests
Use common bode for these tests and a macro 1-liner to define a new test.

Test the same scenarios for 5 signals:
 - SIGKILL (temporarily disabled)
 - SIGSTOP
 - SIGABRT
 - SIGHUP
 - SIGCONT

These tests call: raise(sig). It's actually important to assert their
behavior for tests that are from different kinds.

The SIGKILL test is work in progress. It can be caught by a debugger on the
FreeBSD kernel, but it's causing a signaled event in a debugger on Linux.

NetBSD is right now in one of the camps, but research whether this is a bug
or feature is in progress.

Sponsored by <The NetBSD Foundation>
2018-04-27 21:36:45 +00:00
maxv 8ad8ab65b1 Remove ping6_opts_hops, "-g" does not exist anymore (RH0 removed). 2018-04-26 06:23:33 +00:00
kre 7fea2a9dfc Add a test case for PR bin/53201
Currently this test case will fail, a fix is coming soon (not worth
marking this as an expected failure.)

This test case and the initial bug report comes from
Martijn Dekker's modernish (shell/test set).
2018-04-21 21:28:35 +00:00
ozaki-r 0be59150b6 Add a test that checks if brconfig flush surely removes all entries 2018-04-18 04:03:12 +00:00
kamil 6827020217 Refactor fork-like ATG tests in t_ptrace_wait*
Add CPP syntax sugare to define each fork-like test within a single line
of code with less than 80 columns.

This is a preparation for new fork-like scenarios where we detach either
child and/or parent with PT_DETACH.

The code could be still reduced to smaller number of columns, instead of:

   FORK_TEST(fork1, DSCR(fork,0,0,0,0,0), fork, F, F, F, F, F)

we could perhaps need 50% of it, as the data is duplicated.

On the other hand the line is already short and taking only a single line.

No functional change intended.

Sponsored by <The NetBSD Foundation>
2018-04-15 00:19:23 +00:00
kamil 8a7b75cec0 Import new C and C++ ATF tests for ASan
Add new tests:
 - tests/usr.bin/cc/t_asan_poison.sh
 - tests/usr.bin/c++/t_asan_poison.sh

These tests verify the following build options:
 - regular
 - profile
 - pic
 - pie
 - compat32
 - (static unsupported)

These tests verify whether ASan code can include compiler and sanitizer
specific header: <sanitizer/asan_interface.h>. The testing code checks
the ASAN_POISON_MEMORY_REGION() functionality, poisoning valid memory and
asserting that it triggers expected failure.

Patch submitted by <Siddharth Muralee>
2018-04-11 03:25:25 +00:00
kamil ea82fba129 Cover more fork/vfork/vforkdone scenarios in ATF ptrace(2) tests
Use a shared common body for all the tests: fork1..fork8, vfork1..vfork8.

Merge vforkdone1 and vforkdone2 into vfork* tests.

All the (v?)fork[1-8] tests cover:
 - calling either fork(2) or vfork(2)
 - tracking either enabled or disabled FORK, VFORK or VFORK_DONE

All the PTRACE_VFORK tests are marked as expected failure.

Sponsored by <The NetBSD Foundation>
2018-04-11 01:52:59 +00:00
kamil 1924131dec ATF t_ptrace_wait* refactoring: vforkdone1 and vforkdone2
Merge vforkdone1 and vforkdone2 into other fork tests and reuse the same
function body fork_test().

There is an implicit enhancement in vforkdone2 that it was skipping
PTRACE_VFORK check. This test is now marked as expected failure.

PR kern/51630

Sponsored by <The NetBSD Foundation>
2018-04-10 22:45:39 +00:00
ozaki-r f72ad93267 Add a test case for bridge_rtdelete 2018-04-10 07:09:00 +00:00
kamil 4fb49d74f0 ATF: ptrace: Merge code in fork2 and vfork2 tests with (v)fork1 ones
Reduce code duplication, use the same function body with conditional
switches.

Sponsored by <The NetBSD Foundation>
2018-04-10 00:40:35 +00:00
kamil 3a2e5c145a Merge code in tests: fork1 and vfork1 (ATF t_ptrace_wait*)
Marge bodies of two tests into the same function.
Add few checks for regular fork or not (vfork).

Sponsored by <The NetBSD Foundation>
2018-04-10 00:09:31 +00:00
martin b29a640aff Use tcpdump -n to avoid reverse DNS lookup. There is no point in having
different results from running this test in a networked vs. a non-networked
environment.
Adjust golden output accordingly.
Fixes PR 53150.
2018-04-09 16:21:05 +00:00
kamil 42c80d5774 Improve documentation of the ATF test t_ptrace_wait*: traceme2
Set the description to:

  Verify that a signal emitted by a tracer to a child is caught by
  a signal handler.

Sponsored by <The NetBSD Foundation>
2018-04-09 15:45:16 +00:00
kamil 2e7534f345 Add check in ATF tests for security.models.extensions.user_set_dbregs
Introduce a new function can_we_set_dbregs() in the ATF ptrace(2) tests.
It uses lazy-bool evaluation whether a process can call PT_SETDBREGS.

In case of not being able to do so, print a message and mark a test
as skipped:

  Either run this test as root or set sysctl(3)
  security.models.extensions.user_set_dbregs to 1

No functional change intended to the code flow of the existing tested
scenarios.

Sponsored by <The NetBSD Foundation>
2018-04-08 17:20:18 +00:00
ozaki-r 810a5ee058 Fix typo 2018-04-07 12:36:58 +00:00
ozaki-r 6ca7de5d0d Add tests for GARP without DAD
Additionally make the existing tests for GARP more explicit.
2018-04-06 09:23:36 +00:00
ozaki-r 9e4591fa4a Show outputs of commands if $DEBUG 2018-04-06 09:22:38 +00:00
ozaki-r 4cb98a5a0c Improve packet checks and error reporting 2018-04-06 09:21:57 +00:00
kamil 8e4f836c68 Add new ATF tests for Address Sanitzier (ASan)
Add new C and C++ tests:
 - t_asan_double_free
 - t_asan_global_buffer_overflow
 - t_asan_heap_overflow
 - t_asan_off_by_one
 - t_asan_uaf

Each tests checks:
 - regular build
 - 32-bit
 - PIC
 - PIE
 - profile

These tests require paxctl(8) to disable ASLR in order to work in a
predictable way. This is especially true for all !regular builds with
additional compiler flags.

There are no static variations of these tests as this mode is not supported
in upstream ASan.

Enable these tests on amd64 and i386.

This is part two patch, adding the remaining C++ changes.

Patch submitted by <Siddharth Muralee>
Additional polishing by myself.
2018-04-04 23:53:26 +00:00
kamil 9f0bdbd997 Add new ATF tests for Address Sanitzier (ASan)
Add new C and C++ tests:
 - t_asan_double_free
 - t_asan_global_buffer_overflow
 - t_asan_heap_overflow
 - t_asan_off_by_one
 - t_asan_uaf

Each tests checks:
 - regular build
 - 32-bit
 - PIC
 - PIE
 - profile

These tests require paxctl(8) to disable ASLR in order to work in a
predictable way. This is especially true for all !regular builds with
additional compiler flags.

There are no static variations of these tests as this mode is not supported
in upstream ASan.

Enable these tests on amd64 and i386.

Patch submitted by <Siddharth Muralee>
Additional polishing by myself.
2018-04-04 23:51:35 +00:00
kamil b4fcb5aedb Correct a small regression typo in usr.bin/c++ ATF tests
TESTS_SH= changed to TESTS_SH+=
2018-04-04 15:53:04 +00:00
kamil b269e95d9e Sort entries in ATF tests in tests/usr.bin/c++/Makefile
No functional change intended.
2018-04-04 15:08:59 +00:00
roy 64785daad7 Handle errors better.
Fix test for checking we sent all the data we asked to.
2018-03-26 09:11:15 +00:00
roy 8a9420adee Allow a valid sendto .... duh 2018-03-24 15:51:57 +00:00
kamil 77dc83fa09 Add new C++ ATF tests
Add new variations for existing C++ tests:
 - Static
 - Profile+32-bit
 - PIC+32-bit
 - PIC+Profile
 - PIC+Profile+32-bit

All tests pass for NetBSD/amd64:
 - t_cxxruntime
 - t_hello
 - t_static_destructor

+--------------------------------------------------------------+
| Options            | cxxruntime | hello  | static_destructor |
+--------------------------------------------------------------+
| None               | Passed     | Passed | Passed            |
| 32-bit             | Passed     | Passed | Passed            |
| PIC                | Passed     | Passed | Passed            |
| PIE                | Passed     | Passed | Passed            |
| Profile            | Passed     | Passed | Passed            |
| Static             | Passed     | Passed | Passed            |
| Profile+32-bit     | Passed     | Passed | Passed            |
| PIC+32-bit         | Passed     | Passed | Passed            |
| PIC+Profile        | Passed     | Passed | Passed            |
| PIC+Profile+32-bit | Passed     | Passed | Passed            |
+--------------------------------------------------------------+

Add new C++11 std::call_once tests:
 - t_call_once
 - t_call_once2

Add new C++11 test with pthread_once(3) and C++ lambda:
 - t_pthread_once

All tests with the profile option for std::call_once and
pthread_once(3) are marked as expected failure (NetBSD/amd64).

Results for *_once*:
+------------------------------------------------------------+
| Options            | call_once | call_once2 | pthread_once |
+------------------------------------------------------------+
| None               | Passed    | Passed     | Passed       |
| 32-bit             | Passed    |  Passed    | Passed       |
| PIC                | Passed    | Passed     | Passed       |
| PIE                | Passed    | Passed     | Passed       |
| Profile            |  Failed   |  Failed    |  Failed      |
| Static             | Passed    | Passed     | Passed       |
| Profile+32-bit     |  Failed   |  Failed    |  Failed      |
| PIC+32-bit         | Passed    | Passed     | Passed       |
| PIC+Profile        |  Failed   |  Failed    |  Failed      |
| PIC+Profile+32-bit |  Failed   |  Failed    |  Failed      |
+------------------------------------------------------------+

Long term there is an option to refacotr the framework for C and C++ tests,
in order to reduce code duplication.

Patches sent by Yang Zheng <tomsun.0.7@gmail.com>
2018-03-24 00:26:51 +00:00
kamil 62ac00a826 Fix a printf(3)-like format in ATF ICMP t_ping.c
Use %zd for ssize_t, instead of %d.
2018-03-24 00:06:32 +00:00
roy 80b75699b5 Note value received. Harden another sendto for ENOBUFS. 2018-03-23 10:05:45 +00:00
roy 05ee2584ab Handle ENOBUFS in sendto 2018-03-22 17:27:34 +00:00
roy 1875ff6c39 Handle ENOBUFS in recv 2018-03-22 17:16:05 +00:00
ozaki-r 57e881a906 Avoid setting IP addresses of the same subnet on different interface
If we do so, there will remain one route that is of a preceding address, but
that behavior is not documented and may be changed in the future.  Tests
shouldn't rely on such a unstable behavior.
2018-03-22 09:21:24 +00:00
roy d96ab75caf Handle ENOBUFS when receiving messages.
Don't send messages if the receiver has died.
2018-03-21 12:37:12 +00:00
kamil ce34db38fd Add new ATF tests: kernel/t_zombie
New tests attempting to kill, stop, drop or revive a zombie:
 - signal1 (SIGKILL)
 - signal2 (SIGSTOP)
 - signal3 (SIGABRT)
 - signal4 (SIGHUP)
 - signal5 (SIGCONT)

New test race1 verifying whether there are any kernel races when processing
signals to zombies, executing in a loop for 5 seconds.

These tests were inspired by a kernel unexpected behavior when a lookup
of a dying process could result in two detected entities once as an alive
process and once as a zombie.

race1 is similar to t_ptrace_wait* race1, however without ptrace(2) involved.

Sponsored by <The NetBSD Foundation>
2018-03-14 02:13:47 +00:00
kamil a9dda15d6e ATF: Add new test race1 in t_ptrace_wait*
Reuse the attach1's test body for race1.

Add a new test race1:
  Assert that await_zombie() in attach1 always finds a single
  process and no other error is reported

race1 requires HAVE_PID in wait(2)-like function.

This test is executed in a loop for 5 seconds (16k iterations on Intel i7).
A buggy kernel was asserting an error within this timeframe almost always.

The bug in the kernel is now gone and this test is expected to pass
correctly.

Sponsored by <The NetBSD Foundation>
2018-03-13 14:54:13 +00:00
kamil c6513ba7ad ATF t_ptrace_wait*: Disable debug messages in msg.h
msg.h is a dummy IPC interface.

Disable additional debugging logging here, especially wanted in race*
tests.

Sponsored by <The NetBSD Foundation>
2018-03-13 14:45:36 +00:00
kamil 8fa6ff479d Add a new function in ATF t_ptrace_wait*: await_zombie_raw()
Add await_zombie_raw() that is the same as await_zombie(), whith an
addition of additional "useconds_t ms" parameter indicating delays between
new polling for a zombie process.

This new function will be used for testing a race condition that has been
observed occassionally crashing a test case -- returning duplicate entries
for KERN_PROC_PID.

Sponsored by <The NetBSD Foundation>
2018-03-13 13:34:40 +00:00
knakahara a0d17a179a Enhance assertion ipsecif(4) ATF to avoid confusing setkey(8) error message.
When setkey(8) says "syntax error at [-E]", it must mean get_if_ipsec_unique()
failed.
2018-03-13 03:50:26 +00:00
joerg aa18a61198 Stub out on platforms without ifunc support in the linker. 2018-03-11 21:20:22 +00:00
joerg a64ef2fb9e Add ifunc support for statically linked applications on x86, ppc, sparc
and ARM.
2018-03-09 20:20:47 +00:00
joerg d3d2a5f92e Avoid casting fun by switching ifunc helper functions to return
long long. Dead beef is too useful to switch to a different constant.
2018-03-09 20:15:03 +00:00
kamil f25eee2811 ATF: Reenable attach2 in t_ptrace_wait*
The primary race specific to this test has been fixed in previous commit
(wrong WNOHANG).

This test is still racy and breaks like once every 30,000 execution.
This is down like from once from every 100th execution in the past.

The remaning race is not specific to attach2 and I can reproduce it with
at least attach1. It still looks like being specific to NetBSD and it's
not reproducible on Linux and FreeBSD. Perhaps a bug with pipe(2)/write(2)/
read(2) or close to these features.

Sponsored by <The NetBSD Foundation>
2018-03-07 16:40:06 +00:00
kamil 42ffdafce3 ATF: Correct a race bug in attach2 (t_ptrace_wait*)
At the end of the test we resume a tracer and expect to observe it to
collect the debuggee. We cannot from a parent point of view wait for
collecting it with WNOHANG without a race.

Remove the WNOHANG option from wait*(2) call. This corrects one type of
race.

This test is still racy for some other and unknown reason and this is being
investigated.

Sponsored by <The NetBSD Foundation>
2018-03-07 10:53:55 +00:00
ozaki-r d0486ec90d Tweak tests; increase the size of NS packets for the addition of a nonce 2018-03-07 02:30:37 +00:00
ozaki-r 6963349e89 Provide more informative reports on failures 2018-03-07 02:30:00 +00:00
kamil aad35b0998 Correct all ATF failures in t_ptrace_x86_wait.h (debug registers)
This code after refactoring stopped calling functions that were designed
to trigger expected behavior and thus, tests were breaking.

Sponsored by <The NetBSD Foundation>
2018-03-06 21:11:51 +00:00
kamil 570f001093 Remove PT_GET_SIGMASK / PT_SET_SIGMASK
These operations cloned Linux's specific PTRACE_GETSIGMASK / PTRACE_SETSIGMASK.
This feature was useful in applications like rr/criu/reptyr-like, where
the ptrace(2) interface is abused for the purpose of constructing an arbitrary
process. It's not reliable and not portable. For the NetBSD case it will be
better to invent something dedicated for serializing and deserializing a
process with threads.

Noted on tech-toolchain@ and blog entry

"LLDB restoration and return to ptrace(2)"
https://blog.netbsd.org/tnf/entry/lldb_restoration_and_return_to
2018-03-05 11:24:34 +00:00
uwe cd711bd2b9 Simplify - it's enough to set nctx.uc_link to &octx to restore old
context automatically when swapfunc() returns.
2018-02-28 21:36:50 +00:00
uwe 5eea33881e Add missing $ in the RCSID. 2018-02-28 21:29:10 +00:00
uwe da83da02db threadfunc - we do return from swapcontext() (since revision 1.2),
so drop the NOTREACHED comment.
2018-02-27 20:34:04 +00:00
uwe 02b9aeb870 swapfunc() is not passed to pthread_create, there's no need for it to
have any arguments.
2018-02-27 20:31:35 +00:00
uwe 738b2ab23a Drop unnecessary cast to makecontext() argument. 2018-02-27 20:24:50 +00:00
uwe 79bd7f2c4b Cleanup trailing whitespace. 2018-02-27 20:22:31 +00:00
kamil 5198f250f5 Include <inttypes.h> in t_ucontext.c
The <inttypes.h> user-land header is required for PRI types.
We were including indirectly <sys/inttypes.h> through <sys/*.h> sources,
and this worked for most of the ports.

This fixes indirectly a build for MIPS (tested ports: arc and hpcmips),
where PRI types (PRIxREGISTER) were undefined.

Noted by <uwe>.
2018-02-27 12:20:35 +00:00
kamil c3018cf20c Make the t_ucontext.c test more portable
Cast _UC_MACHINE_*(&u) to (register_t).
This allows to print the returned values with PRIxREGISTER.

This corrects build failures on MIPS and HPPA.
sizeof(int) == sizeof(long) on these 32-bit systems.
2018-02-27 11:15:53 +00:00
christos 6f17b07f09 fix spello 2018-02-25 15:31:07 +00:00
kamil 16ed291475 Add new tests in lib/libc/sys/t_ucontext
New tests:
 - ucontext_sp
 - ucontext_fp
 - ucontext_pc
 - ucontext_intrv

They test respectively:
 - _UC_MACHINE_SP
 - _UC_MACHINE_FP
 - _UC_MACHINE_PC
 - _UC_MACHINE_INTRV

These tests attempt to access and print the values from ucontext, without
interpreting the values.

This is a follow up of the _UC_MACHINE_FP() introduction.

These tests use PRIxREGISTER, and require to be built with -D_KERNTYPES.

Sponsored by <The NetBSD Foundation>
2018-02-25 14:27:07 +00:00
martin 3cbaed46a2 PR lib/53044: remove tests not provided by OpenSSL 1.1.x 2018-02-22 14:24:03 +00:00
christos 0f242fe63e make it compile again for those who don't have LOCAL_PEERCRED 2018-02-17 20:16:18 +00:00
christos 1d89963535 Add a test demonstrating thst LOCAL_PEEREID is busted. 2018-02-17 16:34:18 +00:00
christos bf0b06cfe9 remove clause 3, 4. 2018-02-17 00:28:47 +00:00
christos 98cc4b91d3 Use the same variable name for the accepted socket as with the AF_LOCAL test.
Call getpeereid on the accepted socket.
2018-02-16 22:20:18 +00:00
christos c587e5a36a make sure we call getpeername on the accepted socket! 2018-02-16 22:17:17 +00:00
christos 596e712e68 ensure that getpeereid does not succeed on tcp sockets. 2018-02-16 19:24:16 +00:00
christos e34e5e3adb explain what's going on before we fix it. 2018-02-16 16:30:20 +00:00
christos 474def7698 add getpeereid tests for non-unix sockets, returns garbage... 2018-02-16 16:23:15 +00:00
christos c88e952be5 add a getpeeeid test. 2018-02-16 16:08:22 +00:00
ozaki-r def6ba19bd Fix ping_opts_gateway and ping_opts_recordroute
We need to enable the options of source routing on all rump kernels.
2018-02-09 03:53:07 +00:00
christos c885e6eac2 put .PATH after the variable is defined. 2018-02-09 03:20:21 +00:00
christos 531428e66d fix 1.0 build; thanks ODE make. 2018-02-08 23:52:26 +00:00
christos 60b220f792 include the right test directory for the right openssl version 2018-02-08 23:41:26 +00:00
christos e1f413f949 adjust tests for 1.1 2018-02-08 21:59:10 +00:00
maxv f1624eef2e Now that we don't allow source-routed packets by default, set allowsrcrt=1
and forwsrcrt=1. Should fix the ATF failure.
2018-02-08 09:56:19 +00:00
dholland 32cded6cc9 Typos. 2018-02-08 09:05:16 +00:00
christos 853c815d40 md2 has been deprecated in OpenSSL-1.1 2018-02-07 13:18:33 +00:00
pgoyette 96bdb2f1f0 * Use 'struct testmsg' rather than 'struct mymsg' (avoids a conflict
with FreeBSD)
* Fix a broken call to open(2) with O_CREAT and no permission argument.
* ANSIfy function definitions.
* Improve failure messages.

From freebsd.org via Brooks Davis - Thanks!
2018-02-03 02:57:15 +00:00
ozaki-r 95dd9007db Commonalize and add tests of creating/destroying interfaces 2018-02-01 05:22:01 +00:00
mrg f2b04ca083 implement 32-bit compat support for raidframe.
convert several raidframe ioctls to be bitsize idempotent so that
they work the same in 32 and 64 bit worlds, allowing netbsd32 to
configure and query raid properly.  remove useless 'row' in a few
places.  add COMPAT_80 and put the old ioctls there.

raidframeio.h:
  RAIDFRAME_TEST_ACC
  - remove, unused
  RAIDFRAME_GET_COMPONENT_LABEL
  - convert to label not pointer to label
  RAIDFRAME_CHECK_RECON_STATUS_EXT
  RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT
  RAIDFRAME_CHECK_COPYBACK_STATUS_EXT
  - convert to progress info not pointer to info
  RAIDFRAME_GET_INFO
  - version entirely.
raidframevar.h:
  - rf_recon_req{} has row, flags and raidPtr removed (they're
    not a useful part of this interface.)
  - RF_Config_s{} and RF_DeviceConfig_s{} have numRow/rows removed.
  - RF_RaidDisk_s{} is re-ordered slightly to fix alignment
    padding - the actual data was already OK.
  - InstallSpareTable() loses row argument

rf_compat32.c has code for RF_Config_s{} in 32 bit mode, used
by RAIDFRAME_CONFIGURE and RAIDFRAME_GET_INFO32.

rf_compat80.c has code for rf_recon_req{}, RF_RaidDisk_s{} and
RF_DeviceConfig_s{} to handle RAIDFRAME_FAIL_DISK,
RAIDFRAME_GET_COMPONENT_LABEL, RAIDFRAME_CHECK_RECON_STATUS_EXT,
RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT,
RAIDFRAME_CHECK_COPYBACK_STATUS_EXT, RAIDFRAME_GET_INFO.

move several of the per-ioctl code blocks into separate functions.

add rf_recon_req_internal{} to replace old usage of global
rf_recon_req{} that had unused void * in the structure, ruining
it's 32/64 bit ABI.

add missing case for RAIDFRAME_GET_INFO50.

adjust raid tests to use the new .conf format, and add a case to
test the old method as well.

raidctl:
deal with lack of 'row' members in a couple of places.
fail request no longer takes row.
handle "START array" sections with just "numCol numSpare", ie
no "numRow" specified.  for now, generate old-style configuration
but update raidctl.8 to specify the new style (keeping reference
to the old style.)

note that: RF_ComponentLabel_s::{row,num_rows} and
RF_SingleComponent_s::row are obsolete but not removed yet.
2018-01-18 00:32:48 +00:00
maya b42dccbff0 Use sysctl -n rather than parse the output.
From Ngie Cooper in PR bin/51870
2018-01-17 00:23:17 +00:00
maya 687000d215 - Add inttypes.h #include for PR* macros.
- close fd when done to prevent leak.
- use correct socket length when calling bind(2).

From Ngie Cooper in PR bin/51870
2018-01-17 00:22:29 +00:00
maya bcc7b2aa78 Improve portability of headers and sort them.
From Ngie Cooper in PR bin/51833
2018-01-17 00:16:43 +00:00
martin 87d689fb73 Sync sparc with sparc64 2018-01-14 19:59:51 +00:00