Commit Graph

734 Commits

Author SHA1 Message Date
Alan Somers
71885041ce fuse(4): add tests for ENOSYS special cases
PR:		236557
Sponsored by:	The FreeBSD Foundation
2019-03-15 18:06:51 +00:00
Alan Somers
9038479127 fuse(4): combine common code in the tests
Sponsored by:	The FreeBSD Foundation
2019-03-15 17:04:33 +00:00
Alan Somers
9ae9282e95 fuse(4): add some miscellaneous test cases that I had overlooked
* Test that FUSE_FLUSH and FUSE_RELEASE release POSIX file locks
* Test that FUSE_SETATTR's attr caching feature works
* Fix some minor mistakes in the posix file lock tests

Sponsored by:	The FreeBSD Foundation
2019-03-15 16:16:50 +00:00
Alan Somers
4da6e8cef1 fuse(4): add tests for FUSE_DESTROY, FUSE_FORGET, and unlinking open files
Sponsored by:	The FreeBSD Foundation
2019-03-15 14:49:27 +00:00
Alan Somers
0b6ee94ad5 fuse(4): add tests for extended attributes
Sponsored by:	The FreeBSD Foundation
2019-03-14 23:05:59 +00:00
Alan Somers
94ef9d62cc fuse(4): add tests for FUSE_INTERRUPT
This required changing the way that all operations are mocked.  Previously
MockFS::process had one input argument and one output argument.  Now, it
returns a vector of zero or more responses.  This allows tests to simulate
conditions where the filesystem daemon has a queue depth > 1.

PR:		236530
Sponsored by:	The FreeBSD Foundation
2019-03-14 17:20:24 +00:00
Alan Somers
3592c9fe12 fuse(4) tests: minor tweaks
* better debugging for FUSE_SETATTR
* Move a big variable from stack to heap

Sponsored by:	The FreeBSD Foundation
2019-03-14 15:07:46 +00:00
Alan Somers
b6e5e8cf5b fuse(4): skip the Write.append test unless vfs.fuse.sync_resize==0
Sponsored by:	The FreeBSD Foundation
2019-03-14 14:59:59 +00:00
Alan Somers
0e125f5ff8 fuse(4): combine common code in the tests
Combine a bunch of mostly similar expect_* methods into utils.cc, and only
define FH in a single place.

Sponsored by:	The FreeBSD Foundation
2019-03-14 00:12:59 +00:00
Alan Somers
ef61047a9b fuse(4): add tests for POSIX file locking operations
PR:		234581
Sponsored by:	The FreeBSD Foundation
2019-03-13 22:16:00 +00:00
Alan Somers
1bb6c55076 fues(4): add tests for FUSE_RELEASEDIR
Sponsored by:	The FreeBSD Foundation
2019-03-13 13:41:05 +00:00
Alan Somers
0f10547be1 fuse(4): add tests for opendir and readdir
Sponsored by:	The FreeBSD Foundation
2019-03-12 22:25:59 +00:00
Alan Somers
4459896e18 fuse(4): add tests for FUSE_OPENDIR, FUSE_FSYNC, and FUSE_FSYNCDIR
And one more for FUSE_WRITE, too.

PR:		236379
PR:		236473
PR:		236474
Sponsored by:	The FreeBSD Foundation
2019-03-11 22:29:56 +00:00
Alan Somers
809a8352dd Drop "All rights reserved" from the files I own
Also, add SPDX tags where needed.

MFC after:	2 weeks
2019-03-11 22:23:56 +00:00
Alan Somers
da1200c90f Update copyright info in fuse tests
* Add SPDX tags
* Remove "All Rights Reserved", with permission of emaste (FBSD Foundation)

Reported by:	emaste
Sponsored by:	The FreeBSD Foundation
2019-03-11 19:10:48 +00:00
Alan Somers
e825cfb775 fuse(4): add tests for FUSE_READ
PR:		236379
PR:		236466
PR:		236472
Sponsored by:	The FreeBSD Foundation
2019-03-11 18:28:20 +00:00
Alan Somers
e071c64b4c fuse(4): Add some tests for FUSE_FLUSH
PR:		236405
Sponsored by:	The FreeBSD Foundation
2019-03-08 23:07:51 +00:00
Alan Somers
1d882fd6a1 fuse(4): add tests for FUSE_WRITE and FUSE_RELEASE
And a few definitions needed for upcoming FUSE_READ tests

Sponsored by:	The FreeBSD Foundation
2019-03-08 19:01:31 +00:00
Alan Somers
c2e7dba7f8 fuse(4): add tests relating to open(2) flags
Sponsored by:	The FreeBSD Foundation
2019-03-07 18:12:34 +00:00
Kristof Provost
16b56c7f4e pf tests: Accelerate tests
Make the tests run slightly faster by having pft_ping.py end the capture
of packets as soon as it sees the expected packet, rather than
continuing to sniff.

MFC after:	2 weeks
2019-03-07 11:09:29 +00:00
John Baldwin
2e43efd0bb Drop "All rights reserved" from my copyright statements.
Reviewed by:	rgrimes
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D19485
2019-03-06 22:11:45 +00:00
Alan Somers
c7c8f59051 fuse(4): add tests for unlink, rmdir, and statfs
Also, combine some common code for sending cacheable negative lookup
responses.

Sponsored by:	The FreeBSD Foundation
2019-03-06 00:38:10 +00:00
Alan Somers
9b4318e553 fuse(4): add test cases for FUSE_LINK and FUSE_RENAME
Also, add a FUSE_LOOKUP test case for subdirectories, and improve debugging
output.

Sponsored by:	The FreeBSD Foundation
2019-03-05 21:40:08 +00:00
Alan Somers
50deb1a8c2 fuse(4): add tests for FUSE_MKDIR and FUSE_ACCESS
PR:		236291
PR:		236231
Sponsored by:	The FreeBSD Foundation
2019-03-05 18:53:28 +00:00
Kristof Provost
3846e5755f tun tests: Test renaming and destroying a tun interface in a vnet jail
There was a problem destroying renamed tun interfaces in vnet jails. This was
fixed in r344794. Test the previously failing scenario.

PR:		235704
MFC after:	2 weeks
2019-03-05 15:49:30 +00:00
Alan Somers
76effb87dc fuse(4): combine some common code in the tests
Sponsored by:	The FreeBSD Foundation
2019-03-05 03:27:32 +00:00
Alan Somers
4cbb4f8886 fuse(4): add tests related to FUSE_MKNOD
PR:		236236
Sponsored by:	The FreeBSD Foundation
2019-03-05 00:27:54 +00:00
Alan Somers
99fe8368c2 fuse(4): add tests for CREATE, OPEN, READLINK, SETATTR and SYMLINK
The new SETATTR tests deal with already-open files.

PR:		235775
PR:		236231
Sponsored by:	The FreeBSD Foundation
2019-03-04 22:07:33 +00:00
Alan Somers
2343311052 fuse(4): fix the entry_cache_negative_timeout test
I committed too soon in r344775; the test actually passes when I write it
correctly.

PR:		236226
Sponsored by:	The FreeBSD Foundation
2019-03-04 22:03:09 +00:00
Alan Somers
56f07a9855 fuse(4): add tests for negative lookups
PR:		236226
Sponsored by:	The FreeBSD Foundation
2019-03-04 19:10:22 +00:00
Kristof Provost
06aac31aec tests: Move common (vnet) test functions into a common file
The netipsec and pf tests have a number of common test functions. These
used to be duplicated, but it makes more sense for them to re-use the
common functions.

PR:		236223
2019-03-04 18:15:06 +00:00
Alan Somers
8eeb82e169 fuse(4) use a global environment check.
This is marginally faster than using an environment check in each test case.
Also, if the global check fails then all of the tests are skipped.  Oddly,
it's not possible to skip a test in any other way.

Also, allow the test to run as a normal user if vfs.usermount=1 and
/dev/fuse is accessible.

Reported by:	ngie
Sponsored by:	The FreeBSD Foundation
2019-03-02 16:28:29 +00:00
Alan Somers
7716c35f77 Add some fuse(4) tests for FUSE_SETATTR
Sponsored by:	The FreeBSD Foundation
2019-03-02 15:32:20 +00:00
Kristof Provost
bd0eb4dcc4 pf tests: Test for nested inline anchor issue
PR:		196314
MFC after:	1 week
2019-03-02 12:30:59 +00:00
Alan Somers
44154e682a Begin a fuse(4) test suite
It only tests the kernel portion of fuse, not the userspace portion (which
comes from sysutils/fusefs-libs).  The kernel-userspace interface is
de-facto standardized, and this test suite seeks to validate FreeBSD's
implementation.

It uses GoogleMock to substitute for a userspace daemon and validate the
kernel's behavior in response to filesystem access.  GoogleMock is
convenient because it can validate the order, number, and arguments of each
operation, and return canned responses.

But that also means that the test suite must use GoogleTest, since
GoogleMock is incompatible with atf-c++ and atf.test.mk does not allow C++
programs to use atf-c.

This commit adds the first 10 test cases out of an estimated 130 total.

PR:		235775, 235773
Sponsored by:	The FreeBSD Foundation
2019-03-01 23:53:05 +00:00
Kristof Provost
15426769bb pf tests: Test CVE-2019-5597
Generate a fragmented packet with different header chains, to provoke
the incorrect behaviour of pf.
Without the fix this will trigger a panic.

Obtained from:	Corentin Bayet, Nicolas Collignon, Luca Moro at Synacktiv
2019-03-01 07:39:55 +00:00
Andrew Turner
bdffe3b5bf Allow the kcov buffer to be mmaped multiple times.
After r344391 this restriction is no longer needed.

Sponsored by:	DARPA, AFRL
2019-02-21 10:11:15 +00:00
Andrew Turner
bd52577899 Use KCOV_ENTRY_SIZE for the entry size.
Previously it was sizeof(uint64_t). While this is currently true, it may
not be on all future architectures.

Sponsored by:	DARPA, AFRL
2019-02-21 09:43:14 +00:00
Kristof Provost
fe5a065d4b pf tests: Check size validation in DIOCGETSRCNODES
Ensure that invalid sizes for DIOCGETSRCNODES do not cause panics.

MFC after:	 1 week
2019-01-22 02:56:36 +00:00
Kristof Provost
b9dee1ff02 pf tests: Test PR 229241
pfctl has an issue with 'set skip on <group>', which causes inconsistent
behaviour: the set skip directive works initially, but does not take
effect when the same rules are re-applied.

PR:		229241
MFC after:	1 week
2019-01-13 05:31:53 +00:00
Andrew Turner
c1bc2f7a02 Temporarily disable the kcov tests. Not all architectures have
atomic_store_64 and atomic_store_64.

