Commit Graph

4171 Commits

Author SHA1 Message Date
kamil 6639a5abb4 Add new fork/vfork/posix_spawn ATF tests in t_ptrace_wait*
Add unrelated tracer variation of tests: fork1-16, vfork1-16,
posix_spawn1-16.

All tests pass.
2020-01-29 03:51:56 +00:00
martin 34c1cedf61 Bump timeout to 3600 - the libarchive tests take quite a while to
complete (on a nearly 1 GHz dual armv7 machine it takes more than 700s)
2020-01-28 18:18:32 +00:00
martin 968a2fe40d PR 54902: fix octal numbers accidently spelled as decimal. 2020-01-28 07:12:08 +00:00
skrll 5d55fed31a Don't print the pagesize it messes up atf-report 2020-01-24 08:45:16 +00:00
martin 9a9189223f Fix the build: access_regs_set_unaligned_pc_* tests depend on availability
of gpregs
2020-01-23 06:17:21 +00:00
kamil 7c40686451 Add new ATF tests in t_ptrace_wait*
New tests:
 - access_regs_set_unaligned_pc_0x1
 - access_regs_set_unaligned_pc_0x3
 - access_regs_set_unaligned_pc_0x7

The purpose of these tests is check whether unaligned PC can panic the
kernel. If there is a panic it is fine to return EINVAL on PT_SETREGS.
New tests check respectively pc |= 0x1, pc |= 0x3 and pc |= 0x7.

Inspired by https://marc.info/?l=openbsd-bugs&m=107558043319084&w=2

While there fix access_regs6 to really test PT_SETREGS.
2020-01-21 16:46:07 +00:00
christos d6c17dbb31 Fix static linking (sun2) 2020-01-19 17:36:57 +00:00
christos 63fc2f472b not require .d files for the build. 2020-01-18 15:16:47 +00:00
ryoon 968f5fa0dc Fix build. Three list.h files are required to generate .d files 2020-01-18 13:56:53 +00:00
christos ad61858a16 new tests for libarchive 2020-01-17 16:25:37 +00:00
christos 77da719c4b new tests 2020-01-17 16:24:03 +00:00
ad 2ddceed1d9 Hopefully fix some problems seen with MP support on non-x86, in particular
where curcpu() is defined as curlwp->l_cpu:

- mi_switch(): undo the ~2007ish optimisation to unlock curlwp before
  calling cpu_switchto().  It's not safe to let other actors mess with the
  LWP (in particular l->l_cpu) while it's still context switching.  This
  removes l->l_ctxswtch.

- Move the LP_RUNNING flag into l->l_flag and rename to LW_RUNNING since
  it's now covered by the LWP's lock.

- Ditch lwp_exit_switchaway() and just call mi_switch() instead.  Everything
  is in cache anyway so it wasn't buying much by trying to avoid saving old
  state.  This means cpu_switchto() will never be called with prevlwp ==
  NULL.

- Remove some KERNEL_LOCK handling which hasn't been needed for years.
2020-01-08 17:38:41 +00:00
mgorny b4d38fb000 Add tests for reading registers from x86 core dumps 2020-01-08 17:23:34 +00:00
mgorny 7d1a2cdc58 Combine x86 register tests into unified test function
Reduce the code duplication and improve maintainability of x86 register
tests by combining all of them to a single base function.
2020-01-08 17:23:15 +00:00
mgorny adb864df5e Fix alignment when reading core notes
Both desc and note header needs to be aligned.  Therefore, we need
to realign after skipping past desc as well.

While at it, fix the other alignment fix to use roundup() macro.
2020-01-08 17:22:40 +00:00
msaitoh a5effc3ce9 s/inital/initial/ 2019-12-27 09:25:57 +00:00
kamil 7dea4f94d7 Read TLS base pointer with _lwp_getprivate()
This avoid usage of fast versions that are mostly internal to RTLD.
2019-12-25 02:23:37 +00:00
kamil bd290c46da Define _RTLD_SOURCE in t_ptrace_wait.c
The __lwp_gettcb_fast() and __lwp_getprivate_fast() functions are
namespaced on a selection of ports.
2019-12-24 21:09:38 +00:00
kamil 4f79a48470 Introduce PT_LWPSTATUS + PT_LWPNEXT, obsolete PT_LWPINFO
PT_LWPINFO is a legacy ptrace(2) operation that was originally intended
to retrieve the thread (LWP) information inside a traced process.

It has a number of flaws and is confused with PT_LWPINFO from FreeBSD.

PT_LWPSTATUS and PT_LWPNEXT address the problems (shortly by: rename,
removal of pl_event) and introduces new features: signal context
(pl_sigpend, pl_sigmask), LWP name (pl_name), LWP TLS base address
(pl_private). The private pointer was so far missing information for
a debugger.

PT_LWPSTATUS@nnn is now shipped with core(5) files and contain LWP specific
information, so far missed in the core(5) files.

PT_LWPSTATUS retrieves LWP information for the prompted thread.
PT_LWPNEXT retrieves LWP information for the next thread, borrowing the
semantics from NetBSD specific PT_LWPINFO.

PT_LWPINFO is namespaced with __LEGACY_PT_LWPINFO and still available for
the foreseeable future, without plans of removing it.

Add ATF tests for PT_LWPSTATUS + PT_LWPNEXT.

Keep ATF tests for PT_LWPINFO.

Switch GDB to new API.

Proposed on tech-kern@.
2019-12-24 14:50:59 +00:00
macallan 58c590cd7c disable string op warnings for t_strcat
now this builds on macppc with gcc 8.3
from riastradh@
2019-12-19 19:19:28 +00:00
christos ea19b263f1 Adjust tests for 0 hex values printing 0 instead of 0x0 2019-12-08 17:37:16 +00:00
christos 91fabc4486 Fix broken tests in big endian machines. Internally field values are
stored as uint64_t/uintmax_t so printing them with %d on big endian
ends up being 0.
2019-12-06 19:28:11 +00:00
kamil 1b325ed182 Log PID.LWP in t_ptrace_wait* tests for enabled debug
This is useful for multithreaded test scenarios.
2019-12-06 01:09:50 +00:00
hikaru 068d6bf691 Add HMAC-SHA-{256,384,512} test cases. 2019-12-03 04:20:45 +00:00
riastradh d6cbc02da6 Adapt <sys/pslist.h> to use atomic_load/store_*.
Changes:

