Commit Graph

1364 Commits

Author SHA1 Message Date
Kristof Provost
3468cd95ca pf: ether l3 rules can only use addresses
Disallow the use of tables in ethernet rules. Using tables requires
taking the PF_RULES lock. Moreover, the current table code isn't ready
to deal with ethernet rules.

Disallow their use for now.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-03-25 11:13:47 +01:00
Kristof Provost
d234b011a8 netinet tests: only log critical errors from scapy
See also a26e895f3d.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-03-17 23:34:12 +01:00
Kristof Provost
3c3a19d1f4 pf tests: Test retrieving nested nat-anchors
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-03-17 22:37:06 +01:00
Kristof Provost
d58d2e403d pf tests: Test setting and retrieving nested anchors
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-03-17 22:37:06 +01:00
Kristof Provost
734782a781 pf tests: Test new L3 inspection for pf 'ether' rules
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D34483
2022-03-14 22:43:38 +01:00
John Baldwin
18207579a2 module_test: Fix some assignments to errno intended to be tests.
Reported by:	vangyzen
Reviewed by:	vangyzen, markj
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D34528
2022-03-14 14:05:05 -07:00
Li-Wen Hsu
8e03a75086
Skip sys.geom.class.multipath.failloop.failloop if dtrace fails to run
This test case depends on dtrace and sometimes gets affected if dtrace
has issues.  Make it report skipped instead of failure when dtrace fails
to run.

Sponsored by:	The FreeBSD Foundation
2022-03-08 18:12:40 +08:00
Mark Johnston
d7412bcac8 gmultipath tests: Re-enable the failloop test in CI
Sponsored by:	The FreeBSD Foundation
2022-03-07 10:43:19 -05:00
Mark Johnston
3a01dcc99f tests: Fix the test plan for closefrom_test
Fixes:	f3f3e3c44d ("fd: add close_range(..., CLOSE_RANGE_CLOEXEC)")
Reported by:	Jenkins
2022-03-06 12:57:40 -05:00
John Baldwin
5a1de9c25d Add simple kyua tests for the mod* system calls.
Reviewed by:	markj
Obtained from:	CheriBSD
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D34417
2022-03-03 17:51:45 -08:00
Mateusz Guzik
f3f3e3c44d fd: add close_range(..., CLOSE_RANGE_CLOEXEC)
For compatibility with Linux.