Sponsored by:	DARPA, AFRL
2019-01-12 11:50:39 +00:00
Andrew Turner
b3c0d957a2 Add support for the Clang Coverage Sanitizer in the kernel (KCOV).
When building with KCOV enabled the compiler will insert function calls
to probes allowing us to trace the execution of the kernel from userspace.
These probes are on function entry (trace-pc) and on comparison operations
(trace-cmp).

Userspace can enable the use of these probes on a single kernel thread with
an ioctl interface. It can allocate space for the probe with KIOSETBUFSIZE,
then mmap the allocated buffer and enable tracing with KIOENABLE, with the
trace mode being passed in as the int argument. When complete KIODISABLE
is used to disable tracing.

The first item in the buffer is the number of trace event that have
happened. Userspace can write 0 to this to reset the tracing, and is
expected to do so on first use.

The format of the buffer depends on the trace mode. When in PC tracing just
the return address of the probe is stored. Under comparison tracing the
comparison type, the two arguments, and the return address are traced. The
former method uses on entry per trace event, while the later uses 4. As
such they are incompatible so only a single mode may be enabled.

KCOV is expected to help fuzzing the kernel, and while in development has
already found a number of issues. It is required for the syzkaller system
call fuzzer [1]. Other kernel fuzzers could also make use of it, either
with the current interface, or by extending it with new modes.

A man page is currently being worked on and is expected to be committed
soon, however having the code in the kernel now is useful for other
developers to use.

[1] https://github.com/google/syzkaller

Submitted by:	Mitchell Horne <mhorne063@gmail.com> (Earlier version)
Reviewed by:	kib
Testing by:	tuexen
Sponsored by:	DARPA, AFRL
Sponsored by:	The FreeBSD Foundation (Mitchell Horne)
Differential Revision:	https://reviews.freebsd.org/D14599
2019-01-12 11:21:28 +00:00
Vincenzo Maffione
08f34ad9ed netmap: unit tests: fix issues found by coverity scan
Reported by:	asomers
MFC after:	1 week
Sponsored by:	Sunny Valley Networks
2019-01-03 16:47:05 +00:00
Vincenzo Maffione
5854d71854 netmap: fix warnings on unit tests
Fix some printf() format string warnings raised for ctrl-api-test.c
on some architectures.

MFC after:	1 week
Sponsored by:	Sunny Valley Networks
2018-12-31 12:07:17 +00:00
Vincenzo Maffione
2a8682a815 netmap: add suite of unit tests
Import the unit tests from upstream (https://github.com/luigirizzo/netmap
ba02539859d46d33), and make them ready for use with Kyua.
There are currently 38 regression tests, which test the kernel control ABI
exposed by netmap to userspace applications:

  1: test for port info get
  2-5: tests for basic port registration
  6-9: tests for VALE
  10-11: tests for getting netmap allocator info
  12-15: tests for netmap pipes
  16: test on polling mode
  17-18: tests on options
  19-27: tests for sync-kloop subsystem
  28-39: tests for null ports
  31-38: tests for the legacy NIOCREGIF registers

Reviewed by:	ngie
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D18490
2018-12-31 11:17:58 +00:00
Alan Somers
b1ce931bd8 Conditionalize installtion audit(4) tests on MK_AUDIT
MK_AUDIT already controls auditd(8), praudit(1), etc.  It should also control
the audit test suite.

Submitted by:	ngie
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd/pull/240
2018-12-17 18:35:32 +00:00
Alan Somers
7fe3fd48a5 audit(4) tests: require /etc/rc.d/auditd
These tests should be skipped if /etc/rc.d/auditd is missing, which could be
the case if world was built with WITHOUT_AUDIT set.  Also, one test case
requires /etc/rc.d/accounting.

Submitted by:	ngie
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd/pull/240
2018-12-17 18:11:06 +00:00
Kristof Provost
ff514f1f8a pf tests: Basic rdr test
MFC after:	2 weeks
2018-12-12 20:19:56 +00:00
Kristof Provost
9bfe20461c pf tests: NAT exhaustion test
It's been reported that pf doesn't handle running out of available ports
for NAT correctly. It freezes until a state expires and it can find a
free port.
Test for this, by setting up a situation where only two ports are
available for NAT and then attempting to create three connections.

If successful the third connection will fail immediately. In an
incorrect case the connection attempt will freeze, also freezing all
interaction with pf through pfctl and trigger timeout.

PR:		233867
MFC after:	2 weeks
2018-12-12 20:19:18 +00:00
Kristof Provost
d3cc40300e pf tests: Use the ATF cleanup infrastructure in the ioctl tests
Use ATF_TC_CLEANUP(), because that means the cleanup code will get
called even if a test fails. Before it would only be executed if every
test within the body succeeded.

Reported by:	Marie Helene Kvello-Aune <marieheleneka@gmail.com>
MFC after:	2 weeks
2018-12-11 21:49:13 +00:00
Kristof Provost
87c7063c2b pf tests: ioctl tests require root rights
Explicitly mark these tests as requiring root rights. We need to be able
to open /dev/pf.

Reported by:	Marie Helene Kvello-Aune <marieheleneka@gmail.com>
MFC after:	2 weeks
2018-12-11 21:45:56 +00:00
John Baldwin
c5786670ac Don't report stale signal information for non-signal events in ptrace_lwpinfo.
Once a signal's siginfo was copied to 'td_si' as part of the signal
exchange in issignal(), it was never cleared.  This caused future
thread events that are reported as SIGTRAP events without signal
information to report the stale siginfo in 'td_si'.  For example, if a
debugger created a new process and used SIGSTOP to stop it after
PT_ATTACH, future system call entry / exit events would set PL_FLAG_SI
with the SIGSTOP siginfo in pl_siginfo.  This broke 'catch syscall' in
current versions of gdb as it assumed PL_FLAG_SI with SIGTRAP
indicates a breakpoint or single step trap.

Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D18487
2018-12-10 19:39:24 +00:00
Conrad Meyer
af7dcae0e2 gmirror: Evaluate mirror components against newest metadata copy
Re-apply r341665 with format strings fixed.

If we happen to taste a stale mirror component first, don't reject valid,
newer components that have differing metadata from the stale component
(during STARTING).  Instead, update our view of the most recent metadata as
we taste components.

Like mediasize beforehand, remove some checks from g_mirror_check_metadata
which would evict valid components due to metadata that can change over a
mirror's lifetime.  g_mirror_check_metadata is invoked long before we check
genid/syncid and decide which component(s) are newest and whether or not we
have quorum.

Before checking if we can enter RUNNING (i.e., we have quorum) after a NEW
component is added, first remove any known stale or inconsistent disks from
the mirrorset, rather than removing them *after* deciding we have quorum.
Check if we have quorum after removing these components.

Additionally, add a knob, kern.geom.mirror.launch_mirror_before_timeout, to
force gmirrors to wait out the full timeout (kern.geom.mirror.timeout)
before transitioning from STARTING to RUNNING.  This is a kludge to help
ensure all eligible, boot-time available mirror components are tasted before
RUNNING a gmirror.

Add a basic test case for STARTING -> RUNNING startup behavior around stale
genids.

PR:		232671, 232835
Submitted by:	Cindy Yang <cyang AT isilon.com> (previous version)
Reviewed by:	markj (kernel portions)
Discussed with:	asomers, Cindy Yang
Tested by:	pho
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D18062
2018-12-07 02:44:04 +00:00
Conrad Meyer
c4e87bdfc1 Revert r341665 due to tinderbox breakage
I didn't notice that some format strings were non-portable.  Will fix and
re-commit later.
2018-12-07 00:47:05 +00:00
Alan Somers
a9ebbf33ea geom tests: Fix cleanup of ATF tests since r341392
r341392 changed common test cleanup routines in a way that allowed them to
be used by TAP tests as well as ATF tests.  However, a late change made
during code review resulted in cleanup being broken for ATF tests, which
source geom_subr.sh separately during the body and cleanup phases of the
test.  The result was that md(4) devices wouldn't get cleaned up.

MFC after:	2 weeks
X-MFC-With:	341392
2018-12-07 00:27:38 +00:00
Conrad Meyer
bc1ee0be2d gmirror: Evaluate mirror components against newest metadata copy
If we happen to taste a stale mirror component first, don't reject valid,
newer components that have differing metadata from the stale component
(during STARTING).  Instead, update our view of the most recent metadata as
we taste components.

Like mediasize beforehand, remove some checks from g_mirror_check_metadata
which would evict valid components due to metadata that can change over a
mirror's lifetime.  g_mirror_check_metadata is invoked long before we check
genid/syncid and decide which component(s) are newest and whether or not we
have quorum.

Before checking if we can enter RUNNING (i.e., we have quorum) after a NEW
component is added, first remove any known stale or inconsistent disks from
the mirrorset, rather than removing them *after* deciding we have quorum.
Check if we have quorum after removing these components.

Additionally, add a knob, kern.geom.mirror.launch_mirror_before_timeout, to
force gmirrors to wait out the full timeout (kern.geom.mirror.timeout)
before transitioning from STARTING to RUNNING.  This is a kludge to help
ensure all eligible, boot-time available mirror components are tasted before
RUNNING a gmirror.

When we are instructed to forget mirror components, bump the generation id
to avoid confusion with such stale components later.

Add a basic test case for STARTING -> RUNNING startup behavior around stale
genids.

PR:		232671, 232835
Submitted by:	Cindy Yang <cyang AT isilon.com> (previous version)
Reviewed by:	markj (kernel portions)
Discussed with:	asomers, Cindy Yang
Tested by:	pho
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D18062
2018-12-06 23:55:39 +00:00
Li-Wen Hsu
037479ff5e Temporarily skip flakey test cases
PR:		233586, 233587, 233588
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18362
2018-12-06 09:22:35 +00:00
Kristof Provost
369d9a2c15 pf tests: Add a defer mode test for pfsync
Repeat the pfsync test, this time with the 'defer' option enabled. This
exercises slightly different code paths.
2018-12-05 19:53:09 +00:00
Alan Somers
cf551b8a98 Unbreak geli/gmirror testcases if their geom classes cannot be loaded
The problem with the logic prior to this commit was twofold:

1. The wrong set of idioms (TAP-compatible) were being applied to the ATF
   testcases when run, resulting in confusing ATF failure results on setup.
2. The cleanup subroutines were broken when the geom classes could not be
   loaded as they exited with 0 unexpectedly.

This commit changes the test code to source the class-specific configuration
(conf.sh) once globally, instead of sourcing it per testcase and per cleanup
subroutine, and to call the ATF-specific setup subroutine(s) inline in
the testcases.