- membar_producer();
  *p = v;

    =>

  atomic_store_release(p, v);

  (Effectively like using membar_exit instead of membar_producer,
  which is what we should have been doing all along so that stores by
  the `reader' can't affect earlier loads by the writer, such as
  KASSERT(p->refcnt == 0) in the writer and atomic_inc(&p->refcnt) in
  the reader.)

- p = *pp;
  if (p != NULL) membar_datadep_consumer();

    =>

  p = atomic_load_consume(pp);

  (Only makes a difference on DEC Alpha.  As long as lists generally
  have at least one element, this is not likely to make a big
  difference, and keeps the code simpler and clearer.)

No other functional change intended.  While here, annotate each
synchronizing load and store with its counterpart in a comment.
2019-12-01 15:28:19 +00:00
maxv 6f40daa312 Several improvements. In particular, reduce CS.limit, because Intel CPUs
perform strict sanity checks, and the previous (too high) limit caused the
VM entry to fail.
2019-11-22 10:26:32 +00:00
kre 5bb52324f6 Add a missing ("quoting") '>' in an atf_fail error message string.
Since the tests don't (usually) fail no-one ever noticed the missing char.

That is, the "received this" and "expected this" strings were supposed
to appear in the output err message as "<<string>>" but one of those
closing '>' chars was missing.

No-one should ever notice this change in normal operation, as the tests
are not intended to fail.
2019-11-12 18:59:51 +00:00
kamil 84cacc6757 Rework thread_concurrent_signals and trace_thread_lwpcreate_and_exit
Change the code to remove the LWP id assumptions that broke after
src/sys/kern/kern_lwp.c r. 1.206.

Original code by <mgorny>, tested and tweaked by myself.
2019-11-12 18:18:04 +00:00
yamaguchi 0c3bbc580c atf: add test cases for MTU that is increased on SIOCSETVLAN
From t-kusaba@IIJ, thanks
2019-11-11 02:40:48 +00:00
joerg ed08d30824 Avoid warnings about tautological left shifts as conditional. 2019-10-28 18:10:22 +00:00
maxv a6418236ed Add the "nvmm" group, and make nvmm_init() public. Sent to tech-kern@ a few
days ago.
2019-10-27 07:08:15 +00:00
christos a33f2da334 - use accept4 instead of paccept for everyone.
- add test for accept preserving non-block
- comment on FreeBSD and Linux behavior.
2019-10-26 23:08:27 +00:00
maxv e6f32a5866 Three changes in libnvmm:
- Add 'mach' and 'vcpu' backpointers in the nvmm_io and nvmm_mem
   structures.

 - Rename 'nvmm_callbacks' to 'nvmm_assist_callbacks'.

 - Rename and migrate NVMM_MACH_CONF_CALLBACKS to NVMM_VCPU_CONF_CALLBACKS,
   it now becomes per-VCPU.
2019-10-23 12:02:55 +00:00
maxv f9fb7866ce Miscellaneous changes in NVMM, to address several inconsistencies and
issues in the libnvmm API.

 - Rename NVMM_CAPABILITY_VERSION to NVMM_KERN_VERSION, and check it in
   libnvmm. Introduce NVMM_USER_VERSION, for future use.

 - In libnvmm, open "/dev/nvmm" as read-only and with O_CLOEXEC. This is to
   avoid sharing the VMs with the children if the process forks. In the
   NVMM driver, force O_CLOEXEC on open().

 - Rename the following things for consistency:
       nvmm_exit*              -> nvmm_vcpu_exit*
       nvmm_event*             -> nvmm_vcpu_event*
       NVMM_EXIT_*             -> NVMM_VCPU_EXIT_*
       NVMM_EVENT_INTERRUPT_HW -> NVMM_VCPU_EVENT_INTR
       NVMM_EVENT_EXCEPTION    -> NVMM_VCPU_EVENT_EXCP
   Delete NVMM_EVENT_INTERRUPT_SW, unused already.

 - Slightly reorganize the MI/MD definitions, for internal clarity.

 - Split NVMM_VCPU_EXIT_MSR in two: NVMM_VCPU_EXIT_{RD,WR}MSR. Also provide
   separate u.rdmsr and u.wrmsr fields. This is more consistent with the
   other exit reasons.

 - Change the types of several variables:
       event.type                  enum -> u_int
       event.vector                uint64_t -> uint8_t
       exit.u.*msr.msr:            uint64_t -> uint32_t
       exit.u.io.type:             enum -> bool
       exit.u.io.seg:              int -> int8_t
       cap.arch.mxcsr_mask:        uint64_t -> uint32_t
       cap.arch.conf_cpuid_maxops: uint64_t -> uint32_t

 - Delete NVMM_VCPU_EXIT_MWAIT_COND, it is AMD-only and confusing, and we
   already intercept 'monitor' so it is never armed.

 - Introduce vmx_exit_insn() for NVMM-Intel, similar to svm_exit_insn().
   The 'npc' field wasn't getting filled properly during certain VMEXITs.

 - Introduce nvmm_vcpu_configure(). Similar to nvmm_machine_configure(),
   but as its name indicates, the configuration is per-VCPU and not per-VM.
   Migrate and rename NVMM_MACH_CONF_X86_CPUID to NVMM_VCPU_CONF_CPUID.
   This becomes per-VCPU, which makes more sense than per-VM.

 - Extend the NVMM_VCPU_CONF_CPUID conf to allow triggering VMEXITs on
   specific leaves. Until now we could only mask the leaves. An uint32_t
   is added in the structure:
	uint32_t mask:1;
	uint32_t exit:1;
	uint32_t rsvd:30;
   The two first bits select the desired behavior on the leaf. Specifying
   zero on both resets the leaf to the default behavior. The new
   NVMM_VCPU_EXIT_CPUID exit reason is added.
2019-10-23 07:01:11 +00:00
kamil a73248db21 Remove preprocessor switch TEST_LWP_ENABLED in t_ptrace_wait*
LWP tests are now enabled always and confirmed to be stable.
2019-10-21 18:36:08 +00:00
kamil eb8ea5d12d Remove preprocessor switch TEST_VFORK_ENABLED in t_ptrace_wait*
vfork(2) tests are now enabled always and confirmed to be stable.
2019-10-21 18:31:40 +00:00
mgorny 050caffe42 Fix a race condition when handling concurrent LWP signals and add a test
Fix a race condition that caused PT_GET_SIGINFO to return incorrect
information when multiple signals were delivered concurrently
to different LWPs.  Add a regression test that verifies that when 50
threads concurrently use pthread_kill() on themselves, the debugger
receives all signals with correct information.

The kernel uses separate signal queues for each LWP.  However,
the signal context used to implement PT_GET_SIGINFO is stored in 'struct
proc' and therefore common to all LWPs in the process.  Previously,
this member was filled in kpsignal2(), i.e. when the signal was sent.
This meant that if another LWP managed to send another signal
concurrently, the data was overwritten before the process was stopped.

As a result, PT_GET_SIGINFO did not report the correct LWP and signal
(it could even report a different signal than wait()).  This can be
quite reliably reproduced with the number of 20 LWPs, however it can
also occur with 10.

This patch moves setting of signal context to issignal(), just before
the process is actually stopped.  The data is taken from per-LWP
or per-process signal queue.  The added test confirms that the debugger
correctly receives all signals, and PT_GET_SIGINFO reports both correct
LWP and signal number.

Reviewed by kamil.
2019-10-21 17:07:00 +00:00
christos d35ed14f2a opening a symlink with O_NOFOLLOW is expected to fail. 2019-10-20 16:02:11 +00:00
ozaki-r 3cb3151cb2 tests: add tests for the validateion of net.inet6.ip6.temppltime 2019-10-16 07:42:22 +00:00
jhigh ab00eaeb2d added test cases
invalid version specification
	salt too short
2019-10-14 14:48:48 +00:00
jhigh b640afc213 added versioning tests for argon2 2019-10-14 14:37:31 +00:00
maxv c496a7b118 Implement XCHG, add associated tests, and add comments to explain. With
this in place the Windows 95 installer completes successfuly.

Part of PR/54611.
2019-10-14 10:39:24 +00:00
jhigh 3f4bc82592 removed incorrectly added file 2019-10-14 06:40:40 +00:00
jhigh 499c4e53b1 adding argon2 tests 2019-10-14 03:47:19 +00:00
christos 85f5895969 add missing initializer 2019-10-14 01:15:32 +00:00
maxv 416eaf02dc Fix incorrect parsing: the R/M field uses a special GPR map when the
address size is 16 bits, regardless of the actual operating mode. With
this special map there can be two registers referenced at once, and
also disp16-only.

Implement this special behavior, and add associated tests. While here
simplify a few things.

With this in place, the Windows 95 installer initializes correctly.

Part of PR/54611.
2019-10-13 17:32:15 +00:00
kamil bec2cbec70 Fix race in t_ptrace_wait* LWP tests
Increment the done variable under a mutex. This variable was updated
non-atomically and sometimes not reaching the expected treshold.
2019-10-13 09:42:15 +00:00
mrg 4e545ef793 ifr_name is nul terminated. make it so. 2019-10-13 07:46:16 +00:00
mrg de11d87641 introduce some common variables for use in GCC warning disables:
GCC_NO_FORMAT_TRUNCATION    -Wno-format-truncation (GCC 7/8)
GCC_NO_STRINGOP_TRUNCATION  -Wno-stringop-truncation (GCC 8)
GCC_NO_STRINGOP_OVERFLOW    -Wno-stringop-overflow (GCC 8)
GCC_NO_CAST_FUNCTION_TYPE   -Wno-cast-function-type (GCC 8)

use these to turn off warnings for most GCC-8 complaints.  many
of these are false positives, most of the real bugs are already
commited, or are yet to come.


we plan to introduce versions of (some?) of these that use the
"-Wno-error=" form, which still displays the warnings but does
not make it an error, and all of the above will be re-considered
as either being "fix me" (warning still displayed) or "warning
is wrong."
2019-10-13 07:28:04 +00:00
kamil 1f5d3e8c5d Enable TEST_LWP_ENABLED in t_ptrace_wait*
The LWP events (created, exited) are now reliable in my local tests.

PR kern/51420
PR kern/51995
2019-10-13 04:05:39 +00:00
kamil 5a3fb2eb52 Bump the number of threads in LWP t_ptrace_wait*() tests from to 100
This is a torture, but on purpose to catch LWP_CREATED and LWP_EXITED bugs.
The threads do nothing other than calling sched_yield() in a loop.

MAXLWP is now defined to 2048 on all ports.

This change effects the following tests:

 - trace_thread_nolwpevents
 - trace_thread_lwpexit
 - trace_thread_lwpcreate
 - trace_thread_lwpcreate_and_exit
2019-10-13 04:00:12 +00:00
mrg ad0c4b353e use memcpy() for non C-strings. 2019-10-06 01:05:36 +00:00
mrg 662908cac2 sprintf->snprintf 2019-10-05 22:06:29 +00:00
christos 6b7001662d Add tests for escape sequences. 2019-10-05 20:24:16 +00:00
jhigh c7ab523edc adding full scheme comparison to libcrypt:crypt and pwhash tests 2019-10-05 18:06:16 +00:00
mrg a83f6c1317 msg:
avoid passing the same pointer in multiple arguments for restrict
marked arguments:
- sigaction() wants separate in/out
- use memmove() not memcpy() for overlapping regions (this may fix
  a real bug in nvi -- but it seems unlikely)
- select() wants separate read/write/except
- sigprocmask() wants separate set/oset
2019-10-04 09:01:59 +00:00
kamil 081796c351 Remove ATF t_ptrace_wait test suspend1
The tests verifies that a thread can be suspended by a debugger and later
resumed by a tracee.

This is an unwanted behavior and will be fixed soon.
2019-10-02 23:15:09 +00:00
kamil 1f257ef9aa Merge PT_GET_PROCESS_STATE checks into traceme_raise ATF ptrace tests
Assert that PT_GET_PROCESS_STATE for !child and !lwp events returns
non-error and zeroed struct ptrace_state.

These checks are not really special to traceme_raise, it's just an
opportunity to reuse them in an existing tests without writing a dedicated
one.

This behavior is needed to maintain in 3rd party software (GDB).
2019-10-01 22:26:38 +00:00
kamil b0c977dcb4 Add a few static asserts in t_ptrace_wait.c for conditions that must be kept
Assert that ptrace_state and siginfo_t's _ptrace_state are synchronized.
2019-10-01 21:13:30 +00:00
mrg 21303c93e9 convert HAVE_GCC == 7 to HAVE_GCC >= 7. 2019-09-29 23:44:58 +00:00
christos 38a0431bfa Restore binary compatibility by using the statvfs90 structure internally. 2019-09-23 12:00:57 +00:00
kre f77bb6aeed Initialise the sometvs array of struct timeval that is to be used to
validate that utimes() cannot update the times of a file on a read only
filesystem.   The values are never actually used, but since
	src/sys/kern/vfs_syscalls.c 1.535
they are validated for sanity, and the syscall returns EINVAL if the
values passed are invalid (tv_usec <0 or >= 1000000).  If that happens
we don't get as far as the test which produces the EROFS that is expected
from this test (these tests - one for each filesystem type).

So, init the timeval structs (just to 0, the values will still not be
used) so that the EINVAL doesn't bite us before we're eaten by the EROFS
which is the way we're supposed to die.

If the syscall API args were labelled as "const" the compiler probably
would have caught the use of uninit'd vars and complained much sooner.
2019-09-21 14:25:42 +00:00
blymn e275f7f7db Rototill to add complex character support:
- Add cchar command to director test language to allow a complex character
  to be defined and passed to the slave.
- Removed the distinction between args and returns internally to prevent
  confusing the two which leads to errors and/or crashes.
- Converted mutt_test to use the new cchar definition and fixed the
  check files for the test.
2019-09-19 11:31:57 +00:00
christos 3f24065918 Remove the incomplete define. 2019-09-15 23:39:13 +00:00
christos 7d2cda35f1 Add tests for fexecve(2) 2019-09-15 16:53:58 +00:00
christos 0a76d2ed5a Add F_GETPATH, presented to tech-kern. 2019-09-15 16:25:57 +00:00
roy 801b070c3c t_arp: Wait for 10 seconds for RTM_MISS
Let's try increasing the ping timeout to try and fix PR misc/54525.
2019-09-09 10:29:04 +00:00
roy 07f3df8b72 tests: fix ARP and NDP tests for RTM_* messages
While here add tests for RTM_MISS.
2019-09-03 19:07:50 +00:00
brad 01424baa92 The cleaner is compiled into the ATF test harness for the LFS
filesystem tests.  Use the new -J option to pass the raw device into
the cleaner.  This avoids the not rump safe getdiskrawname call and
makes sure we use an internal rump device name for cleaning.  This
should fix bin/54488.
2019-08-30 23:45:13 +00:00
kamil 1a5f018b01 Enhance the support of LLVM sanitizers
Define _REENTRANT for MKSANITIZER build. This is needed for at least stdio
code. This caused new build issued with duplicated symbols in few places
and rump kernel code picking different code paths borrowed from libc.
Handle all this in one go.

Add bsd.sanitizer.mk to share common code used by programs and libraries.

Switch from realall to beforeinstall target in .syms files. This is more
reliable in MKSANITIZER.
2019-08-27 22:48:53 +00:00
ozaki-r b5415e57cd tests: add tests for IPv6 link-local addresses with a scope ID
Setting an address with a scope ID doesn't work for rump.ifconfig for some
reasons and needs $HIJACKING for now.  The bug should be fixed someday.
2019-08-26 07:41:50 +00:00
ozaki-r c6ad1822be tests: explain how rump_server_check_memleaks works 2019-08-26 04:50:32 +00:00
ozaki-r 06b680af2f tests: restore rump_server_check_poolleaks for llentpl
It didn't work correctly because rumphijack for vmstat didn't work expectedly;
vmstat has the sgid bit for kvm(3) and that prevents rumphijack from working.

Address the issue by cloning a vmstat binary without the sgid bit temporarily
and using it for rumphijack.  Note that it's a workaround.  vmstat should stop
using kvm(3) for /dev/kmem and drop the sgid bit eventually.
2019-08-26 04:50:03 +00:00
kamil 5612f2cac8 Define target_not_supported_body() in TSan, MSan and libFuzzer tests 2019-08-23 06:39:54 +00:00
ozaki-r 571560e45c Disable rump_server_check_memleaks for now
It doesn't work in some cases.
2019-08-20 09:53:45 +00:00
ozaki-r 7c447e107e tests: check pool object leaks
Currently only llentpl leaks can be detected.
2019-08-19 03:22:47 +00:00
ozaki-r ce0ae1dfed tests: use rump_server_add_iface to create interfaces 2019-08-19 03:22:05 +00:00
ozaki-r b271a6e258 tests: enable to create interfaces other than shmif with rump_server_add_iface
For this change interfaces are destroyed in the reverse order of their
creations in case there are dependencies between interfaces.
2019-08-19 03:21:13 +00:00
ozaki-r 3a470f73b4 tests: fix test header name 2019-08-19 03:20:27 +00:00
kamil f0720e6929 Add ATF c and c++ tests for TSan, MSan, libFuzzer
These tests require Clang/LLVM 7 or newer on NetBSD.

Contributed by Yang Zheng during GSoC 2018.
2019-08-18 20:15:58 +00:00
gson 40aea22397 The udf_renamerace test case no longer fails due to PR kern/49046, but
it does fail due to PR kern/53865 on real hardware.
2019-08-17 09:44:01 +00:00
kamil d383d9b590 Avoid symbol clashes in test/rump/modautoload/t_modautoload with sanitizers
Set SANITIZER_RENAME_SYMBOL.t_modautoload to:

 * sysctlbyname
 * sysctlgetmibinfo
2019-08-17 04:04:28 +00:00
kamil 8d8be769a2 Adapt tests/kernel/t_subr_prf for MKSANITIZER
Allow to rename snprintf-like functions to avoid clashes with a sanitizer.

This tests needs a fixup to remove 'undef symbol' from the test code
generator.
2019-08-15 08:46:09 +00:00
kamil fab4b3f46f Avoid symbol clashes in bin/df under MKSANITIZER
Remove symbol conflicts for: __getmntinfo13
2019-08-15 08:24:11 +00:00
kamil 5d3c833b7d Avoid symbol clashes in fs/nfs/nfsservice under MKSANITIZER
Remove symbol conflicts for: __getmntinfo13
2019-08-15 08:23:45 +00:00
kamil 825c3698b4 Avoid symbol clashes in tests/usr.bin/id under MKSANITIZER
Remove symbol conflicts for:

 - __getpwnam50
 - __getpwuid50
 - getgrgid
 - getgrouplist
 - getgroups
2019-08-15 08:22:52 +00:00
kamil 1101023c0c Fix build of t_ubsan/t_ubsanxx under MKSANITIZER
Do not link micro-ubsan runtime for disabled tests.

This avoids double symbols linked into a single binary.
2019-08-15 08:17:32 +00:00
ozaki-r bce11250f5 tests: check if ifconfig (ioctl) works after a failure of ifconfig destroy
This is a test for PR kern/54434.
2019-08-15 04:21:33 +00:00
ozaki-r caa310059a Make a permanet neighbor cache to avoid sending an NS packet disturbing the test
A receiver of an ICMPv6 request packet creates a stale cache entry and it turns
into the delay state on replying the packet.  After 5 second, the receiver sends
an NS packet as a reachability confirmation, which disturbs the test and causes
a unexpected result.

Should fix PR misc/54451
2019-08-13 07:20:43 +00:00
martin 7f7ec27799 Re-enable the QEMU specific timing limits, but only an increased upper
limit for now - let's see if that works on the test-bed.
2019-08-11 11:42:23 +00:00
martin 98d251c113 PR lib/54440: adapt the FreeBSD change to this test and calculate time
differences more exact, allowing between 0 and 1 s delay between the
expected wakeup and the actual event happening.
Also convert the QEMU special case code to the same scheme, but for now
disable it (with XXX mark) and see if the proper timing limits fix that
case too.
If not, we will re-enable the QEMU special case.
2019-08-10 07:36:15 +00:00
christos 92bbbea0b3 PR/54414: Valery Ushakov: add a test for wcsrtombs(3) doesn't update the
source argument on conversion error
2019-07-28 13:46:45 +00:00
ozaki-r ac002ee323 tests: add tests for getspi and udpate 2019-07-23 04:31:25 +00:00
kre 311f349816 Stop assuming that printf handles options in any way at all
(it doesn't - that is, shouldn't) which includes processing -- as an
"end of options".  The first arg is (always) the format string.

Remove/fix tests that assumed the contrary.

Problem (with printf) pointed out on tech-userlevel by Thierry Laronde.
2019-07-21 15:25:59 +00:00
kre da8bc57f2b Correct a typo. It is atf_require_prog not atf_require_pfog ... 2019-07-21 15:00:18 +00:00
ozaki-r 2f33341a03 tests: extract all kernel logs, not just a panic message, from rump_server.core 2019-07-18 04:22:22 +00:00
ozaki-r bc1d718ff0 tests: shorten the expire time of neighbor caches to reduce the runtime of the tests 2019-07-18 04:00:09 +00:00
christos fbf9c51ff3 fix misplaced paren 2019-07-16 21:13:28 +00:00
martin 653f037ebe PR misc/54382: whenever open(2) is called with O_CREAT, make sure to
pass an open mode argument.
2019-07-16 17:29:17 +00:00
gson b9a5a0bbdb In the setitimer_old test case, allow for time passing between the two
setitimer() calls.  Should fix PR kern/54370.
2019-07-13 12:44:02 +00:00
msaitoh 03e9d50adf Fix typo (s/supress/suppress/). 2019-07-11 03:49:51 +00:00
martin 0509bcf964 Gracefully skip test if not enough space in temporary directory. 2019-07-10 06:21:40 +00:00
martin 33a5a5b239 Reduce disk image size for tests (PR 44239 has been fixed) 2019-07-10 06:10:54 +00:00
martin d903b87a2d Make sure we have enough free inodes before running the filename_expansion
test.
2019-07-10 05:57:43 +00:00
maya 36592171e1 return return atf_no_error() instead of 0 for consistency.
suggested by moritzbuhl in https://github.com/NetBSD/src/pull/11/
2019-07-09 16:24:01 +00:00
gson 7753bf0b70 Update require.memory to match the increased rlimit. 2019-07-09 13:59:25 +00:00
ozaki-r a96cce565c tests: check that a new cache is not created over the limit 2019-07-09 02:50:24 +00:00
ozaki-r 24bc91d9f1 Add ATF test for a description.
From t-kusaba@IIJ
2019-07-04 02:46:40 +00:00
kamil c4f0499ad5 Avoid GCC warning on NetBSD/i386
Cast note_hdr.n_namesz to ssize_t through size_t to avoid potential
signedness bit shifts.
2019-07-01 02:04:37 +00:00
blymn f3430e9b6f Fix test for pad and enable it. 2019-06-30 22:37:11 +00:00
blymn afb56d5385 Enable mvscanw test since libcurses is now correct. 2019-06-30 22:21:33 +00:00
mgorny dba7737605 Add a test for verifying procinfo note inside coredumps.
Add a first test for triggering a core dump in the debugged process
(via PT_DUMPCORE) and verifying it.  The test finds procinfo note
and checks its contents.

The core dump is processed through libelf.  However, it only provides
for finding all note segments (or sections?).  I had to implement
finding and processing individual notes myself.  I've added
a core_find_note() function that will be reused in future tests.

Reviewed by kamil.
2019-06-30 21:20:04 +00:00
ozaki-r 2ed6d11366 tests: test state transitions of neighbor caches 2019-06-28 06:46:04 +00:00
blymn edb52aabb2 Enable beep test, return is correct. 2019-06-26 22:18:44 +00:00
mgorny c2ad96ff63 Implement PT_GETXSTATE and PT_SETXSTATE
Introduce two new ptrace() requests: PT_GETXSTATE and PT_SETXSTATE,
that provide access to the extended (and extensible) set of FPU
registers on amd64 and i386.  At the moment, this covers AVX (YMM)
and AVX-512 (ZMM, opmask) registers.  It can be easily extended
to cover further register types without breaking backwards
compatibility.

PT_GETXSTATE issues the XSAVE instruction with all kernel-supported
extended components enabled.  The data is copied into 'struct xstate'
(which -- unlike the XSAVE area itself -- has stable format
and offsets).

PT_SETXSTATE issues the XRSTOR instruction to restore the register
values from user-provided 'struct xstate'.  The function replaces only
the specific XSAVE components that are listed in 'xs_rfbm' field,
making it possible to issue partial updates.

Both syscalls take a 'struct iovec' pointer rather than a direct
argument.  This requires the caller to explicitly specify the buffer
size.  As a result, existing code will continue to work correctly
when the structure is extended (performing partial reads/updates).
2019-06-26 12:30:12 +00:00
blymn 6e08cf3636 Fixed mvscanw test but leave disabled for the moment, the return for
mvscanw is incorrect in libcurses, we need a major lib version bump
to correct it.
2019-06-25 22:19:29 +00:00
skrll b801bf2f56 Another spello of 'unknown' 2019-06-24 06:26:29 +00:00
isaki e0eeaafc81 Rewrite t_pad test.
Previous version compared the pad's output binary passed mulaw-slinear
conversion and frequency conversion with the prepared "good result".
In such case, a test may fail when the implemantation changes.  In fact,
the frequency conversion algorithm was changed in isaki-audio2, so
output waveforms is not completely the same (but that's no problem with
the audio waveforms).
New version uses slinear_le/2ch/44100Hz input data and compares the
output binary with the input data.  pad with no conversions should
output the same binary.
Fix PR kern/54187.
2019-06-20 12:14:46 +00:00
kamil 177438b064 Add mkfifo{,at}(2) mode in mknod{,at}(2) as requested by POSIX
mknod with mode & S_IFIFO and dev=0 shall behave like mkfifo.

Update the documentation to reflect this state.

Add ATF tests.

This is an in-kernel implementation as typically user-space programs use
mkfifo(2) directly, however whenever there is need to bypass libc (like in
valgrind) then portable POSIX software calls the mknod syscall.

Noted on tech-kern@ by Greg Troxel.
2019-06-20 03:31:53 +00:00
kamil 6923eb2928 Allow to conditionally enable LWP ATF tests in t_ptrace_wait*
By default the tests are disabled.
2019-06-18 21:14:26 +00:00
gson 8d7fd85720 The runtime of the ecdsa test case increased approximately sixfold
with the openssl update on 2019-06-09, and it is now timing out on
sparc.  Increase the timeout by roughly the same factor.
2019-06-16 10:45:50 +00:00
kamil 0937aecd4c Enable vfork(2) ATF tests in t_ptrace_wait*
The racing issues are gone in my local setup.
2019-06-13 20:26:06 +00:00
kamil 3d6a33dc1e Add new ATF ptrace(2) tests for posix_spawn, reusing tests for fork/vfork
New tests:
 - posix_spawn_detach_spawner
 - posix_spawn_kill_spawner
 - posix_spawn_singalmasked
 - posix_spawn_singalignored

All test pass.
2019-06-12 17:07:11 +00:00
kamil 3bdf3dd9d4 Add new PTRACE_POSIX_SPAWN tests in ptrace(3)
Add test:
 - eventmask_preserved_posix_spawn
 - fork9..fork16
 - vfork9..vfork16
 - posix_spawn1..16

New tests verify semantics of PTRACE_POSIX_SPAWN.

All tests pass.
2019-06-11 23:30:05 +00:00
hannken 22d3f49885 Need rumpdev_disk for rumpfs_zfs. 2019-06-11 14:00:16 +00:00
blymn 1c4bb036d6 Fixed bug in curses library keyname, test now passes. 2019-06-11 10:23:36 +00:00
blymn aa404db794 Bracket strings being validated with markers to ensure sneaky whitespeace
is noticed.
2019-06-11 10:22:35 +00:00
gson dd9a375876 In the "got %d/%d" message printed at the end of the pingsize test,
make the latter number show the actual number of ICMP packets the test
attempted to send.  Thus, the two numbers can now be meaningfully
compared, and their difference indicates the number of packets lost.
2019-06-11 08:34:01 +00:00
blymn 347a95cdfb Fix dupwin test. 2019-06-11 08:09:35 +00:00
blymn 77b858f20e fix derwin test. 2019-06-11 08:00:38 +00:00
kamil 0b4f3508ae Add posix_spawn(3) ATF tests in t_ptrace_wait*
New tests verify whether forking process reports forking events to a
debugger.

Right now there is no support in the kernel for this system.
2019-06-10 22:16:06 +00:00
kamil 9faafe843f Add more verbosity to debug messages in t_ptrace_wait
Log func() file:line for each debug message.

Most messages are similar one with the other and this change allows easier
navigation in the code.
2019-06-10 21:18:04 +00:00
blymn 1a6faca1b0 Add a script that allows a check file to be created by cutting and
pasting the contents of the square brackets in the "Excess nn bytes
from slave" message emitted when the director is running in verbose
mode (-v).
2019-06-09 07:54:55 +00:00
blymn 94110ecce1 Adjust check files for changes in cursor positioning. 2019-06-09 07:49:42 +00:00
blymn 437fe1c40c Add an extra parameter to the h_run function so flags can be passed
to the director.
2019-06-09 07:48:47 +00:00
maxv d1002cd7eb Change the NVMM API to reduce data movements. Sent to tech-kern@. 2019-06-08 07:27:44 +00:00
christos da8b7648ed Add a $ORIGIN test 2019-06-07 21:18:16 +00:00
gson 1430c33c98 Add a regression test for PR bin/54154, or in other words, make sure
we get notified in a timely manner if gdb's XML support disappears
again.
2019-06-07 19:05:15 +00:00
mgorny d3a3574d75 Fix alignment of SSE filling data 2019-06-04 12:17:42 +00:00
mgorny e00cc41d74 Add more debug to register writing tests 2019-06-04 12:17:05 +00:00
kamil 173c420d5d Fix a mistake in a test for KERN_PROC_CWD
Emit properly ENOENT scenario in chroot. For some reason the final patch
did not hit the tree.
2019-06-01 22:18:23 +00:00
kamil 707a3080aa Add ATF KERN_PROC_CWD tests 2019-06-01 19:49:02 +00:00
kre 9c62ddd5c1 Deal with fallout from the addition of
KERN_PROC_CWD in sysctl(3)
That is kern.proc.$$.KERN_PROC_CWD (I think - not that it matters here)

The effect is that -lrump now requires -lrumpvfs

This set of changes fixes (I believe) regular dynamic builds,
more might be required for static builds (will be verified soon).
2019-06-01 06:59:17 +00:00
gson db7bf52ef5 Increase the timeout for the manyaddrs test case; the default is often
insufficient under qemu.
2019-05-31 15:36:10 +00:00
maya 6eb8aac828 Print result of function we tested (sinf),
not of function we didn't test (sin).

no need to print 17 digits for a float.

from Riastradh.
2019-05-27 00:24:37 +00:00
maya 5d16d0ee65 on i386 with FLT_EVAL_METHOD=2, the computation inside cosf was done in
binary80 arithmetic and never rounded to binary32 at the end, so it
appeared farther from the correctly rounded result in binary32 than expected.

Force binary32 using volatile float.

PR lib/54232: lib/libm/t_cos:cosf_angles regression on i386

From Riastradh.
2019-05-27 00:10:36 +00:00
blymn ae5e88e264 Add more tests for curses 2019-05-26 09:54:32 +00:00
blymn 81750f8bcd Start supporting wide char tests. 2019-05-26 07:47:37 +00:00
blymn 002c700f46 Adjust copywin test to work correctly with updated curses.
This fixes PR 54231
2019-05-26 07:28:14 +00:00
kamil f3514b55f9 Drop no longer needed macros KCOV_STORE() KCOV_LOAD() in kcov(4)
Corrently KCOV_STORE() and KCOV_LOAD() are equivalent to x=y.

Obtained from <R3x>
2019-05-26 01:44:34 +00:00
kamil 1a993279dc Add new user_va0_disable* tests in t_ptrace_wait*
Add tests:
 - user_va0_disable_pt_continue
 - user_va0_disable_pt_syscall
 - user_va0_disable_pt_detach

Assert that setting PC to 0x0 in PT_CONTINUE/PT_SYSCALL/PT_DETACH for
vm.user_va0_disable==0 is disallowed.
2019-05-25 03:25:08 +00:00
kamil 3978be2006 Add get_user_va0_disable() in t_ptrace_wait.h
Add a utility function to check vm.user_va0_disable.
2019-05-25 03:22:53 +00:00
christos 64bf11ba3e unexpand 2019-05-21 04:10:20 +00:00
christos 38217df340 add printf attribute 2019-05-21 04:09:46 +00:00
kre 8b2a560acf Make the t_subr_prf test build after changes to sys/kern/subr_prf.c
and while here add a simple test for the new kernel vasprintf().
2019-05-21 03:46:45 +00:00
blymn 84da1bf133 Add option to specify an alternate library location to allow testing
a development library version without installing it.
2019-05-19 22:34:23 +00:00
christos af5402251e Add explanatory text 2019-05-15 13:43:45 +00:00
christos 292b510fe2 clang ifunc's on powerpc require secure-plt. 2019-05-14 19:07:07 +00:00
bad 48e354a3ed Get rid of all the -lrumpdev and -lrumpvfs that are no longer needed
after moving rump's mainbus from rumpdev to rumpkern.

Produces the same atf-run results as before.
2019-05-13 17:55:07 +00:00
blymn ac3404f424 Provide correct validation after curses change. 2019-05-12 02:37:24 +00:00
maxv bfb4017486 Rework the machine configuration interface.
Provide three ranges in the conf space: <libnvmm:0-100>, <MI:100-200> and
<MD:200-...>. Remove nvmm_callbacks_register(), and replace it by the conf
op NVMM_MACH_CONF_CALLBACKS, handled by libnvmm. The callbacks are now
per-machine, and the emulators should now do:

-	nvmm_callbacks_register(&cbs);
+	nvmm_machine_configure(&mach, NVMM_MACH_CONF_CALLBACKS, &cbs);

This provides more granularity, for example if the process runs two VMs
and wants different callbacks for each.
2019-05-11 07:31:56 +00:00
mgorny 989594cf4b Add PT_SET*REGS tests for mm/xmm registers. 2019-05-10 18:07:10 +00:00
mgorny d0d1caee46 Remove obsolete size asserts. 2019-05-10 17:34:26 +00:00
mgorny d8aacecd69 Use newly-filled i386 reg structs in PT_GETFPREGS & PT_GETXMMREGS tests. 2019-05-10 16:28:00 +00:00
mgorny 2d583f722a Add tests for PT_SETREGS 2019-05-10 16:24:35 +00:00
mgorny 873249d162 Add ptrace() tests for reading mm* and xmm* registers 2019-05-09 13:07:35 +00:00
christos 7ef0a4297e fix unused variable warnings. 2019-05-06 00:08:13 +00:00
mgorny f07d526de7 Introduce tests for reading r8..r15 registers. 2019-05-05 18:16:39 +00:00
mgorny e6dd84e00f Reintroduce i386 tests for general-purpose registers, without MMX req
Reintroduce the test for reading i386 general-purpose register values
from the debugged program.  This time it's split into one test for the six
registers not normally used by the compiler (eax..edx, esi, edi), and another
for ebp, esp.  This leaves enough free registers for the latter to work
without MMX.
2019-05-05 18:15:40 +00:00
mgorny b3185a33be Revert i386_regs_gp_read as it fails on non-MMX systems. 2019-05-05 15:05:22 +00:00
mgorny 15af42397a Add tests for reading pre-set general purpose register values via PT_GETREGS.
Add new tests verifying that PT_GETREGS provides correct register values
from the underlying program.  The test uses inline assembly in the child program
to set registers to well-known constants, then compares the results obtained
via PT_GETREGS against them.

Reviewed by kamil.
2019-05-05 10:04:11 +00:00
kre b7fc669e75 Fix an (apparent) ancient ash bug, that was apparently fixed sometime
in the past, but managed to re-surface...

The expression "${0+\}}" should expand to "}" not "\}"
Almost all other shells handle it that way (incl FreeBSD & dash).

Issue pointed out by Martijn Dekker.

Add ATF sub-tests for the 4 old var expand operators (${var+word}
${var-word} ${var-word} and ${var?word} - including the forms
with the ':' included) and amongst those tests include test cases
for this issue, so if the bug tries to appear again, we can squash
it quicker.   (The newer pattern matching operators are already
well tested as part of testing patterns.)
2019-05-04 02:52:22 +00:00
kamil e6d350579a Adapt t_ptrace_wait* tests for recent kernel changes
Adapt AUXV reading loop to handle io.piod_len == 0 as EOF.

Temporarily disable trace_thread_lwpcreate until it will be verified that
it is stable.
2019-05-02 22:52:21 +00:00
kamil a2a627f040 Rename and partially enable trace_thread ATF ptrace(2) tests
Rename trace_thrad[1234] to more meaningful names:

 - trace_thread_nolwpevents
 - trace_thread_lwpexit
 - trace_thread_lwpcreate
 - trace_thread_lwpcreate_and_exit

In my local tests LWP CREATE events work as expected.
LWP EXIT ones are still racy and keep them disabled racy.

PR kern/51995
2019-05-02 00:34:06 +00:00
kamil f33e5cf82e ATF ptrace(2) tests suspend1 and resume1 now pass
Verified on bare metal and in qemu.

PR kern/51995
2019-05-01 23:44:16 +00:00
kamil 786ec9cc85 ATF ptrace(2) tests signal9 and signal10 now pass
PR kern/51918
2019-05-01 21:59:32 +00:00
kamil 9cd3398aac Add new fork/vfork ATF trests in t_ptrace_wait*
Add new tests:

 - fork_detach_forker
 - vfork_detach_vforker
 - vfork_detach_vforkerdone
 - fork_kill_forker
 - vfork_kill_vforker
 - vfork_kill_vforkerdone

All tests pass with recent kernel changes.
2019-05-01 18:20:23 +00:00
kamil 514747201b Add new ATF ptrace(2) tests: bytes_transfer_eof
Assert that error is returned after attempt to read or write post EOF.
2019-04-30 22:39:31 +00:00
kre 63e182f423 snprintb(3) says that, in the new(?) Torek format, all fields specs end with \0
The F spec is one of those, it should be terminated with \0 just like all
the others (irrelevant that it has no extra data to delimit).

Fix <sys/mman.h> to define the snprintb() format string correctly (include
the missing \0's).   Fix the copy of that definition included into
snprintb(3) to match the updated mman.h version (ride the date bump
from the day before yesterday .. this is the same change, just corrected).

Undo the previous snprintb.c change ("off by one" fix) which was an
attempt to make the broken mman.h usage work (and did, but not the way
it should be done).   Also, after using the new * format (instead of only
when something has already matched) skip the associated data so we don't
attempt to interpret it as more field specifiers.  This func needs lots of TLC!

Fix the ATF tests for snprintb() to not assume that F format is really
exactly like f format, and has data after the field specifier.  It doesn't.
Add several more tests (including testing the '*' field operator
recently added).
2019-04-29 07:55:38 +00:00
maya af8d450a9a Use LDADD, which apparently puts the libraries at the end of the command,
and makes static builds (aka sun2) happier.
2019-04-26 20:41:10 +00:00
maya d7ada1c9e8 -frounding-math is gcc specific, help clang builds 2019-04-26 19:17:05 +00:00
maya ff9d8a09c1 Add a test case for signbit.
(paranoia prior to a libm change)
2019-04-26 08:52:16 +00:00
blymn e05fb203f8 Fix argument parsing for mvinsch, last arg is a chtype not a string. 2019-04-26 02:46:00 +00:00
maya e262cfe2be Expand to cover long double somewhat.
The given data is for double, so use DBL_EPSILON and don't expect better
results.
2019-04-25 22:58:23 +00:00
kamil aed5e5582f Fix typo in 'exceptions' 2019-04-25 20:48:54 +00:00
kamil 14fc6dc308 Fix typo 2019-04-25 19:37:09 +00:00
kamil 5e8f5be0b4 Introduce check for the support of FPU exceptions
If FPU exceptions are unsupported, skip the SIGFPE crash tests.

Reuse code from tests/kernel/h_segv.c
2019-04-25 19:15:23 +00:00
kamil 977be96776 Do not allow 0 as ILL si_code as it's reserved for SI_USER 2019-04-25 11:47:59 +00:00
kamil 623b6fd526 In ATF t_ptrace_wait* SIGILL tests allow any si_code
These codes are not portable between CPUs and kernels.

Change the checks to return any valid si_code in the defined range of ILL
values.

PR port-sparc/54140 by Andreas Gustafsson
2019-04-25 11:45:12 +00:00
christos 4899735091 PR/54000: Andreag Gustafsson: Compile the rounding test with
-fround-math since with gcc-7, the default mode ignores fenv settings
(the same effect can be achieved with -O0 :-)

https://gcc.gnu.org/wiki/FloatingPointMath
2019-04-24 15:12:09 +00:00
kamil a9ca1710c0 Add a complete C11 threads(3) implementation
C11 Thread support library is a portable threading C API between OSs,
similar to std::threads in the C++ world.

The library is implemented as a thin shim over POSIX interfaces.

NetBSD implements the API as a part of the POSIX threading library
(libpthread(3)).

C11 threads(3) are in the process of making them an integral part
of the POSIX standard. The interface has been implemented in major
OSs and used with stopgap libraries for older versions of them.

C11 threading library is already used (with a stopgap implementation)
in the NetBSD distribution in MESA.

Original implementation by myself from 2016.

ATF tests are new and cover almost all interfaces.

Proposed on tech-userlevel@.
2019-04-24 11:43:19 +00:00
maya f93d65267a wether -> whether 2019-04-21 11:45:08 +00:00
kamil ec2b73a402 Fix typo in TEST_VFORK_ENABLED
This allows building and running vfork(2) test scenarios correctly.
2019-04-19 21:54:32 +00:00
ozaki-r 8a507e3468 tests: dump kernel stats on cleanup 2019-04-18 07:56:54 +00:00
ozaki-r 7a4fe7b5fc tests: make utility funtions easy to use for tests that don't use the framework 2019-04-18 07:56:04 +00:00
kamil 828333c1da Fix Clang/LLVM build in t_ptrace_wait.c
Do not compile functions that might be unused.
2019-04-17 15:54:55 +00:00
christos 6851d4c465 Re-arrange the ufetchstore tests to look like the other ones. 2019-04-15 23:41:23 +00:00
christos cd89a430c2 fix TESTSDIR.
http://releng.netbsd.org/builds/HEAD/201904150550Z/evbarm-earm.build.failed
2019-04-15 20:21:35 +00:00
kamil 49f0c7e644 Temporarily ifdef out PTRACE_VFORK and PTRACE_VFORKDONE tests
It's not reliable on all ports. sparc and evbarm are known to hang.

PR kern/54111 by Martin Husemann
2019-04-15 16:47:47 +00:00
christos f2519f7f77 ifix uninialized pid 2019-04-14 01:45:30 +00:00
kamil 512ebd326d Add new tests in ATF t_prace_wait*
New tests:

 - traceme_vfork_fork
 - traceme_vfork_vfork

New tests assert that fork/vfork in vforked traced does not emit any
events.
2019-04-11 23:23:53 +00:00
kamil a27f299eb9 Add new tests traceme_vfork_clone* in ATF t_ptrace_wait*
Added tests:

 - traceme_vfork_clone
 - traceme_vfork_clone_vm
 - traceme_vfork_clone_fs
 - traceme_vfork_clone_files
 - traceme_vfork_clone_sighand
 - traceme_vfork_clone_vfork

All tests pass. Validate that children do not trigger any signals and dead
locks when traced by a vfork(2)ed parent.
2019-04-11 23:00:01 +00:00
kamil 3651177b82 Add clone_func() in t_ptrace_wait.h 2019-04-11 20:20:54 +00:00
kamil e7d8414a5b Validate that clone(2) is handled properly with more ptrace(2) ATF tests
New tests:

 - clone[1-8]
 - clone_vm[1-8]
 - clone_fs[1-8]
 - clone_files[1-8]
 - clone_sighand[1-8] // disabled temporarily
 - clone_vfork[1-8]

Assert that appropriate events are triggered for the combination of:

 - PTRACE_FORK
 - PTRACE_VFORK
 - PTRACE_VFORK_DONE
2019-04-11 19:25:31 +00:00
kre 265b061776 PR bin/54112
Fix handling of "$@" (that is, double quoted dollar at), when it
appears in a string which will be subject to field splitting.

Eg:
	${0+"$@" }

More common usages, like the simple "$@" or ${0+"$@"} end up
being entirely quoted, so no field splitting happens, and the
problem was avoided.

See the PR for more details.

This ends up making a bunch of old hack code (and some that was
relatively new) vanish - for now it is just #if 0'd or commented out.
Cleanups of that stuff will happen later.

That some of the worst $@ hacks are now gone does not mean that processing
of "$@" does not retain a very special place in every hackers heart.
RIP extreme ugliness - long live the merely ordinary ugly.

Added a new bin/sh ATF test case to verify that all this remains fixed.
2019-04-10 08:13:11 +00:00
kre 49b4b2e530 Fix quoting (quotes really do not nest...) and remove a bunch of it
that is harmless, but also pointless (in sh, quotes do not make strings,
everything is a string, rather they hide characters which would have
some other meaning unquoted (like spaces) - quotes are not needed around
strings like "descr" so remove them...

Be more consistent with line wrap style, try to avoid wrapping in the
middle of a (sh) word where possible.   Avoid \ use when it is not needed.

Un-KNF (C style) - sh has no declarations, there is no need to leave
blank lines at the head of a function to mark the end of the declarations.

This should be a NFC - but the quoting really was broken before, just
was probably harmless breakage.
2019-04-10 06:13:21 +00:00
kre c2cf8ad6d4 PR bin/53999 from rudolf (eq.cz)
Fix cgdconfig to report verification failures with gpt and mbr
verification methods (and not treat them as silent hard errors).
This also causes the cgd to be unconfigured when one of those
verification methods fails.

Add ATF tests to check that bad verification is reported, and
does not leave the cgd configured.

Patches from the PR applied.
2019-04-10 06:09:39 +00:00
thorpej c3061c7058 Add a test to make sure an overflowing-into-kernel-space fetch/store near
vm_max_address fails with EFAULT.
2019-04-07 15:50:12 +00:00
rin 398d80afc5 Revert previous. arc port was fixed correctly. 2019-04-07 03:43:55 +00:00
rin d45215e83b Avoid redefining UADDR for arc. 2019-04-07 03:35:25 +00:00
kamil 115bc67048 Add new tests in ATF t_fork/t_vfork
Verify whether nested fork(2)/vfork(2)/clone(2) calls are supported in a
fork(2)ed/vforked(2) child.

The interesting ones are non-forked parent and non-forked child scenarios,
in particular double vfork(2).
2019-04-06 15:41:54 +00:00
kamil c2131c4609 Simplify FORK_TEST in ATF t_ptrace_wait*
Reduce the scope of combinations that were planned to be tested from the
same function body.

NFCI
2019-04-06 15:35:09 +00:00
maya 006c716966 Add missing Makefile.
Grabbed from thorpej's github repository.
XXX not actually built tested...
2019-04-06 11:54:25 +00:00
thorpej 91bfaeb675 Overhaul the API used to fetch and store individual memory cells in
userspace.  The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms.  The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

Also augmement the ucas(9) API, making it consistently available on
all plaforms, supporting uniprocessor and multiprocessor systems, even
those that do not have CAS or LL/SC primitives.

Welcome to NetBSD 8.99.37.
2019-04-06 03:06:23 +00:00
kamil f851b6d6f0 Reenable tests vfork7 and vfork8 in ATF t_ptrace_wait*
These tests used to hang on SMP machines.

For experiment after recent changes reenable the tests.
2019-04-05 23:01:09 +00:00
kamil 29c84c24ec Add __clone(2) tests in t_ptrace_wait*
The __clone(2) API is a variation of fork(2)/vfork(2) operations.

New tests:
 - clone_signalignored
 - clone_signalmasked
 - clone_vm_signalignored
 - clone_vm_signalmasked
 - clone_fs_signalignored
 - clone_fs_signalmasked
 - clone_files_signalignored
 - clone_files_signalmasked
 - clone_vfork_signalignored
 - clone_vfork_signalmasked

All new tests pass.

CLONE_SIGHAND tests are right now disabled as they cannot reuse the shared
signal operations (wait(2)) to wait for a clonee.

Another nit is that wait(2) must be used right now with WALLSIG as for some
reason the default variation doesn't work.
2019-04-05 22:58:53 +00:00
kamil d845d12b1a Upgrade indent(1)
Merge all the changes from the recent FreeBSD HEAD snapshot
into our local copy.

FreeBSD actively maintains this program in their sources and their
repository contains over 100 commits with changes.

Keep the delta between the FreeBSD and NetBSD versions to absolute
minimum, mostly RCS Id and compatiblity fixes.

Major chages in this import:

 - Added an option -ldi<N> to control indentation of local variable names.
 - Added option -P for loading user-provided files as profiles
 - Added -tsn for setting tabsize
 - Rename -nsac/-sac ("space after cast") to -ncs/-cs
 - Added option -fbs Enables (disables) splitting the function declaration and opening brace across two lines.
 - Respect SIMPLE_BACKUP_SUFFIX environment variable in indent(1)
 - Group global option variables into an options structure
 - Use bsearch() for looking up type keywords.
 - Don't produce unneeded space character in function declarators
 - Don't unnecessarily add a blank before a comment ends.
 - Don't ignore newlines after comments that follow braces.

Merge the FreeBSD intend(1) tests with our ATF framework.
All tests pass.

Upgrade prepared by Manikishan Ghantasala.
Final polishing by myself.

Part II, checkin new files.
2019-04-04 15:27:35 +00:00
kamil d6a1bc3f07 Upgrade indent(1)
Merge all the changes from the recent FreeBSD HEAD snapshot
into our local copy.

FreeBSD actively maintains this program in their sources and their
repository contains over 100 commits with changes.

Keep the delta between the FreeBSD and NetBSD versions to absolute
minimum, mostly RCS Id and compatiblity fixes.

Major chages in this import:

 - Added an option -ldi<N> to control indentation of local variable names.
 - Added option -P for loading user-provided files as profiles
 - Added -tsn for setting tabsize
 - Rename -nsac/-sac ("space after cast") to -ncs/-cs
 - Added option -fbs Enables (disables) splitting the function declaration and opening brace across two lines.
 - Respect SIMPLE_BACKUP_SUFFIX environment variable in indent(1)
 - Group global option variables into an options structure
 - Use bsearch() for looking up type keywords.
 - Don't produce unneeded space character in function declarators
 - Don't unnecessarily add a blank before a comment ends.
 - Don't ignore newlines after comments that follow braces.

Merge the FreeBSD intend(1) tests with our ATF framework.
All tests pass.

Upgrade prepared by Manikishan Ghantasala.
Final polishing by myself.
2019-04-04 15:22:13 +00:00
kamil 62c5f415e8 Fix flaky check for the /dev/kcov device in t_kcov
Add a top-level check for the KCOV device, instead of deferring it ot each
thread. The thread-based solution was flaky.

PR kern/54064 by Andreas Gustafsson
2019-04-04 10:53:20 +00:00
kamil 329e37cd13 The *fork*_signalmasked ATF tests no longer fail
Add a fixup for signalmasking in the vforkdone_singalmasked test.
2019-04-03 08:19:46 +00:00
kamil d4a71dbeee Add new ATF ptrace(2) tests bytes_transfer_alignment*
Verify bytes transfer for potentially misaligned operation.

New tests:

 - bytes_transfer_alignment_pt_read_i
 - bytes_transfer_alignment_pt_read_d
 - bytes_transfer_alignment_pt_write_i
 - bytes_transfer_alignment_pt_write_d
 - bytes_transfer_alignment_piod_read_i
 - bytes_transfer_alignment_piod_read_d
 - bytes_transfer_alignment_piod_write_i
 - bytes_transfer_alignment_piod_write_d
 - bytes_transfer_alignment_piod_read_auxv

All tests pass (at least on x86_64).
2019-03-28 08:13:40 +00:00
gson 462b0659d5 Timeout for evp test case is still not enough for qemu/sparc 2019-03-27 21:14:54 +00:00
htodd 2603483ecd Fix build break due to typos. 2019-03-22 01:50:14 +00:00
maxv e8b93c6953 Make it possible for an emulator to set the protection of the guest pages.
For some reason I had initially concluded that it wasn't doable; verily it
is, so let's do it.

The reserved 'flags' argument of nvmm_gpa_map() becomes 'prot' and takes
mmap-like protection codes.
2019-03-21 20:21:40 +00:00
maxv db0dfdd0c2 Add CVS ids, and rename the PTE bits. No functional change. 2019-03-19 19:23:39 +00:00
christos 5686c770fd PR/54061: Bump memory for jemalloc (a lot). 2019-03-16 21:57:15 +00:00
christos 97775c96b8 PR/54062: Using random garbage in the mmsghdr (in this case 0xa5's from
jemalloc debug) makes the syscall unhappy. Zero out the memory instead...
2019-03-16 21:46:43 +00:00
kre e5eb671065 Add a bunch of fprintf(stderr,...) diagnostics to try and help determine
what is going wrong which is causing this test to crash the kernel.
2019-03-13 08:50:12 +00:00
kre 03996e069a Explicitly test for PR lib/54053
A suitable test was actually there already - but the results
were not verified.   So just add a test that the result string
is what is expected.  (Previously for len==128 and bytes==10000
it would  have returned "0E" now it returns 10000 as it should.)
2019-03-11 17:45:12 +00:00
kamil b8c8c51cf8 Introduce enhancements to the kcov(4) code
Add new tests verifying dup2(2) scenarios:
 - kcov_dup2
 - kcov_basic_dup2_pc
 - kcov_basic_dup2_cmp

The dup2(2) trick is used by syzkaller and assert that it works.
All new tests pass.

While there add minor non-functional cleanup changes.
2019-03-10 22:34:14 +00:00
kamil f43e07b7f7 Add support for trace type selection in kcov(4)
Allow to specify mode in KCOV_IOC_ENABLE synchronizing the functionality
with Linux, FreeBSD and OpenBSD. As a NetBSD (and OpenBSD) specific of
the ioctl(2) interface, the mode argument has to be specified as &value
rather than value.

There are 3 modes available:
 1. KCOV_MODE_NONE       -- no trace specified, useful for testing purposes
 2. KCOV_MODE_TRACE_PC   -- trace the kernel program counter
 3. KCOV_MODE_TRACE_CMP  -- trace comparison instructions and switch statements

Adapt the ATF tests and documentation for new API.

The KCOV_MODE_TRACE_CMP mode is implemented but still awaits for the
GCC 8.x upgrade or selection of Clang/LLVM as the kernel compiler.

Obtained from OpenBSD and adapted for NetBSD by myself.
2019-03-10 17:51:00 +00:00
kamil 923f374452 Fix bug in kcov_multiple_threads in t_kcov
Spawn the expected number of threads rather than hardcoding one value for
all tests.
2019-03-10 13:24:50 +00:00
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