MFC after:	3 days
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D34424
2022-03-03 17:21:58 +00:00
Kristof Provost
0d88926740 pf tests: extend ether test to verify mac address masks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-03-02 17:00:08 +01:00
Kristof Provost
fdadb00682 pf tests: Ensure 'pfctl -F ethernet' works
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-03-02 17:00:07 +01:00
Kristof Provost
93b64cdc59 pf tests: slightly more complect captive portal setup
Combine anchor, dummynet and rdr to produce a more complex captive
portal setup.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D32484
2022-03-02 17:00:07 +01:00
Kristof Provost
d1702bd1c3 pf tests: basic test for ether anchors
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D32483
2022-03-02 17:00:07 +01:00
Kristof Provost
87a89d6e14 pfctl: support lists of mac addresses
Teach the 'ether' rules to accept { mac1, mac2, ... } lists, similar to
the lists of interfaces or IP addresses we already supported for layer 3
filtering.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D32481
2022-03-02 17:00:07 +01:00
Kristof Provost
ab1868a7d1 pf tests: test match keyword and dummynet
Ensure that the 'match' keyword works with dummynet

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D32480
2022-03-02 17:00:06 +01:00
Kristof Provost
0faafc2185 pf tests: test dummynet for ether traffic
Test that we can set dummynet information on L2, which is processed by
L3 later (assuming it's not overruled by L3 rules, of course).

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D32223
2022-03-02 17:00:06 +01:00
Kristof Provost
feefb5625b pf tests: Test ether direction
Test that we correctly match inbound ('in') or outbound ('out') Ethernet
packets.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31747
2022-03-02 17:00:05 +01:00
Kristof Provost
792d7a5630 pf tests: Basic captive portal like test
Use the ether rules to selectively (i.e. per MAC address) redirect
certain connections. Test that tags carry over to the layer-3 pf code.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31746
2022-03-02 17:00:05 +01:00
Kristof Provost
4ffb7d1300 pf tests: Test EtherType filtering
Test filtering packets by their EtherType (i.e. ARP/IPv4/IPv6/...).

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31745
2022-03-02 17:00:05 +01:00
Kristof Provost
3a04f1d1ed pf tests: Test MAC address negation
Test that we can express 'ether block from ! 00:01:02:03:04:05'.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31744
2022-03-02 17:00:04 +01:00
Kristof Provost
d6fc3ee2e7 pf tests: MAC address filtering test
Test the MAC address filtering capability in the new 'ether' feature in
pf.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31743
2022-03-02 17:00:04 +01:00
Ed Maste
f27fb06cad zfs: Update test format strings to match variable typtes
And drop stray 'd' from the end of some printed numbers.  I assume this
was the result of someone thinking u is a printf length modifier for d,
not a format specifier itself.

Reviewed by:	kevans, rew
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34387
2022-03-01 12:21:40 -05:00
Alan Somers
e8553be9bc fusefs: fix a cached attributes bug during directory rename
When renaming a directory into a different parent directory, invalidate
the cached attributes of the new parent.  Otherwise, stat will show the
wrong st_nlink value.

MFC after:	1 week
Reviewed by:	ngie
Differential Revision: https://reviews.freebsd.org/D34336
2022-02-24 14:07:25 -07:00
Li-Wen Hsu
d33158471a
Temporarily skip sys.geom.class.multipath.failloop.failloop in CI
This test case uses `dtrace -c` but it has some issues at the moment so
disable it until dtrace fixed.

From markj:

This is the CTF type ID limit which has come up quite a few times
lately.  It'll be fixed with the introduction of CTFv3.

PR:		258763
Sponsored by:	The FreeBSD Foundation
2022-02-24 06:28:24 +08:00
Andrew Turner
6713be3159 Add NT_ARM_ADDR_MASK
This can be used by debuggers to find which bits in a virtual address
should be masked off to get a canonical address. This is currently used
by the Pointer Authentication Code support to get its mask. It could also
be used if we support Top Byte Ignore for the same purpose.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34302
2022-02-22 17:10:35 +00:00
Arka Sharma
766c2466ff mmap map_at_zero test: handle W^X
Use kern.elfXX.allow_wx to decide whether to map W+X or W-only memory.

Future work could expand this test to add an "allow_wx" axis to the
test matrix, but I would argue that a separate test should be written,
since that's orthogonal to map_at_zero.

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2022-02-21 09:43:42 -06:00
Kristof Provost
7d3fc84b2d pf tests: Test per-anchor tables
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-02-17 14:13:50 +01:00
Kristof Provost
7f55a9b490 pf tests: remove a stray 'set -x'
'set -x' is very useful when debugging tests, but does not need to be
left in.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-02-17 13:40:41 +01:00
Kristof Provost
31566b98b8 vlan tests: fix bpf_pcp test
We now allow net.link.vlan.mtag_pcp to be set per-vnet, so we must set
it in the correct vnet, not on the host.
2022-02-15 07:53:30 +01:00
Kristof Provost
24360d8375 pf tests: Basic 'set prio' test
The ability to set VLAN PCP from pf was introduced in 3e248e0fb4, but
never had a test added.

Create a basic setup to set the PCP to an arbitrary value and use
tcpdump to check it's actually set.

MFC after:	1 week
2022-02-14 22:51:10 +01:00
Alan Somers
0b6a34acda [skip ci] fusefs: delete a stray comment from 91972cfcdd
MFC after:	3 days
2022-02-12 09:27:56 -07:00
John Baldwin
dba02df30d Cast pointer to uintptr_t to avoid alignment warnings.
Both struct ip and struct udphdr both have an aligment of 2, but the
cast from struct ip to a uint32_t pointer confused GCC 9 into raising
the required alignment to 4 and then raising a
-Waddress-of-packed-member error when casting to struct udphdr.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D31941
2022-02-11 16:04:52 -08:00
Mark Johnston
5de79eeddb ktls: Disallow transmitting empty frames outside of TLS 1.0/CBC mode
There was nothing preventing one from sending an empty fragment on an
arbitrary KTLS TX-enabled socket, but ktls_frame() asserts that this
could not happen.  Though the transmit path handles this case for TLS
1.0 with AES-CBC, we should be strict and allow empty fragments only in
modes where it is explicitly allowed.

Modify sosend_generic() to reject writes to a KTLS-enabled socket if the
number of data bytes is zero, so that userspace cannot trigger the
aforementioned assertion.

Add regression tests to exercise this case.

Reported by:	syzkaller
Reviewed by:	gallatin, jhb
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34195
2022-02-08 12:40:41 -05:00
Andrew Turner
31cf95cec7 Stop single stepping in signal handers on arm64
We should clear the single step flag when entering a signal hander and
set it when returning. This fixes the ptrace__PT_STEP_with_signal test.

While here add support for userspace to set the single step bit as on
x86. This can be used by userspace for self tracing.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34170
2022-02-07 15:03:23 +00:00
Dimitry Andric
c9cabf9aa6 Explicitly include semaphore.h for struct _sem in fusefs setattr test
In libc++'s __threading_support header the semaphore.h header was
implicitly included, but from version 14 onwards, this is no longer the
case, resulting in compile errors:

tests/sys/fs/fusefs/setattr.cc:740:8: error: variable has incomplete type 'sem_t' (aka '_sem')
        sem_t sem;
              ^
tests/sys/fs/fusefs/utils.hh:33:8: note: forward declaration of '_sem'
struct _sem;
       ^

MFC after:	3 days
2022-02-06 17:07:28 +01:00
Kristof Provost
34478b73bf pf tests: Only do post-test logging when specifically enabled
The pf tests have the ability to log state information (pf rules, pf
states, interfaces, ...) on exit (i.e. on success or on error).
This is useful, but only in specific cases. When it's not needed it may
get in the way of clear output.

Test scripts can add 'debug' to the pft_init call to enable this for the
specified test.

Reviewed by:	brd
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D34133
2022-02-05 10:31:51 +01:00
Kristof Provost
1094189965 pf tests: Test adding counters to an existing table
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D34132
2022-02-05 10:29:34 +01:00
Warner Losh
356deeb2e7 kyua/qemu: When running in qemu, don't teset sendfile
qemu's bsd-user doesn't implement sendfile, so just skip those tests
that use it.

Sponsored by:		Netflix
2022-02-02 14:27:51 -07:00
John Baldwin
978c7e2247 tests/sys/ses: Use ANSI C definition for has_ses.
This fixes -Wstrict-prototypes and -Wold-style-definition warnings
from GCC 9.
2022-02-01 13:25:47 -08:00
Mark Johnston
773e3a71b2 pf: Initialize pf_kpool mutexes earlier
There are some error paths in ioctl handlers that will call
pf_krule_free() before the rule's rpool.mtx field is initialized,
causing a panic with INVARIANTS enabled.

Fix the problem by introducing pf_krule_alloc() and initializing the
mutex there.  This does mean that the rule->krule and pool->kpool
conversion functions need to stop zeroing the input structure, but I
don't see a nicer way to handle this except perhaps by guarding the
mtx_destroy() with a mtx_initialized() check.

Constify some related functions while here and add a regression test
based on a syzkaller reproducer.

Reported by:	syzbot+77cd12872691d219c158@syzkaller.appspotmail.com
Reviewed by:	kp
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34115
2022-01-31 16:14:00 -05:00
Andrew Turner
548a2ec49b Add PT_GETREGSET
This adds the PT_GETREGSET and PT_SETREGSET ptrace types. These can be
used to access all the registers from a specified core dump note type.
The NT_PRSTATUS and NT_FPREGSET notes are initially supported. Other
machine-dependant types are expected to be added in the future.

The ptrace addr points to a struct iovec pointing at memory to hold the
registers along with its length. On success the length in the iovec is
updated to tell userspace the actual length the kernel wrote or, if the
base address is NULL, the length the kernel would have written.

Because the data field is an int the arguments are backwards when
compared to the Linux PTRACE_GETREGSET call.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19831
2022-01-27 11:40:34 +00:00
Kristof Provost
a95fcd81d5 netpfil tests: re-enable dummynet tests
These had been disabled due to panics with queued packets keeping
pointers (in m->m_pkthdr.rcvif) to removed interfaces.
This issue has been resolved in 165746f4e4, so the tests can be run
again.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-01-27 10:16:21 +01:00
Kristof Provost
74e6b014b4 netpfil tests: test removing interfaces with pending dummynet packets
Dummynet queues packets with an associated struct ifnet pointer. Ensure
that things do not explode if that interface goes away with packets
still in the queue.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33065
2022-01-27 09:36:09 +01:00
Gleb Smirnoff
929ff66ad3 tests/sys/net/routing: remove bandaid against old epair(4) panic 2022-01-26 21:58:43 -08:00
Gleb Smirnoff
942d05e3b8 tests/sys/net/epair: don't leak the interface after the test 2022-01-26 21:08:50 -08:00
Li-Wen Hsu
2c449a4c5a
Fix test of ses(4) when there is no SES device exists
glob(3) returns GLOB_NOMATCH if GLOB_NOCHECK or GLOB_NOMAGIC flag is not
passed so ATF_REQUIRE_EQ(r, 0) will cause a precondition check failure if no
/dev/ses* exists.

Remove calling of atf_tc_skip() in ATF_TC_CLEANUP() because it would let
the clean up procedure unfinish.

While here, fix a set-but-not-used warning.

Reviewed by:	asomers
Differential Revision:	https://reviews.freebsd.org/D34056
2022-01-27 07:11:17 +08:00
Kyle Evans
e5b431fc0c tests: add a basic test for argc == 0
The kernel should reject such exec()s now, early on. Instead of adding
the needed boilerplate to write a test in C, just add an -n argument for
"(n)ull argv" to the execve helper and exec this other helper that just
exits silently with argv count.

Reviewed by:	emaste, kib, markj (all previous version)
Differential Revision:	https://reviews.freebsd.org/D34045
2022-01-26 13:40:27 -06:00
Gleb Smirnoff
80fc25025f tests/net*: destroy interface from inside a jail
There is no guarentee that upon return of 'jail -r' all jail resources
will be released.  The test suite used to rely on that.  Recent changes
to the PCB zones made jails delay releasing their resources, which ended
with interface leak in the test suite.

Fix that by executing 'ifconfig foo0 destroy' inside the jail, instead
of doing 'jail -r' and expecting interfaces to pop up back immediately
in the parent jail.

Reviewed by:		kp
Differential revision:	https://reviews.freebsd.org/D33942
2022-01-24 21:08:03 -08:00