The refactoring done is effectively a no-op for the TAP testcases, modulo
any refactoring done to create common code between the ATF and TAP
testcases.

This unbreaks the geli testcases converted to ATF in r327662 and r327683,
and the gmirror testcases added in r327780, respectively, when the geom
class could not be loaded.

tests/sys/geom/class/mirror/...
    While here, ignore errors when turning debug failpoint sysctl off, which
    could occur if the gmirror class was not loaded.

Submitted by:	ngie
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd/pull/241
2018-12-02 05:06:37 +00:00
Alan Somers
b27a4408c2 Remove some dead code from the geli tests
This is detritus in the Makefile, leftover from 327662.

MFC after:	2 weeks
2018-12-02 00:41:43 +00:00
Kristof Provost
df5ceb3b66 pf tests: Test name handling
Provoke a situation where two interfaces have the same name, and verify
pf's reaction to this.
2018-12-01 09:59:32 +00:00
Kristof Provost
db785060cb pf tests: Make pass_block:noalias more robust
Send several ICMPv6 echo requests. We've seen occasional failures with a
single request.
2018-12-01 09:57:29 +00:00
Eric van Gyzen
de7417c40c Maybe make gcc happy
According to Jenkins, the GCC architectures were unhappy because:

    sigaltstack.c:82: warning: missing initializer
    sigaltstack.c:82: warning: (near initialization for 'oss.ss_size')

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2018-11-30 23:47:57 +00:00
Eric van Gyzen
984969cd96 Fix reporting of SS_ONSTACK
Fix reporting of SS_ONSTACK in nested signal delivery when sigaltstack()
is used on some architectures.

Add a unit test for this.  I tested the test by introducing the bug
on amd64.  I did not test it on other architectures.

Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D18347
2018-11-30 22:44:33 +00:00
David Bright
d340488122 Make whitespace more consistent in libkqueue tests.
After r337820, which "corrected" some spaces-instead-of-tab whitespace
issues in the libkqueue tests, jmg@ pointed out that these files were
originally space-based, not tab-spaced, and so the correction should
have been to get rid of the tabs that had been introduced in previous
changes, not the spaces. This change does that. This is a whitespace
only change; no functional change is intended.

Reported by:	jmg@
MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2018-11-27 15:12:34 +00:00
Mark Johnston
9ed1e4ecd4 Plug a trivial memory leak.
CID:		1396911
MFC with:	r340485
2018-11-20 18:13:18 +00:00
Mark Johnston
5211f8dccb Add regression tests for r340313 and r340483.
Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17926
2018-11-16 19:04:12 +00:00
Mark Johnston
634bb9e435 Rename the SO_REUSEPORT_LB test file to be consistent with other tests.
MFC after:	1 week
2018-11-16 18:59:58 +00:00
Li-Wen Hsu
b0e9618e68 Fix test: sys.netpfil.pf.pass_block.noalias
Replace hard-coded epair0b with the variable holds the real epair interface
used for testing.

Reviewed by:	kp
Approved by:	emaste, markj (mentors)
MFC with:	r339836
Sponsored by:	The FreeBSD Foundation
2018-11-09 15:24:24 +00:00
Kristof Provost
55177f18a1 pf tests: Test PR 183198
Create a table which is only used inside an anchor, ensure that the
table exists.

PR:		183198
MFC after:	2 weeks
2018-11-08 21:56:06 +00:00
Kristof Provost
6ab3ac5afa pf tests: Basic pfsync test
Set up two jails, configure pfsync between them and create state in one
of them, verify that this state is copied to the other jail.

MFC after:	2 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D17504
2018-11-02 16:59:55 +00:00
Kristof Provost
71f8908a1a pf tests: Test ':0' ignoring link-local addresses
PR:		201695
2018-10-28 05:37:15 +00:00
Mark Johnston
36847545b5 Add a very basic regression test for setfacl -R with NFSv4 ACLs.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-10-26 21:20:04 +00:00
Mark Johnston
6951c4eebc Update and re-enable ACL tests following r332396 and r339781.
PR:		229930
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-10-26 19:03:30 +00:00
Mark Johnston
ddab8c351a Reparent a child of pdfork(2) to its reaper when the procdesc is closed.
Unconditionally reparenting to PID 1 breaks the procctl(2) reaper
functionality.

Add a regression test for this case.

Reviewed by:	kib
Approved by:	re (gjb)
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17589
2018-10-16 20:06:56 +00:00
Mark Johnston
3f8b4bf28d Add a couple of basic regression tests for SO_REUSEPORT_LB.
Reviewed by:	asomers
Approved by:	re (kib)
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D17110
2018-09-11 21:14:07 +00:00
Alan Somers
e894e376b0 Fix sys/netipsec/tunnel tests after r337736
Originally, these tests accidentally used broadcast addresses when they
should've used unicast addresses.  That the tests passed prior to r337736
was accidental.

Submitted by:	ae
Reviewed by:	olivier
MFC after:	2 weeks
2018-08-17 18:37:22 +00:00
Kristof Provost
2848a0e2da pf tests: Verify that pf limits the number of fragments per packet
Test the limitation on number of frames per packet introduced in pf in r337969.

Sponsored by:	Klara Systems
2018-08-17 15:02:58 +00:00
Conrad Meyer
1e7bbbc54c Add test cases for Poly1305 from RFC 7539 2018-08-17 00:32:00 +00:00
Alan Somers
3c5ba95ad1 Fix sys/opencrypto/blake2_test when kern.cryptodevallowsoft=0
Two of these testcases require software crypto to be enabled. Curiously, it
isn't by default.

PR:		230671
Reported by:	Jenkins
Reviewed by:	cem
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D16755
2018-08-16 23:49:56 +00:00
Alan Somers
88fa3a7649 Revert r337929
FreeBSD's mkstemp sets the temporary file's permissions to 600, and has ever
since mkstemp was added in 1987.  Coverity's warning is still relevant for
portable programs since OpenGroup does not require that behavior, and POSIX
didn't until 2008.  But none of these programs are portable.
2018-08-16 22:04:00 +00:00
Alan Somers
76f2606181 Fix Coverity warnings about mkstemp in tests
umask(2) should always be used prior to mkstemp(3) so the temporary file
won't be created with insecure permissions.

Reported by:	Coverity
CID:		1331605 1347173 1375366 1339800 1331604 1296056 1296060
CID:		1296057 1296062
MFC after:	2 weeks
2018-08-16 21:36:19 +00:00
Alan Somers
670e1da043 Fix the sys/opencrypto/runtests test when aesni(4) is already loaded
Apparently kldstat requires the full module name, including busname

Reported by:	Jenkins
MFC after:	2 weeks
2018-08-16 15:44:48 +00:00
David Bright
4e258e2d9f Fix a couple whitespace errors in r337814.
Reported by:	Renato Botelho <garga.bsd@gmail.com>
MFC after:	3 days
X-MFC-with:	r337814
Sponsored by:	Dell EMC
2018-08-14 20:26:54 +00:00
David Bright
45bed28c11 Fix several (more) memory leaks.
A follow-up to r337812 to catch a couple more memory leaks that should
have been included in that change.

Reported by:	Coverity
CID:		1296064, 1296067 (for real this time)
MFC after:	3 days
X-MFC-with:	r337812
Sponsored by:	Dell EMC
2018-08-14 19:31:06 +00:00
David Bright
53e992cfb9 Fix several memory leaks.
The libkqueue tests have several places that leak memory by using an
idiom like:

puts(kevent_to_str(kevp));

Rework to save the pointer returned from kevent_to_str() and then
free() it after it has been used.

Reported by:	asomers (pointer to Coverity), Coverity
CID:		1296063, 1296064, 1296065, 1296066, 1296067, 1350287, 1394960
Sponsored by:	Dell EMC
2018-08-14 19:12:45 +00:00
Kristof Provost
9317ba2226 pf tests: Basic test for 'set skip in $groupname'
This tests for the problem reported in PR 229241, where using a group
name in 'set skip on' did not work as expected.

Sponsored by:	Essen Hackathon
2018-08-11 16:41:07 +00:00
Mark Johnston
ffb8b43ec2 Update PR 131876 regression tests after r337423.
- Add some more cases to the truncation test.
- Remove the "expect fail" annotations.

PR:		131876
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D16562
2018-08-07 16:39:07 +00:00
Mark Johnston
9f21643182 Fix the regression test for PR 181741.
With r337328, the test hangs becase the sendmsg() call will block until
the receive buffer is at least partially drained.  Fix the problem by
using a non-blocking socket and allowing short writes.  Also assert
that a SCM_CREDS message was received if one was expected.

PR:		181741
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D16516
2018-08-04 20:29:58 +00:00
Ruslan Bukin
7db4981b23 Increase timeout for nop_test:stripesize.
It takes 49s to complete this test in QEMU/RISC-V.

Sponsored by:	DARPA, AFRL
2018-08-03 12:16:02 +00:00
Alan Somers
da4465506d Fix LOCAL_PEERCRED with socketpair(2)
Enable the LOCAL_PEERCRED socket option for unix domain stream sockets
created with socketpair(2). Previously, it only worked with unix domain
stream sockets created with socket(2)/listen(2)/connect(2)/accept(2).

PR:		176419
Reported by:	Nicholas Wilson <nicholas@nicholaswilson.me.uk>
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D16350
2018-08-03 01:37:00 +00:00
Mark Johnston
48729f75e1 Fix some nits in the unix_passfd tests.
- Remove return statements in functions with a void return type.
- Allocate enough space for the SCM_CREDS and SCM_RIGHTS messages
  received in the rights_creds_payload test.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2018-08-01 19:45:04 +00:00
Mark Johnston
9f9dd0523b Add a regression test related to PR 131876.
If an error occurs while copying a SCM_RIGHTS message to userspace,
we free the mbuf containing externalized rights, leaking them.

PR:		131876
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2018-07-31 00:48:08 +00:00
David Bright
d0a179019f Correct possible misleading error message in kqtest.
ian@ pointed out that in the test_abstime() function time(NULL) is
used twice; once in an "if" test and again in the enclosed error
message. If the true branch was taken and the process got preempted
before the second time(NULL) call, by the time the error message was
generated enough time could have elapsed that the message could claim
that the event came "too early" but print an event time that was after
the expected timeout. Correct by making the time(NULL) call only once
and using that returned time in both the "if" test and the error
message.

Reported by:	ian@
MFC after:	4 days
X-MFC-with:	r336761, r336781, r336802
Sponsored by:	Dell EMC
2018-07-30 14:21:49 +00:00
Alan Somers
70eaeb3622 audit(4): add tests for sysctl(3) and sysarch(2)
Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D16116
2018-07-29 20:34:44 +00:00
David Bright
4faa0dc193 Fix compilation error on some arches after r336761 & r336781.
Another cast for printing an intmax_t was needed in a kqueue test for
some arches.

