Commit Graph

3436 Commits

Author SHA1 Message Date
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
ozaki-r 11f91074e6 Change the prefix of test names to ipsecif_ to distinguish from tests for ipsec(4) 2018-01-11 07:58:22 +00:00