Commit Graph

71 Commits

Author SHA1 Message Date
christos ca7e4587fd KMODULEDIR is no longer absolute (${DESTDIR} is added to it by the system
makefile because we need to install the module in two places the debug part
and the regular part)
2020-05-01 22:24:18 +00:00
maxv 4cc4c6ebbe Split in sub-tests for clarity, and add a new test, marked as expected
failure for now.
2020-04-26 11:56:38 +00:00
maxv e497fc86e6 Add tests on the x86 PTEs. We scan the MMU page tables directly and verify
certain properties.
2020-04-26 09:08:40 +00:00
christos 0dc8cda9a3 Centralize the base rump libraries into a variable used by all the other
Makefiles so that we can make changes to it centrally as needed and have
less mess. Fixes the sun2 build that needs rumpvfs after librump after
the latest changes.
2020-03-01 18:08:12 +00:00
pgoyette ea561c44e3 Update the t_modctl test to ensure that static evcnts are added.
While here, remove the explicit call to sysctl_setup() routine,
since the module infrastructure already invokes such routines
automatically.
2020-02-22 19:54:34 +00:00
kamil 93226e2fbb Avoid undefined behavior in get_modstat_info
t_modctl.c:114:16, member access within misaligned address 0x71bf5bcede84
for type 'struct modstat_t'

t_modctl.c:116:13, load of misaligned address 0x7e81bc3c9104 for type
'struct modstat_t' which requires 8 byte alignment
2020-02-22 00:24:15 +00:00
kamil b216505454 Avoid undefined behavior in disabledstat
t_builtin.c:174:16, member access within misaligned address 0x741271c25004
for type 'struct modstat_t'

t_builtin.c:175:4, member access within misaligned address 0x741271c251c4
for type 'struct modstat_t'
2020-02-22 00:18:55 +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
maya f93d65267a wether -> whether 2019-04-21 11:45:08 +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
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
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 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 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 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 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
pgoyette d91f98a871 Merge the [pgoyette-compat] branch 2019-01-27 02:08:33 +00:00
christos 76d3dd6b3e PR/53908: Alex Raschi: One more file needs to move. 2019-01-25 18:34:45 +00:00
christos 78928445f5 PR/53908: Alex Raschi: Test that require modules belong in modules; move the
threadpool test from kernel to modules.
2019-01-25 18:33:58 +00:00
martin ddaa1d089b Skip the test on non-modular kernels 2018-01-09 15:16:02 +00:00
martin edea8a3220 PR 52864: add a test for this bug, from sevan@ 2018-01-08 14:17:15 +00:00
christos c54cb81102 Don't play with "../.." in includes for h_macros.h; deal with it centrally.
Minor fixes.
2017-01-13 21:30:39 +00:00
christos ffeb8dbf4e Define _KERNTYPES for things that need it. 2016-01-23 21:22:45 +00:00
he f693807fd8 Fix static linking for the tests: -lrump is also used by -lrumpuser,
so we also need -lrump after -lrumpuser.  Fixes build for sun2.
2014-06-10 04:28:39 +00:00
martin d0ba1a0677 Fix stupid thinko when checking for the availability of options MODULAR
and permission to load modules.
2012-08-20 08:07:52 +00:00
martin f3b7cec914 Be more verbose if we get unexpected error codes from modctl. 2012-08-19 20:54:56 +00:00
martin 66c66d2d86 Make use of the new MODCTL_EXISTS check to query kernel wether (and why
not) we can load modules.
2012-08-13 08:07:03 +00:00
dsl 9ba407934a Fix build - delete extra & 2012-06-03 10:59:44 +00:00
jruoho 84c32e5f2a For now, skip module tests if modctl(8) fails either with EPERM or ENOSYS. 2012-04-20 05:41:25 +00:00
martin ca7d70aa58 While we need an absolute path when loading a module (including the .kmod
extension), we want the shortname w/o extension for the unload.
2012-04-17 21:39:19 +00:00
jruoho ce711fc79d Avoid zero-length format string. 2012-04-17 06:23:52 +00:00
jruoho 681aa38aee Adjust. 2012-04-17 05:18:54 +00:00
pgoyette d2616fb0aa The k_helper3 program does not need to be (and shouldn't be) installed
in its own subdirectory.
2012-04-14 02:46:17 +00:00
pgoyette 84c6871a07 Let's get it right this time. 2012-04-13 15:02:37 +00:00
pgoyette bfea36353b Put k_helper3 in the correct location. 2012-04-13 14:54:39 +00:00
jruoho e49dc377ca Add a helper program that loads a module and returns the errno from modctl(8).
XXX: As noted on tech-kern@, the syscall should be modified to fail
     consistently with a given predefined errno on non-MODULAR kernels.
2012-04-13 07:05:32 +00:00
jruoho a4f8c0aaa1 Skip Xen. XXX: There should be a reliable way to detect MODULAR. 2012-03-20 05:50:11 +00:00
joerg 66dd2755f5 Add __printflike attribution to use vprintf and friends with an argument
as format string.
2012-03-15 02:02:20 +00:00
jruoho 96d2b606cc A modctl(MODCTL_STAT, ...) always succeeds, even in non-modular kernels such
as Xen domUs. Thus, refactor the code to detect non-modular kernels; when the
other operations (MODCTL_LOAD or MODCTL_UNLOAD) fail specifically with ENOSYS,
this is taken as a hint about non-modularity and the test is skipped.
2012-03-13 05:56:46 +00:00
jruoho 21ea49cf59 Skip the tests even if modctl(2) does not fail specifically with ENOSYS. 2012-03-11 19:33:17 +00:00
jmmv 1cf12d0216 Add a test to ensure that PAGE_SIZE is available in kernel modules.
This test reproduces the error condition in PR port-macppc/46041 and
therefore it is an xfail in this particular platform.
2012-02-17 22:36:50 +00:00