Pointy-hat:	me (twice)
MFC after:	1 week
X-MFC-with:	r336761, r336781
Sponsored by:	Dell EMC
2018-07-28 02:53:36 +00:00
David Bright
b6429f4bff Fix compilation error on some arches after r336761.
A cast for printing an intmax_t was needed in a kqueue test for some
arches.

MFC after:	1 week
X-MFC-with:	r336761
Sponsored by:	Dell EMC
2018-07-27 20:14:58 +00:00
David Bright
95c05062ec Allow a EVFILT_TIMER kevent to be updated.
If a timer is updated (re-added) with a different time period
(specified in the .data field of the kevent), the new time period has
no effect; the timer will not expire until the original time has
elapsed. This violates the documented behavior as the kqueue(2) man
page says (in part) "Re-adding an existing event will modify the
parameters of the original event, and not result in a duplicate
entry."

This modification, adapted from a patch submitted by cem@ to PR214987,
fixes the kqueue system to allow updating a timer entry. The
kevent timer behavior is changed to:

  * When a timer is re-added, update the timer parameters to and
    re-start the timer using the new parameters.
  * Allow updating both active and already expired timers.
  * When the timer has already expired, dequeue any undelivered events
    and clear the count of expirations.

All of these changes address the original PR and also bring the
FreeBSD and macOS kevent timer behaviors into agreement.

A few other changes were made along the way:

  * Update the kqueue(2) man page to reflect the new timer behavior.
  * Fix man page style issues in kqueue(2) diagnosed by igor.
  * Update the timer libkqueue system test to test for the updated
    timer behavior.
  * Fix the (test) libkqueue common.h file so that it includes
    config.h which defines various HAVE_* feature defines, before the
    #if tests for such variables in common.h. This enables the use of
    the actual err(3) family of functions.
  * Fix the usages of the err(3) functions in the tests for incorrect
    type of variables. Those were formerly undiagnosed due to the
    disablement of the err(3) functions (see previous bullet point).

PR:		214987
Reported by:	Brian Wellington <bwelling@xbill.org>
Reviewed by:	kib
MFC after:	1 week
Relnotes:	yes
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D15778
2018-07-27 13:49:17 +00:00
Alan Somers
3468bf40ce Introduce test program for auditpipe(4)
Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D16395
2018-07-26 00:16:41 +00:00
Alan Somers
75b9becc2c Temporarily disable the sys/acl/00 and sys/acl/02 tests
These tests are failing due to PR 229930.  Unfortunately, TAP tests can't be
marked as expected failures.

PR:		229930
Reported by:	Jenkins
2018-07-22 21:00:11 +00:00
Mark Johnston
6984a7b8bb Add a regression test for PR 131876.
PR:		131876
MFC after:	1 week
2018-07-22 18:07:08 +00:00
Alan Somers
12395dc9f6 Fix audit of chflagsat, lgetfh, and setfib
These syscalls were always supposed to have been auditted, but due to
oversights never were.

PR:		228374
Reported by:	aniketp
Reviewed by:	aniketp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D16388
2018-07-22 14:11:52 +00:00
Alan Somers
8cadd66d98 Fix sys.fs.tmpfs.mknod_test.{char, block} by reverting r321967
In r321967 ngie "fixed" these tests by changing their expectations to match
the device numbers produced by the new ino64 code.  But it wasn't the tests
that were broken, it was the kernel.  bde fixed the kernel in r335053.

Reported by:	Jenkins
MFC after:	Never (only applies to >= 12)
2018-07-21 20:14:01 +00:00
Alan Somers
85e089fe36 Clear expected failures for aesni_aes_gcm tests
These tests were fixed by r335584

PR:		228094
PR:		201447
MFC after:	2 weeks
X-MFC-With:	335584
2018-07-21 19:28:07 +00:00
Alan Somers
55cd452396 audit(4): add test cases for chflagsat(2), lgetfh(2), setfib(2)
These three syscalls aren't currently audited correctly, so the tests are
marked as expected failures.

PR:		228374
Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D16379
2018-07-21 16:34:38 +00:00
Alan Somers
0f1d973c8e audit(4): add more test cases for auditon(2)
auditon(2) is an ioctl-like syscall with several different variants, each of
which has a distinct audit event.  This commit tests the remaining variants
that weren't tested in r336564.

Submitted by:	aniketp
MFC after:	2 weeks
X-MFC-With:	336564
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D16381
2018-07-21 16:26:00 +00:00
Alan Somers
19fa6fe642 Separate the audit(4) tests for auditon(2)'s individual commands
auditon(2) is an ioctl-like syscall with several different variants, each of
which has a distinct audit event.  Write separate audit(4) tests for each
variant.

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D16255
2018-07-20 18:59:48 +00:00
Alan Somers
405f09319f audit(4): add tests for _exit(2), cap_enter(2), and cap_getmode(2)
Also, fix a bug in common code that could cause other tests to fail: using
ppoll(2) in combination with buffered I/O for /dev/auditpipe.  Fix it by
disabling buffering.

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D16099
2018-07-17 15:12:55 +00:00
Kristof Provost
6e0bca03bd pf tests: Basic synproxy test
A very basic syncproxy test: set up a connection via a synproxy rule.
This triggeres the panic fixed in r336273.
2018-07-14 21:32:32 +00:00
John Baldwin
a9c91abd3b Export a breakpoint() function to userland for arm and arm64.
Enable ptrace() tests using breakpoint() on these architectures.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D15191
2018-07-06 23:49:17 +00:00
Alan Somers
b1b5f04d5b audit(4): add tests for procctl(2)
Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D16086
2018-07-01 16:05:50 +00:00
Alan Somers
af045bbfd7 audit(4): add tests for several more administrative syscalls
Includes ntp_adjtime, auditctl, acct, auditon, and clock_settime.  Includes
quotactl, mount, nmount, swapon, and swapoff in failure mode only.  Success
tests for those syscalls will follow.  Also includes reboot(2) in failure
mode only.  That one can't be tested in success mode.

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15898
2018-06-29 04:52:27 +00:00
Alan Somers
18ba95c24a audit(4): add tests for setsid, wait4, wait6, and kill
Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D16035
2018-06-29 04:46:15 +00:00
Alan Somers
5641c23fa7 audit(4): fix Coverity issues
Fix several incorrect buffer size arguments and a file descriptor leak.

Submitted by:	aniketp
Reported by:	Coverity
CID:		1393489 1393501 1393509 1393510 1393514 1393515 1393516
CID:		1393517 1393518 1393519
MFC after:	2 weeks
X-MFC-With:	335284
X-MFC-With:	335318
X-MFC-With:	335320
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D16000
2018-06-27 15:28:09 +00:00
Alan Somers
c907f24ead audit(4): add tests for the process-control audit class
Tested syscalls include rfork(2), chdir(2), fchdir(2), chroot(2),
getresuid(2), getresgid(2), setpriority(2), setgroups(2), setpgrp(2),
setrlimit(2), setlogin(2), mlock(2), munlock(2), minherit(2), rtprio(2),
profil(2), ktrace(2), ptrace(2), fork(2), umask(2), setuid(2), setgid(2),
seteuid(2), and setegid(2).  The last six are only tested in the success
case, either because they're infalliable or a failure is difficult to cause
on-demand.

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15966
2018-06-26 20:26:57 +00:00
Alan Somers
3d3d017834 audit(4): add tests for pipe, posix_openpt, shm_open, and shm_unlink
Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15963
2018-06-26 19:26:07 +00:00
Alan Somers
4aabb64af9 audit(4): add tests for Sys V semaphore operations
Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15897
2018-06-22 02:56:03 +00:00
Alan Somers
b92435cc82 audit(4): add tests for sendmsg, recvmsg, shutdown, and sendfile
Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15895
2018-06-19 17:41:46 +00:00
Alan Somers
d1fb351c68 audit(4): add tests for utimes(2) and friends, mprotect, and undelete
Includes utimes(2), futimes(2), lutimes(2), futimesat(2), mprotect(2), and
undelete(2).  undelete, for now, is tested only in failure mode.

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15893
2018-06-19 16:55:39 +00:00
Alan Somers
4003d93835 audit(4): add tests for ioctl(2)
Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15872
2018-06-19 01:32:33 +00:00
Alan Somers
ff150bea29 audit(4): Add tests for {get/set}auid, {get/set}audit, {get/set}audit_addr
Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15871
2018-06-18 15:37:43 +00:00
Alan Somers
943f585c5a audit(4): add tests for send, recv, sendto, and recvfrom
Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15869
2018-06-18 15:27:31 +00:00
Alan Somers
844fc5ebf1 audit(4): add tests for extattr_set_file and friends
Includes extattr_{set_file, _set_fd, _set_link, _delete_file, _delete_fd,
_delete_link}

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15867
2018-06-18 15:07:10 +00:00
Alan Somers
4107f2c44c Fix 32-bit build after 335307
This was correct in the final version on Phabricator, but somehow I screwed
up applying the patch locally.

Reported by:	linimon
Pointy-hat-to:	asomers
MFC after:	2 weeks
X-MFC-With:	335307
2018-06-18 04:12:58 +00:00
Alan Somers
8f2433eb44 audit(4): add tests for Sys V shared memory syscalls
includes shmget, shmat, shmdt, and shmctl

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15860
2018-06-17 21:29:35 +00:00
Alan Somers
b84a044b4c audit(4): add tests for connect, connectat, and accept
Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15853
2018-06-17 17:43:55 +00:00
Alan Somers
49f526501d audit(4): Add tests for a few syscalls in the ad class
The ad audit class is for administrative commands.  This commit adds test
for settimeofday, adjtime, and getfh.

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15861
2018-06-17 16:24:46 +00:00
Alan Somers
7d951cc29a audit(4): add tests for extattr_get_file(2) and friends
This commit includes extattr_{get_file, get_fd, get_link, list_file,
list_fd, list_link}.  It does not include any syscalls that modify, set, or
delete extended attributes, as those are in a different audit class.

Submitted by:	aniketpt
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15859
2018-06-17 15:22:27 +00:00
Alan Somers
68e520fea4 audit(4): add tests for chflags and friends
chflags, fchflags, and lchflags (but not chflagsat) are included.

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15854
2018-06-17 03:10:25 +00:00
Alan Somers
2c347e631e audit(4): add tests for pathconf(2) and friends
pathconf, lpathconf, and fpathconf are included

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15842
2018-06-16 18:29:24 +00:00
Alan Somers
d7d1ecc071 audit(4): add tests for POSIX message queues
Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15848
2018-06-16 18:22:35 +00:00
Alan Somers
5c9a473888 audit(4): add tests for chown(2) and friends
Includes chown, fchown, lchown, and fchownat

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15825
2018-06-16 15:38:59 +00:00
Alan Somers
babaf5cb1c audit(4): add tests for bind(2), bindat(2), and listen(2)
Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15843
2018-06-16 15:25:08 +00:00
Alan Somers
ad2afa8c8b audit(4): Add a few tests for network-related syscalls
Add tests for socket(2), socketpair(2), and setsockopt(2)

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15803
2018-06-15 16:41:28 +00:00
Alan Somers
52e29fd0cd audit(4): improve formatting in tests/sys/audit/open.c
[skip ci]

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15797
2018-06-15 15:36:10 +00:00
Alan Somers
2884521370 audit(4): add tests for access(2), chmod(2), and friends
access(2), eaccess(2), faccessat(2), chmod(2), fchmod(2), lchmod(2), and
fchmodat(2).

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15805
Differential Revision:	https://reviews.freebsd.org/D15808
2018-06-15 15:32:02 +00:00
Alan Somers
a56867b8c5 audit(4): add tests for fhopen, fhstat, and fhstatfs
Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15798
2018-06-14 15:04:49 +00:00
Alan Somers
5597d2a341 audit(4): fix typo from r335136
Typo in Makefile accidentally disabled some older tests

MFC after:	2 weeks
X-MFC-With:	335136
2018-06-14 14:53:01 +00:00
Alan Somers
6d203d2dd7 audit(4): add tests for flock, fcntl, and fsync
Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15795
2018-06-14 13:42:58 +00:00
Alan Somers
ae19b2ef9b audit(4): add tests for statfs(2), fstatfs(2), and getfsstat(2)
Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15750
2018-06-14 02:30:43 +00:00
Alan Somers
b13a70d5a4 audit(4): Fix file descriptor leaks in ATF tests
Submitted by:	aniketp
Reported by:	Coverity
CID:		1393343 1393346 1392695 1392781 1391709 1392078 1392413
CID:		1392014 1392521 1393344 1393345 1393347 1393348 1393349
CID:		1393354 1393355 1393356 1393357 1393358 1393360 1393362
CID:		1393368 1393369 1393370 1393371 1393372 1393373 1393376
CID:		1393380 1393384 1393387 1393388 1393389
MFC after:	2 weeks
Sponsored by:	Google, Inc (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15782
2018-06-13 17:01:57 +00:00
Alan Somers
f86d65170b audit(4): add tests for stat(2) and friends
This revision adds auditability tests for stat, lstat, fstat, and fstatat,
all from the fa audit class.  More tests from that audit class will follow.

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15709
2018-06-10 21:36:29 +00:00
Kristof Provost
d850143efd pf tests: Basic route-to tests
Very basic route-to tests. These tests attempt to provoke PR 228782 for IPv4
and IPv6. A test failure will panic the machine.
2018-06-09 14:21:07 +00:00
Alan Somers
c41bbc0acb audit(4): add tests for open(2) and openat(2)
These syscalls are atypical, because each one corresponds to several
different audit events, and they each pass several different audit class
filters.

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15657
2018-06-05 20:13:24 +00:00
Alan Somers
01e77fa0bf audit(4): add tests for the cl audit class
The only syscalls in this class are close, closefrom, munmap, and revoke.

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15650
2018-06-03 23:36:29 +00:00
Alan Somers
a19dca2dfd audit(4): add tests for the fd audit class
The only syscalls in this class are rmdir, unlink, unlinkat, rename, and
renameat.  Also, set is_exclusive for all audit(4) tests, because they can
start and stop auditd.

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15647
2018-06-01 21:24:10 +00:00
Alan Somers
26f5ecb775 audit(4): Add tests for the fw class of syscalls.
truncate and ftruncate are the only syscalls in this class, apart from
certain variations of open and openat, which will be handled in a different
file.

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15640
2018-06-01 16:23:47 +00:00
Alan Somers
8ec6562b6d audit(4): Add tests for the fr class of syscalls
readlink and readlinkat are the only syscalls in this class.  open and
openat are as well, but they'll be handled in a different file.  Also, tidy
up the copyright headers of recently added files in this area.

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15636
2018-06-01 01:37:07 +00:00
Alan Somers
e5569cb61e Revert r334362
Reconnect tests/sys/audit now that the GCC issue is fixed by 334388

MFC after:	2 weeks
X-MFC-With:	334362, 334360, 334388
2018-05-30 19:58:36 +00:00
Ed Maste
16b88f72f7 Temporarily disconnect audit tests
Audit tests added in r334360 broke the build on a number of archs.
Remove the subdir from the top level tests/sys/Makefile until they're
fixed.
2018-05-30 00:36:58 +00:00
Alan Somers
f7f4e0f7a8 Add initial set of tests for audit(4)
This change includes the framework for testing the auditability of various
syscalls, and includes changes for the first 12.  The tests will start
auditd(8) if needed, though they'll be much faster if it's already running.
The syscalls tested in this commit include mkdir(2), mkdirat(2), mknod(2),
mknodat(2), mkfifo(2), mkfifoat(2), link(2), linkat(2), symlink(2),
symlinkat(2), rename(2), and renameat(2).

Submitted by:	aniketp
MFC after:	2 weeks
Sponsored by:	Google, Inc (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15286
2018-05-29 23:08:33 +00:00
John Baldwin
ca75fa17ee Export a breakpoint() function to userland for riscv.
As a result, enable tests using breakpoint() on riscv.

Reviewed by:	br
Differential Revision:	https://reviews.freebsd.org/D15191
2018-05-16 16:56:35 +00:00
Ed Maste
ee9c968c85 Strip trailing / from TESTSDIR
Otherwise makefs gets upset:
makefs: ./usr/tests/sys/cddl/zfs/tests/exec/: empty leaf element

Sponsored by:	The FreeBSD Foundation
2018-05-11 16:11:24 +00:00
Ed Maste
2216c6933c Disable connectat/bindat with AT_FDCWD in capmode
Previously it was possible to connect a socket (which had the
CAP_CONNECT right) by calling "connectat(AT_FDCWD, ...)" even in
capabilties mode.  This combination should be treated the same as a call
to connect (i.e. forbidden in capabilities mode).  Similarly for bindat.

Disable connectat/bindat with AT_FDCWD in capabilities mode, fix up the
documentation and add tests.

PR:		222632
Submitted by:	Jan Kokemüller <jan.kokemueller@gmail.com>
Reviewed by:	Domagoj Stolfa
MFC after:	1 week
Relnotes:	Yes
Differential Revision:	https://reviews.freebsd.org/D15221
2018-04-30 17:31:06 +00:00
Konstantin Belousov
1187fc2dc6 Remove redundant pipe from pdeathsig.c test.
A pipe was was left over from a development version of pdeathsig.c and
is not needed.

Process C waits for a signal that'll be generated when process B
exists. Process B waits for process D to send it a byte via pipe_db
before it exits. Process D sends the byte after it has started
ptrace()ing process C. The point of the test is to show that process C
receives the signal because process B exited, even though C has been
reparented to process D. The pipe pipe_cd isn't doing anything useful
(though in an earlier version of the patch it did). Clean that up by
removing the useless pipe.

Submitted by:	Thomas Munro
MFC after:	6 days
Differential revision:	https://reviews.freebsd.org/D15214
2018-04-27 16:34:28 +00:00
John Baldwin
e71d9c1f33 Shorten some recently-added lines that are an extra indent over 80 columns. 2018-04-24 23:22:45 +00:00
John Baldwin
643ce7de72 Add two tests for TRAP_* signal codes for SIGTRAP.
- ptrace__breakpoint_siginfo tests that a SIGTRAP for a software breakpoint
  in userland triggers a SIGTRAP with a signal code of TRAP_BRKPT.
- ptrace__step_siginfo tests that a SIGTRAP reported for a step after
  stepping via PT_STEP or PT_SETSTEP has a signal code of TRAP_TRACE.
2018-04-24 05:30:05 +00:00
John Baldwin
bd061c3998 Expose breakpoint() to userland from <machine/cpufunc.h> on MIPS.
Enable ptrace() tests using breakpoint on MIPS as well.

Tested on:	mips64
MFC after:	1 month
2018-04-24 05:26:28 +00:00
John Baldwin
403e331d54 Extend support for ptrace() tests using breakpoints.
- Use a single list of platforms to define HAVE_BREAKPOINT for platforms
  that expose a functional breakpoint() inline to userland.  Replace
  existing lists of platform tests with HAVE_BREAKPOINT instead.
- Add support for advancing PC past a breakpoint inserted via breakpoint()
  to support the existing ptrace__PT_CONTINUE_different_thread test on
  non-x86 platforms (x86 advances the PC past the breakpoint instruction,
  but other platforms do not).  This is implemented by defining a new
  SKIP_BREAK macro which accepts a pointer to a 'struct reg' as its sole
  argument and modifies the contents to advance the PC.  The intention is
  to use it in between PT_GETREGS and PT_SETREGS.

Tested on:	amd64, i386, mips (after adding a breakpoint() to mips)
MFC after:	1 month
2018-04-24 05:20:16 +00:00
Konstantin Belousov
1302eea7bb Rename PROC_PDEATHSIG_SET -> PROC_PDEATHSIG_CTL and PROC_PDEATHSIG_GET
-> PROC_PDEATHSIG_STATUS for consistency with other procctl(2)
operations names.

Requested by:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	13 days
2018-04-20 15:19:27 +00:00
Konstantin Belousov
b940886338 Add PROC_PDEATHSIG_SET to procctl interface.
Allow processes to request the delivery of a signal upon death of
their parent process.  Supposed consumer of the feature is PostgreSQL.

Submitted by:	Thomas Munro
Reviewed by:	jilles, mjg
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D15106
2018-04-18 21:31:13 +00:00
John Baldwin
8ce99bb405 Properly do a deep copy of the ioctls capability array for fget_cap().
fget_cap() tries to do a cheaper snapshot of a file descriptor without
holding the file descriptor lock.  This snapshot does not do a deep
copy of the ioctls capability array, but instead uses a different
return value to inform the caller to retry the copy with the lock
held.  However, filecaps_copy() was returning 1 to indicate that a
retry was required, and fget_cap() was checking for 0 (actually
'!filecaps_copy()').  As a result, fget_cap() did not do a deep copy
of the ioctls array and just reused the original pointer.  This cause
multiple file descriptor entries to think they owned the same pointer
and eventually resulted in duplicate frees.

The only code path that I'm aware of that triggers this is to create a
listen socket that has a restricted list of ioctls and then call
accept() which calls fget_cap() with a valid filecaps structure from
getsock_cap().

To fix, change the return value of filecaps_copy() to return true if
it succeeds in copying the caps and false if it fails because the lock
is required.  I find this more intuitive than fixing the caller in
this case.  While here, change the return type from 'int' to 'bool'.

Finally, make filecaps_copy() more robust in the failure case by not
copying any of the source filecaps structure over.  This avoids the
possibility of leaking a pointer into a structure if a similar future
caller doesn't properly handle the return value from filecaps_copy()
at the expense of one more branch.

I also added a test case that panics before this change and now passes.

Reviewed by:	kib
Discussed with:	mjg (not a fan of the extra branch)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D15047
2018-04-17 18:07:40 +00:00
Alan Somers
52c0983128 lio_listio: return EAGAIN instead of EIO when out of resources
This behavior is already documented by the man page, and suggested by POSIX.

Reviewed by:	jhb
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D15099
2018-04-16 18:12:15 +00:00
Eitan Adler
8adbc73788 [tests] change tests/sys/acl/run to run on perl 5.26
Previously unescaped regex just resulted in a warning. Now it results in
a failed test.
2018-04-11 07:15:30 +00:00
Kristof Provost
cb625c1e17 pf tests: Do not build or install if pf is not enabled
Do not build or install pf tests if WITHOUT_PF is set. This fixes the build
failure with WITHOUT_PF=yes.

Reported by:	Vladimir Zakharov <zakharov.vv@gmail.com>
2018-04-10 12:45:34 +00:00
Kristof Provost
62d28676c3 pf tests: Basic ioctl validation
Basic validation tests for DIOCRADDADDRS, DIOCRDELADDRS, DIOCRSETADDRS,
DIOCRGETADDRS, DIOCRGETASTATS, DIOCRCLRASTATS, DIOCRTSTADDRS,
DIOCRINADEFINE, DIOCXBEGIN and DIOCXROLLBACK.

MFC after:	1 week
2018-04-06 19:37:15 +00:00
Kristof Provost
1bb72c2943 pf tests: Try to provoke a memory leak
There was a memory leak in the DIOCRADDTABLES ioctl() code which could
be triggered by trying to add tables with the same name.
Try to provoke this memory leak. It was fixed in r331225.

MFC after:	1 week
2018-04-06 19:22:22 +00:00
Kristof Provost
8e748b94e7 pf tests: Basic ioctl validation for DIOCIGETIFACES and DIOCXCOMMIT
Validate the DIOCIGETIFACES and DIOCXCOMMIT ioctls with invalid values.

MFC after:	1 week
2018-04-06 19:21:29 +00:00
Kristof Provost
1ff545d642 pf tests: Basic ioctl validation for DIOCRGETTABLES, DIOCRGETTSTATS, DIOCRCLRTSTATS and DIOCRSETTFLAGS
Validate the DIOCRGETTABLES, DIOCRGETTSTATS, DIOCRCLRTSTATS and
DIOCRSETTFLAGS ioctls with invalid values. These may succeed (because
the kernel uses the minimally required size, not the specified size),
but should not trigger kernel panics.

MFC after:	1 week
2018-04-06 15:57:20 +00:00
Kristof Provost
98c5f9884e pf tests: Basic ioctl validation tests
Validate the DIOCRADDTABLES and DIOCRDELTABLES ioctls with invalid size
values. All of these requests should fail.

MFC after:	1 week
2018-04-06 15:03:48 +00:00
Andriy Gapon
5a2fc46447 ZFS test suite: fix uses of illumos /dev/[r]dsk/ and /dev/zvol/[r]dsk/ 2018-03-27 11:49:15 +00:00
Conrad Meyer
0e33efe4e4 Import Blake2 algorithms (blake2b, blake2s) from libb2
The upstream repository is on github BLAKE2/libb2.  Files landed in
sys/contrib/libb2 are the unmodified upstream files, except for one
difference:  secure_zero_memory's contents have been replaced with
explicit_bzero() only because the previous implementation broke powerpc
link.  Preferential use of explicit_bzero() is in progress upstream, so
it is anticipated we will be able to drop this diff in the future.

sys/crypto/blake2 contains the source files needed to port libb2 to our
build system, a wrapped (limited) variant of the algorithm to match the API
of our auth_transform softcrypto abstraction, incorporation into the Open
Crypto Framework (OCF) cryptosoft(4) driver, as well as an x86 SSE/AVX
accelerated OCF driver, blake2(4).

Optimized variants of blake2 are compiled for a number of x86 machines
(anything from SSE2 to AVX + XOP).  On those machines, FPU context will need
to be explicitly saved before using blake2(4)-provided algorithms directly.
Use via cryptodev / OCF saves FPU state automatically, and use via the
auth_transform softcrypto abstraction does not use FPU.

The intent of the OCF driver is mostly to enable testing in userspace via
/dev/crypto.  ATF tests are added with published KAT test vectors to
validate correctness.

Reviewed by:	jhb, markj
Obtained from:	github BLAKE2/libb2
Differential Revision:	https://reviews.freebsd.org/D14662
2018-03-21 16:18:14 +00:00
Conrad Meyer
855c2cbe07 Appease GCC 4.2
It mistakenly believes the 'static' keyword must come first.  Fix PPC,
Sparc64, and maybe MIPS world.  Fallout from r331279.

Reported by:	tinderbox (results come slowly)
2018-03-21 04:44:19 +00:00
Conrad Meyer
e9ac27430c Implement getrandom(2) and getentropy(3)
The general idea here is to provide userspace programs with well-defined
sources of entropy, in a fashion that doesn't require opening a new file
descriptor (ulimits) or accessing paths (/dev/urandom may be restricted
by chroot or capsicum).

getrandom(2) is the more general API, and comes from the Linux world.
Since our urandom and random devices are identical, the GRND_RANDOM flag
is ignored.

getentropy(3) is added as a compatibility shim for the OpenBSD API.

truss(1) support is included.

Tests for both system calls are provided.  Coverage is believed to be at
least as comprehensive as LTP getrandom(2) test coverage.  Additionally,
instructions for running the LTP tests directly against FreeBSD are provided
in the "Test Plan" section of the Differential revision linked below.  (They
pass, of course.)

PR:		194204
Reported by:	David CARLIER <david.carlier AT hardenedbsd.org>
Discussed with:	cperciva, delphij, jhb, markj
Relnotes:	maybe
Differential Revision:	https://reviews.freebsd.org/D14500
2018-03-21 01:15:45 +00:00
John Baldwin
7c13fd10c4 Revert r318180 and re-enable AIO tests on md(4) by default.
The 'physio' fast-path used by AIO requests on md(4) devices, is not
gated on the unsafe_aio knob.  Prior to r327755, some AIO requests could
fail the fast-path and fall back to the slow-path (requests for devices
not supporting unmapped I/O and requests which failed with EFAULT during
the fast-path).  However, those cases now return a suitable error rather
than using the slow-path.

PR:		217261
Reviewed by:	asomers
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D14742
2018-03-19 19:09:15 +00:00
Alan Somers
c189c73f01 aio_kqueue_test: fix the build when DEBUG=1
Also, make the debug output more verbose
2018-03-17 17:52:47 +00:00
Alan Somers
604bbb3f3c aio: add an ATF test case for aio_fsync error conditions 2018-03-17 17:48:21 +00:00
Andriy Gapon
bd539a8e3c zfs test suite: move definition of DISK to the cfg file in zpool_get
The variable is used not only by the setup script but also by the
atf test bodies.

Another one that should have been in r331001.
2018-03-15 14:47:53 +00:00
Andriy Gapon
0577c05e9a zfs test suite: add new pool properties / features to the zpool_get list 2018-03-15 14:41:09 +00:00
Andriy Gapon
1524d42a3e zfs test suite: move definition of DISK to the cfg file in zpool_get
The variable is used not only by the setup script but also by the
atf test bodies.

This should have been in r331001.
2018-03-15 14:35:46 +00:00
Andriy Gapon
4da82917ea zfs test suite: move definition of DISK to the cfg file in zpool_export
The variable is used not only by the setup script but also by the
atf test bodies.
2018-03-15 14:23:31 +00:00
Andriy Gapon
a7478ad1ce zfs test suite: support device paths with intermediate directories
The code assumed that disks (devices) used for testing are always named
like /dev/foo, but there is no reason for that restriction and we can
easily support paths like /dev/stripe/bar.
2018-03-15 12:47:34 +00:00
Andriy Gapon
aaaf06cd0c zfs test suite: fix a typo, TESTPOOL vs TESTPOOL2 2018-03-15 12:44:13 +00:00
Andriy Gapon
2b188a8915 zfs test suite: destroy old gnops before creating new ones 2018-03-15 12:42:19 +00:00
Andriy Gapon
bafadcd52b zfs test suite: align zfs_destroy_005_neg: with upstream
The change is to account for a different order in which the recursive
destroy may be attempted.  If we first try a dataset that can be destroyed
then it will be destroyed, but if we first try a dataset that cannot be
destroyed then we will not attempt to destroy the other dataset.
2018-03-15 12:40:43 +00:00
Andriy Gapon
ee00e55c89 zfs test suite: fix a typo, da0 vs $disk 2018-03-15 12:35:22 +00:00
Andriy Gapon
72891bc15d re-enable zfs_copies_006_pos test after a fix in r330977
The test was disabled in r329408.

PR:		225960
2018-03-15 09:28:10 +00:00
Andriy Gapon
3c9d418b7e re-enable zpool_upgrade_007_pos test after the fix in r330974
The test was disabled in r329248.

PR:		225877
2018-03-15 08:52:49 +00:00
Alan Somers
4b40bdbd1f Add tests for lagg(4) and other cloned network interfaces
Unfortunately, most of the tests are disabled because they fairly frequently
trigger panics.

MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
2018-02-23 18:18:42 +00:00
Alan Somers
2fae26bd8b Add the ZFS test suite
It was originally written by Sun as part of the STF (Solaris test framework).
They open sourced it in OpenSolaris, then HighCloud partially ported it to
FreeBSD, and Spectra Logic finished the port.  We also added many testcases,
fixed many broken ones, and converted them all to the ATF framework.  We've had
help along the way from avg, araujo, smh, and brd.

By default most of the tests are disabled.  Set the disks Kyua variable to
enable them.

Submitted by:	asomers, will, justing, ken, brd, avg, araujo, smh
Sponsored by:	Spectra Logic Corp, HighCloud
2018-02-23 16:31:00 +00:00
Alan Somers
834063202a gpart: append partition name to the underlying provider's physical path
If the underlying provider's physical path is null, then the gpart device's
physical path will be, too. Otherwise, it will append the partition name,
such as "/p1" or "/s1/a". This will make gpart work better with zfsd(8).

PR:		224965
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D14010
2018-02-14 20:26:09 +00:00
Alan Somers
0bab7fa8a7 geli: append "/eli" to the underlying provider's physical path
If the underlying provider's physical path is null, then the geli device's
physical path will be, too. Otherwise, it will append "/eli".  This will make
geli work better with zfsd(8).

PR:		224962
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D13979
2018-02-14 20:15:32 +00:00
Brooks Davis
5e1e3ea237 Fix and enable SysV IPC tests.
Don't declare some types that FreeBSD incorrectly declares.

Fix an incorrect call to open() (missing mode).

ANSIfy prototypes.

Enable SysV message queue, semaphore, and shared memory tests.

With exception of the workaround for union semun, these fixes have been
committed to NetBSD.

Reviewed by:	asomers
Approved by:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D13471
2018-02-05 18:48:00 +00:00
John Baldwin
e0a40f3045 Mark the unused argument to continue_thread() as such.
clang in HEAD and 11 does not warn about this, but clang in 10 does.
2018-01-24 17:46:20 +00:00
Conrad Meyer
844d9543dc Add ccp(4): experimental driver for AMD Crypto Co-Processor
* Registers TRNG source for random(4)
* Finds available queues, LSBs; allocates static objects
* Allocates a shared MSI-X for all queues.  The hardware does not have
  separate interrupts per queue.  Working interrupt mode driver.
* Computes SHA hashes, HMAC.  Passes cryptotest.py, cryptocheck tests.
* Does AES-CBC, CTR mode, and XTS.  cryptotest.py and cryptocheck pass.
* Support for "authenc" (AES + HMAC).  (SHA1 seems to result in
  "unaligned" cleartext inputs from cryptocheck -- which the engine
  cannot handle.  SHA2 seems to work fine.)
* GCM passes for block-multiple AAD, input lengths

Largely based on ccr(4), part of cxgbe(4).

Rough performance averages on AMD Ryzen 1950X (4kB buffer):
aesni:      SHA1: ~8300 Mb/s    SHA256: ~8000 Mb/s
ccp:               ~630 Mb/s    SHA256:  ~660 Mb/s  SHA512:  ~700 Mb/s
cryptosoft:       ~1800 Mb/s    SHA256: ~1800 Mb/s  SHA512: ~2700 Mb/s

As you can see, performance is poor in comparison to aesni(4) and even
cryptosoft (due to high setup cost).  At a larger buffer size (128kB),
throughput is a little better (but still worse than aesni(4)):

aesni:      SHA1:~10400 Mb/s    SHA256: ~9950 Mb/s
ccp:              ~2200 Mb/s    SHA256: ~2600 Mb/s  SHA512: ~3800 Mb/s
cryptosoft:       ~1750 Mb/s    SHA256: ~1800 Mb/s  SHA512: ~2700 Mb/s

AES performance has a similar story:

aesni:      4kB: ~11250 Mb/s    128kB: ~11250 Mb/s
ccp:               ~350 Mb/s    128kB:  ~4600 Mb/s
cryptosoft:       ~1750 Mb/s    128kB:  ~1700 Mb/s

This driver is EXPERIMENTAL.  You should verify cryptographic results on
typical and corner case inputs from your application against a known- good
implementation.

Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12723
2018-01-18 22:01:30 +00:00
Alan Somers
6f7f85e0e1 gnop(8): add the ability to set a nop provider's physical path
While I'm here, expand the existing tests a bit.

MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D13579
2018-01-18 05:57:10 +00:00
Mark Johnston
a19e742901 Add regression tests for r327779.
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2018-01-10 19:41:05 +00:00
Mark Johnston
00da6aa72b Remove the executable bit from some recently added test scripts. 2018-01-10 15:55:07 +00:00
Kristof Provost
a60f45a0d5 pf tests: Fix pft_ping.py to work with scapy 2.3.3
Scapy requires the Raw payload to be a string, which was not the case. This
caused the pft_ping.py script to fail, which in turn caused the test to fail.
2018-01-09 19:02:42 +00:00
Alan Somers
1d23aa6ec7 geli: optimize tests
Reduce the geli tests' runtime by about a third:

* In integrity_test:copy, use a file-backed md(4) device instead of a
  malloc'd one.  That way we can corrupt the underlying storage without
  needing to detach and reattach the geli device.

* In integrity_test:{copy, hmac, data} and onetime_test:{onetime,
  onetime_a}, move reads of /dev/random out of the loop.

MFC after:	2 weeks
2018-01-08 00:10:45 +00:00
Alan Somers
565a0a2c65 geli: convert remaining TAP tests to ATF
MFC after:	2 weeks
2018-01-07 22:21:07 +00:00
Alan Somers
48c29f849e Fix typo from r327666
MFC after:	13 days
X-MFC-With:	327666
2018-01-07 21:57:52 +00:00
Alan Somers
5dce212d67 geli: fix parallel execution of tests
The trick is not to destroy an md(4) device during a test.  That can create
a "double-free" situation, because we also destroy md devices during test
cleanup.

MFC after:	2 weeks
2018-01-07 02:30:08 +00:00
Alan Somers
f397a004de geli: convert most tests from TAP to ATF
I'm leaving readonly_test and nokey_test alone for now. In a future commit
they should be broken up into several smaller test cases and distributed
between multiple files.

Reviewed by:	ngie
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D13717
2018-01-07 00:44:22 +00:00
Alan Somers
3a8d2bd4a1 geli: fix the resize test on arm64
The resize test used bsdlabel(8), which is not available on all
architectures.  Change it to use gpart(8) instead, which should be available
everywhere.

PR:		221763
Reported by:	andrew
MFC after:	2 weeks
2017-12-29 18:42:55 +00:00
Alan Somers
610b95a173 Fix a harmless typo from r310786
I copy/pasted a reference to an undefined shell variable.

MFC after:	2 weeks
2017-12-29 18:09:06 +00:00
Alan Somers
2e23c41122 geli: factor out some common code in the geli tests
No functional change.

MFC after:	2 weeks
Sponsored by:	Spectra Logic Corp
2017-12-29 16:13:06 +00:00
Alan Somers
041999e3d0 Fix potential TOCTTOU bug in the geli tests
This change mostly reverts r293436, which introduced the bug due to a belief
that geli(8) would allocate md(4) devices by itself. However, that belief is
incorrect. Instead of using linear probing to find available md(4) numbers,
it's best to use the existing attach_md function.

Reviewed by:	ngie
MFC after:	2 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D13666
2017-12-29 16:06:10 +00:00
Eitan Adler
9914452050 other: Fix several typos and minor errors
- duplicate words
- typos
- references to old versions of FreeBSD

Reviewed by:	imp, benno
2017-12-27 03:23:58 +00:00
John Baldwin
3a014c56c1 Catch up to r325719 which makes the kern.proc.pid sysctl "work" for zombies.
Some of the ptrace tests need to wait for a child process to become a
zombie before preceding.  The parent process polls the child process
via the kern.proc.pid sysctl to wait for it to become a zombie.
Previously the code polled until the sysctl failed with ESRCH.  Now it
will poll until either the sysctl fails with ESRCH (for compatiblity
with older kernels) or returns a kinfo_proc structure with the ki_stat
field set to SZOMB.

Reported by:	Jenkins
Tested by:	markj
Discussed with:	mjg
MFC after:	1 week
2017-12-18 23:35:14 +00:00
Mark Johnston
37a13f5792 Skip gnop tests if the corresponding kernel module isn't available.
Reviewed by:	asomers
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D13500
2017-12-15 17:10:51 +00:00
Mark Johnston
21274cad33 Belatedly add syncwait.
X-MFC with:	r326861
2017-12-14 22:15:46 +00:00
Mark Johnston
504eda2021 Make indentation consistent with other tests, and use syncwait.
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-12-14 22:14:07 +00:00
Mark Johnston
ca623e07ce Add some basic tests for gmirror read and write error handling.
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-12-14 22:11:35 +00:00
Kristof Provost
02d92cc609 tests: ipsec: Don't load/unload aesni.ko in the test header
We can't kldunload in the test head as Kyua interprets any output from
them. This would lead to syntax errors and skipping the entire file.

Move the kld commands into the test case bodies.

Pointed out by: asomers@
2017-12-03 18:35:07 +00:00
Kristof Provost
4fbebc7472 Add IPSec tests in tunnel mode
Some IPSec in tunnel mode allowing to test multiple IPSec
configurations.  These tests are reusing the jail/vnet scripts from pf
tests for generating complex network.

Submitted by:	olivier@
Differential Revision:	https://reviews.freebsd.org/D13017
2017-12-03 13:52:35 +00:00
Conrad Meyer
38d84d683e vfs_lookup: Allow PATH_MAX-1 symlinks
Previously, symlinks in FreeBSD were artificially limited to PATH_MAX-2.

Add a short test case to verify the change.

Submitted by:	Gaurav Gangalwar <ggangalwar AT isilon.com>
Reviewed by:	kib
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12589
2017-11-17 19:25:39 +00:00
Alan Somers
c4708ce80c Fix build on arm after r325817
Reported by:	rpokala
MFC after:	3 weeks
X-MFC-With:	325817
Sponsored by:	Spectra Logic Corp
2017-11-14 21:11:55 +00:00
Alan Somers
c52ef9bbff AIO tests: increase limits
tests/sys/aio/aio_kqueue_test.c
	Instead of using a hard-coded queue depth, use
	vfs.aio.max_aio_queue_per_proc

tests/sys/aio/lio_kqueue_test.c
	The old, small limit on lio_listio's operation count was lifted by
	change 324941.  Raise the operation count as high as possible without
	exceeding the process's operation limit.

MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
2017-11-14 17:46:37 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Bryan Drewery
3806950135 DIRDEPS_BUILD: Connect new directories.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:04:07 +00:00
John Baldwin
e012fe34cb Discard the correct thread event reported for a ptrace stop.
When multiple threads wish to report a tracing event to a debugger,
both threads call ptracestop() and one thread will win the race to be
the reporting thread (p->p_xthread).  The debugger uses PT_LWPINFO
with the process ID to determine which thread / LWP is reporting an
event and the details of that event.  This event is cleared as a side
effect of the subsequent ptrace event that resumed the process
(PT_CONTINUE, PT_STEP, etc.).  However, ptrace() was clearing the
event identified by the LWP ID passed to the resume request even if
that wasn't the 'p_xthread'.  This could result in clearing an event
that had not yet been observed by the debugger and leaving the
existing event for 'p_thread' pending so that it was reported a second
time.

Specifically, if the debugger stopped due to a software breakpoint in
one thread, but then switched to another thread that was used to
resume (e.g. if the user switched to a different thread and issued a
step), the resume request (PT_STEP) cleared a pending event (if any)
for the thread being stepped.  However, the process immediately
stopped and the first thread reported it's breakpoint event a second
time.  The debugger decremented the PC for "both" breakpoint events
which resulted in the PC now pointing into the middle of an
instruction (on x86) and a SIGILL fault when the process was resumed a
second time.

To fix, always clear the pending event for 'p_xthread' when resuming a
process.  ptrace() still honors the requested LWP ID when enabling
single-stepping (PT_STEP) or setting a different PC (PT_CONTINUE).

Reported by:	GDB testsuite (gdb.threads/continue-pending-status.exp)
Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D12794
2017-10-27 03:16:19 +00:00
Kristof Provost
96b90524d1 pf tests: Remove temporary files
Remove the created_jails.lst and created_interfaces.lst files in the
cleanup code.
2017-10-26 20:55:33 +00:00
Kristof Provost
57d465298a pf tests: Fragmentation (v6) test
Test fragmentation handling (i.e. scrub fragment reassemble) code for
IPv6.

Two simple tests: Ping a host (jail) and test forwarding of fragmented
packets.
2017-10-26 20:54:52 +00:00
Kristof Provost
da86443874 pf tests: destroy jails before destroying interfaces
When cleaning up we must destroy the jails before we destroy the interfaces.
Otherwise we might try to destroy interfaces that belong to a jail, which won't
work and fail to completely clean up.
2017-10-26 20:53:56 +00:00
John Baldwin
54cfb29e3a Add a test for sending a signal while stepping a thread via PT_STEP.
MFC after:	1 week
2017-10-25 17:23:33 +00:00
Bryan Drewery
753e292217 Add a test for r324671 along with some other masked tests.
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-10-17 19:01:01 +00:00
Bryan Drewery
fc1e29dc35 This child is expected to exit on SIGTRAP, don't leave a core behind.
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-10-16 20:06:24 +00:00
Kristof Provost
f038a398da pf tests: Use pft_set_rules everywhere
We now have a utility function to set pf rules in the jail. Use it
whenever we need to set the pf rules in the test jail.
2017-10-16 15:05:32 +00:00
Kristof Provost
ba22aeacf1 pf tests: Basic IPv6 forwarding tests
Pass/block packets in the forwarding path with pf.

Introduce the pft_set_rules() helper function, because we need to
remember to flush states between individual tests. If not we can get
packets passing despite rules blocking them because they match states
created in a previous test.

Extend pft_ping.py to be able to send IPv6 echo requests.
2017-10-16 15:03:45 +00:00
Kristof Provost
67f4baf8b0 pf: test set-tos
Introduce tests for the set-tos feature of pf. Teach pft_ping.py to send
and verify ToS flags.
2017-10-16 15:01:49 +00:00
Bryan Drewery
9643739121 Fix shadowed variable hidden by WARNS changing to 3 in r313006.
Sponsored by:	Dell EMC Isilon
MFC after:	1 week
2017-10-12 19:58:21 +00:00
Enji Cooper
5b347b28cd Check the exit code from fsck_ffs instead of relying on MODIFIED being in the output
^/head@r323923 changed when MODIFIED is printed at exit. It's better to follow the
documented way of determining whether or not a filesystem is clean per fsck_ffs, i.e.,
ensure that the exit code is either 0 or 7.

The pass/fail determination is brittle prior to this commit, and ^/head@r323923 made
the issue apparent -- thus this needs to be fixed independent of ^/head@r323923.

PR:		222780
MFC after:	1 week
MFC with:	r323923
Reported by:	Jenkins
2017-10-10 05:58:33 +00:00
Kristof Provost
c0b63519b0 pf: Very basic forwarding test
This test illustrates the use of scapy to test pf.

Differential Revision:	https://reviews.freebsd.org/D12581
2017-10-06 20:51:32 +00:00
Kristof Provost
1d6f5f214a pf: Basic automated test using VIMAGE
If VIMAGE is present we can start jails with their own pf instance. This
makes it fairly easy to run tests.
For example, this basic test verifies that drop/pass and icmp
classification works. It's a basic sanity test for pf, and hopefully an
example on how to write more pf tests.

The tests are skipped if VIMAGE is not enabled.

This work is inspired by the GSoC work of Panagiotes Mousikides.

Differential Revision:	https://reviews.freebsd.org/D12580
2017-10-06 20:43:14 +00:00
Conrad Meyer
fe182ba1d0 aesni(4): Add support for x86 SHA intrinsics
Some x86 class CPUs have accelerated intrinsics for SHA1 and SHA256.
Provide this functionality on CPUs that support it.

This implements CRYPTO_SHA1, CRYPTO_SHA1_HMAC, and CRYPTO_SHA2_256_HMAC.

Correctness: The cryptotest.py suite in tests/sys/opencrypto has been
enhanced to verify SHA1 and SHA256 HMAC using standard NIST test vectors.
The test passes on this driver.  Additionally, jhb's cryptocheck tool has
been used to compare various random inputs against OpenSSL.  This test also
passes.

Rough performance averages on AMD Ryzen 1950X (4kB buffer):
aesni:      SHA1: ~8300 Mb/s    SHA256: ~8000 Mb/s
cryptosoft:       ~1800 Mb/s    SHA256: ~1800 Mb/s

So ~4.4-4.6x speedup depending on algorithm choice.  This is consistent with
the results the Linux folks saw for 4kB buffers.

The driver borrows SHA update code from sys/crypto sha1 and sha256.  The
intrinsic step function comes from Intel under a 3-clause BSDL.[0]  The
intel_sha_extensions_sha<foo>_intrinsic.c files were renamed and lightly
modified (added const, resolved a warning or two; included the sha_sse
header to declare the functions).

[0]: https://software.intel.com/en-us/articles/intel-sha-extensions-implementations

Reviewed by:	jhb
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12452
2017-09-26 23:12:32 +00:00
Conrad Meyer
a317fb03c2 crypto(9): Use a more specific error code when a capable driver is not found
When crypto_newsession() is given a request for an unsupported capability,
raise a more specific error than EINVAL.

This allows cryptotest.py to skip some HMAC tests that a driver does not
support.

Reviewed by:	jhb, rlibby
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12451
2017-09-26 01:31:49 +00:00
Enji Cooper
d86680b073 Convert some idioms over to py3k-compatible idioms
- Import print_function from __future__ and use print(..) instead of `print ..`.
- Use repr instead of backticks when the object needs to be dumped, unless
  print(..) can do it lazily. Use str instead of backticks as appropriate
  for simplification reasons.

This doesn't fully convert these modules over py3k. It just gets over some of
the trivial compatibility hurdles.
2017-09-24 00:14:48 +00:00
Conrad Meyer
67e4d800ec cryptotest.py: Like r323869, skip SHA HMAC tests on non-SHA drivers
Sponsored by:	Dell EMC Isilon
2017-09-22 04:41:48 +00:00
Conrad Meyer
e720124622 cryptotest.py: Fix whitespace style errors
I accidentally introduced different whitespace style in r323878.  I'm not
used to using tabs for indentation in Python scripts.

Whitespace only; no functional change.

Sponsored by:	Dell EMC Isilon
2017-09-22 04:25:44 +00:00
Conrad Meyer
005fdbbc69 cryptotest.py: Actually use NIST-KAT HMAC test vectors and test the right hashes
Previously, this test was entirely a no-op as no vector in the NIST-KAT file
has a precisely 20-byte key.

Additionally, not every vector in the file is SHA1.  The length field
determines the hash under test, and is now decoded correctly.

Finally, due to a limitation I didn't feel like fixing in cryptodev.py, MACs
are truncated to 16 bytes in this test.

With this change and the uncommitted D12437 (to allow key sizes other than
those used in IPSec), the SHA tests in cryptotest.py actually test something
and e.g. at least cryptosoft passes the test.

Sponsored by:	Dell EMC Isilon
2017-09-21 21:07:21 +00:00
Conrad Meyer
b3eaa68045 cryptotest.py: Do not run AES-CBC or AES-GCM tests on non-AES crypto(4) drivers
For some reason, we only skipped AES-XTS tests if a driver was not in the
aesmodules list.  Skip other AES modes as well to prevent spurious failures
in non-AES drivers.

Sponsored by:	Dell EMC Isilon
2017-09-21 18:06:21 +00:00
Conrad Meyer
7abea82d17 cryptotest.py: Add a seatbelt that we're actually testing anything
Without nist-kat installed, cryptotest.py is a no-op.  Showing 'success' in
that case is unhelpful.

Sponsored by:	Dell EMC Isilon
2017-09-21 05:46:28 +00:00
Enji Cooper
188e46ab03 Add supporting changes for Add limited sandbox capability to "make check"
Non-tests/... changes:
- Add HAS_TESTS= to Makefiles with libraries and programs to enable iteration
  and propagate the appropriate environment down to *.test.mk.

tests/... changes:
- Add appropriate support Makefile.inc's to set HAS_TESTS in a minimal manner,
  since tests/... is a special subdirectory tree compared to the others.

MFC after:	2 months
MFC with:	r322511
Reviewed by:	arch (silence), testing (silence)
Differential Revision:	D12014
2017-08-14 19:21:37 +00:00
Alan Somers
4312aa67e3 tests/sys/netinet/fibs_test: skip selected tests when firewalls are enabled
Some tests send packets over epair(4) interfaces. Firewalls can cause
spurious failures.

Reviewed by:	ngie
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D11917
2017-08-08 15:37:21 +00:00
Enji Cooper
d2ba5111c1 Make test scripts under tests/... non-executable
Executable bits should be set at install time instead of in the repo.
Setting executable bits on files triggers false positives with Phabricator.

MFC after:	2 months
2017-08-08 04:59:16 +00:00
Enji Cooper
a9be721ce5 MFhead@r321967 2017-08-03 03:45:48 +00:00
Enji Cooper
acc33f3de9 Chase r321920 and r321930 (dev_t being widened)
The layout of st_rdev has changed after this commit, and assumptions made
in the NetBSD tests are no longer valid. Change the hardcoded assumed
values to account for the fact that major/minor are now represented by
64 bits as opposed to the less precise legacy precision of 16 bits.

PR:	221048
Relnotes: st_rdev layout changed; warning about impact of r321920 to
	  downstream consumers
2017-08-03 03:43:41 +00:00
Enji Cooper
341d6b3579 Use bsd.opts.mk, not src.opts.mk 2017-08-03 00:35:35 +00:00
Enji Cooper
86cc58dc96 MFhead@r321960 2017-08-02 22:28:12 +00:00