Commit Graph

2561 Commits

Author SHA1 Message Date
Mark Johnston 9d9fa9a2c2 unix: Fix handling of listening sockets during garbage collection
socantrcvmore() and unp_dispose() assume that the socket's socket
buffers are initialized, which isn't the case for listening sockets.

Reported by:	syzbot+a62883292a5c257703be@syzkaller.appspotmail.com
MFC after:	1 week
Reviewed by:	glebius
Differential Revision:	https://reviews.freebsd.org/D53743
2025-11-14 00:43:38 +00:00
Dag-Erling Smørgrav a34a57d4b4 tarfs: Fix support for large files
* When fast-forwarding through a zstd frame, we incorrectly used the
  min() inline function instead of the MIN() macro.  The function
  truncates the result to unsigned int, resulting in a decompression
  error when trying to seek more than 4 GB into the frame.

* POSIX states that a size extended header record overrides the size
  field in the header if present, and that one must be included if the
  size of the file exceeds 8 GB (the size field maxes out at 64 GB).

* Reduce repetition in the exthdr parser by deduplicating the syntax
  error handler.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Fixes:		69d94f4c76 ("Add tarfs, a filesystem backed by tarballs.")
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D53718
2025-11-12 22:24:43 +01:00
Dag-Erling Smørgrav fb99c0ba60 sound tests: Actually fix format strings
Fixes:		eb95b990f8 ("sound tests: Fix format specified for kevent.data")
2025-11-11 16:25:41 +01:00
Christos Margiolis eb95b990f8 sound tests: Fix format specified for kevent.data
Reported by:	CI
Fixes:		dd81b19ef2 ("sound tests: Test polling")
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2025-11-11 14:22:28 +01:00
Christos Margiolis 41f2ec3be9 sound tests: Fix select(2) arguments
Fixes:		dd81b19ef2 ("sound tests: Test polling")
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2025-11-11 13:23:58 +01:00
Christos Margiolis dd81b19ef2 sound tests: Test polling
Co-authored by:	meka@tilda.center
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D53188
2025-11-11 13:04:54 +01:00
Mark Johnston b3b279b801 multicast tests: Run in VNET jails
The tests themselves create identically named jails, resulting in
spurious failures when the tests are run in parallel.

MFC after:	1 week
2025-11-09 14:45:42 +00:00
Kyle Evans fa393807c5 fusefs: standardize on OPNOTSUPP for posix_fallocate(2)
POSIX Issue 7 had allowed EINVAL for this case, but issue 8 moves it
to ENOTSUP instead.  ZFS uses the latter and we have some software in
ports already that's wanting to use that to detect the filesystem not
supporting it, so let's standardize on it.

Reviewed by:	imp (previous version), asomers, kib
Differential Revision:	https://reviews.freebsd.org/D53535
2025-11-04 18:30:58 -06:00
Alan Somers e8449c0e0f fusefs: respect the server's FUSE_SETXATTR_EXT flag
FUSE protocol 7.33 extended the FUSE_SETXATTR request format.  But the
extension is optional.  The server must opt-in by setting the
FUSE_SETXATTR_IN flag during FUSE_INIT.  We were wrongly using the
extended format for any server using protocol 7.33 or later.

PR:		290547
Co-authored-by:	CismonX <admin@cismon.net>
Fixes:		d5e3cf41e8 ("fusefs: Upgrade FUSE protocol to version 7.33")
MFC after:	3 days
2025-11-03 10:14:35 -07:00
Kristof Provost 56d5ec30e8 pf tests: pfctl -T replace test
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-10-31 16:24:09 +01:00
Kajetan Staszkiewicz ee1f417a86 pf: Check if source nodes use a valid redirection address
Source nodes redirect (nat-to, rdr-to, route-to) all further connections
matching the rule which has created the source node. The source node is
valid as long as there are states resulting from the rule or until the
source node lifetime expires. When the rule's redirection pool is
modified (e.g. table contents are changed) the source node is still
valid and it will redirect new connections to invalid target (e.g. a
dead next-hop).

When performing source tracking after finding a source node check if the
redirection address still exists in pool of the rule which has created
this node. If not, delete the source node. This will result in finding a
new redirection address and creation of a new source node.

Reviewed by:	kp
Obtained from:	OpenBSD
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D53231
2025-10-30 19:32:52 +02:00
Kajetan Staszkiewicz 646798b678 pf: Make nat-to and rdr-to work properly both on in and out rules
New-style address translation is done by nat-to and rdr-to actions on
normal match and pass rules. Those rules, when used without address
translation, can be specified without direction. But that allows users
to specify pre-routing nat and post-routing rdr. This case is not
handled properly and causes pre-routing nat to modify destination
address, as if it was a rdr rule, and post-routing rdr to modify source
address, as if it was a nat rule.

Ensure that nat-to action modifies source address and rdr-to destination
address no matter in which direction the rule is applied. The man page
for pf.conf already specifies that nat-to and rdr-to rules should be
limited to respective directions.

PR:		288577
Reviewed by:	kp
MFC after:	3 days
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D53216
2025-10-30 19:32:21 +02:00
Kristof Provost faacc0d968 pf: improve add state validation
Both for the DIOCADDSTATE ioctl and for states imported through pfsync packets.
Add a test case to exercise this code path.

Reported by:	Ilja Van Sprundel <ivansprundel@ioactive.com>
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-10-30 09:42:27 +01:00
Kristof Provost 1da3c0ca5b pf: improve DIOCRCLRTABLES validation
Unterminated strings in the anchor or name could cause crashes.
Validate them, and add a test case.

Reported by:	Ilja Van Sprundel <ivansprundel@ioactive.com>
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-10-30 09:42:27 +01:00
Kristof Provost db0d002a21 pf tests: tftp-proxy test case
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-10-29 09:38:58 +01:00
Jose Luis Duran 99560fe98c pfctl: Do not warn if there is no Ethernet anchor
Avoid emitting a warning if there is no Ethernet anchor.  If the anchor
--regardless of its type-- is nonexistent, should be caught earlier.

This can be misleading when there is a layer 3 anchor but not an
Ethernet anchor, giving the user the impression that there is no layer 3
anchor with that name.

PR:		280516
Approved by:	kp
MFC after:	2 days
Differential Revision:	https://reviews.freebsd.org/D53360
2025-10-28 11:31:20 +00:00
Jose Luis Duran a943a96a50 libpfctl: Fix displaying deeply nested anchors
Set the number of rulesets (i.e., anchors) directly attached to the
anchor and its path in pfctl_get_ruleset().

While here, add a test to document this behavior.

PR:		290478
Reviewed by:	kp
Fixes:		041ce1d690 ("pfctl: recursively flush rules and tables")
MFC after:	2 days
Differential Revision:	https://reviews.freebsd.org/D53358
2025-10-28 11:29:19 +00:00
Alan Somers d86025c1d4 fusefs: Fix intermittency in the BadServer.ShortWrite test case
We were using the m_quit bit for two similar but distinct uses:

* To instruct the server to quit
* To cope with the kernel forcibly unmounting the fs

Fix the intermittent test failure by adding a separate bit,
m_expect_unmount, to handle cases like the latter.

Reported by:	Siva Mahadevan <me@svmhdvn.name>
MFC after:	1 week
Revied by:	Siva Mahadevan <me@svmhdvn.name>
Differential Revision: https://reviews.freebsd.org/D53357
2025-10-27 13:11:19 -06:00
John Baldwin 2fbb6e213a closefrom_test: Convert to atf-c(3)
Reviewed by:	ngie, markj
Differential Revision:	https://reviews.freebsd.org/D52800
2025-10-27 13:36:06 -04:00
Alan Somers 5d42c88139 fusefs: fix page fault triggered by async notification when unmounted
A FUSE daemon can send asynchronous notification to the kernel in order
to, for example, invalidate an inode's cache.  Fix a page fault that can
happen if the file system isn't yet mounted, or is already unmounted,
when that notification arrives.

PR:		290519
MFC after:	1 week
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D53356
2025-10-26 10:44:27 -06:00
John Baldwin b307799b51 closefrom_test: Fix the first test
The first test is supposed to close the new fd, but was instead not
closing anything.

Reviewed by:	ngie, markj
Fixes:		3cedbec3ee ("Integrate tools/regression/fifo into ...")
Differential Revision:	https://reviews.freebsd.org/D52799
2025-10-23 15:59:32 -04:00
Alan Somers 6d408ac490 fusefs: add a regression test for a cluster_read bug
VOP_BMAP is purely advisory.  If VOP_BMAP returns an error during
readahead, cluster_read should still succeed, because the actual data
was still read just fine.

Add a regression test for PR 264196, wherein cluster_read would fail if
VOP_BMAP did.

PR:		264196
MFC with:	62aef3f73f
Reported by:	danfe
Reviewed by:	arrowd
Differential Revision: https://reviews.freebsd.org/D51316
2025-10-23 07:40:56 -06:00
Mark Johnston 1dd66c6ac2 so_reuseport_lb_test: Add a test case for connected UDP sockets
Approved by:	so
2025-10-22 15:42:50 +00:00
Alan Somers 7648d2ebda tests/sys/netpfil/pf/sctp: make use of required.kmods
This greatly speeds up skipping a test that can't be run.

MFC after:	2 weeks
Sponsored by:	ConnectWise
Reviewed by:	kp
Differential Revision: https://reviews.freebsd.org/D53215
2025-10-21 13:46:26 -06:00
Kristof Provost cb36bfee25 pf: fix 'no rdr'
Ensure we always have a non-NULL rule pointer (ctx.rm).
It might have gotten set to NULL by pf_get_translation().

While here also restore the previous rdr behaviour be re-adding the incorrectly
removed 'break' in pf_match_translation_rule.

PR:		290177
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D53191
2025-10-19 23:07:43 +02:00
Brad Davis e868a20266 glabel: add a basic test
Reviewed by:	asomers
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D53178
2025-10-17 15:01:33 -06:00
Gleb Smirnoff 8596810d02 tests/carp: kill routed(8) before destroying interfaces
Otherwise routed logs a warning:

"MCAST_LEAVE_GROUP ALLROUTERS: Can't assign requested address"

that may be misinterpreted as a problem.
2025-10-15 11:55:25 -07:00
Gleb Smirnoff be7bdb1cf0 netinet: do route lookup when asked to join multicast group on ifindex 0
The code to do the route lookup was already there, but was used only for
the legacy IP_ADD_MEMBERSHIP when called without index.  Do same lookup
for IP_ADD_MEMBERSHIP with index and what is more important for
MCAST_JOIN_GROUP, if the supplied index is 0.  This is a neat feature and
Linux does that, so this should make a few applications easier portable to
FreeBSD.

Differential Revision:	https://reviews.freebsd.org/D52918
2025-10-15 11:54:57 -07:00
Gleb Smirnoff ead7219352 unix/stream: repair SO_SNDTIMEO
The send operations are waiting on the peer's socket buffer, but we shall
use our timeout value.  Provide a test for that.

Reported by:		phk
Reviewed by:		asomers
Differential Revision:	https://reviews.freebsd.org/D53081
Fixes:			d157927807
2025-10-14 17:29:31 -07:00
Gleb Smirnoff c8359b3271 tests/multicast: fix test flakyness
The receiver is run as a background job, so we need a wait loop to
make sure it has been fully functional before launching sender.

Reported by:	Siva Mahadevan <me svmhdvn.name>
PR:		290210
2025-10-14 16:43:15 -07:00
Alan Somers d1bd541b38 fusefs: fix intermittency in the BadServer.ShortWrite test
This test implicitly depended on the order in which two threads
completed.  If the test thread finished first, the test would pass.  But
if the mock file system thread did, it would attempt to read from an
unmounted file system, and fail.  As a result, the test would randomly
fail once out of every several thousand executions.  Fix it by telling
the mock file system's event loop to exit without attempting to read any
more events.

Reported by:	Siva Mahadevan <me@svmhdvn.name>
MFC after:	1 week
Reviewed by:	Siva Mahadevan <me@svmhdvn.name>
Differential Revision: https://reviews.freebsd.org/D53080
2025-10-14 08:46:54 -06:00
Nick Banks be1ad90e6b tcp: Initial ktest for HPTS
Reviewed by:		rrs, tuexen
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D52979
2025-10-13 21:47:31 +02:00
Chuck Silvers d5cfca008d mmap_test: determine page size at run time rather than compile time
Sponsored by:	Netflix
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D52735
2025-10-13 09:13:22 -07:00
Kristof Provost 1735d66a9c pf tests: verify checksum offload handling
Disable epair's checksum offload on one interface in a nat test, to ensure
that pf does the right thing in scenarios where one interface offloads checksum
handling and one does not.

We trust the TCP (or ICMP) checksum verification code to drop the packet if pf
does it wrong, which will cause the test case to fail.

Suggested by:	tuexen
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-10-11 13:24:25 +02:00
Kristof Provost 8a6bfa0455 pf tests: add missing atf_test_case lines for nat tests
The lack of these lines means we don't call the cleanup function.
That's not as bad as it could be, because these tests are nested in a jail by
Kyua, so most of the cleanup work (destroying jails and interfaces) is done when
the parent jail goes away, but it's still better to have these lines.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-10-11 13:24:25 +02:00
Kristof Provost 8217075f9e pf tests: give rules_counter:4G more time
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-10-11 13:24:24 +02:00
Kristof Provost c700393934 pf tests: give inetd some time to start
Give inetd time to start rather than immediately trying to connect to it.
Make the tests a little more robust.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-10-11 13:24:24 +02:00
Kristof Provost 98c1bf371c pf tests: make syncookie:loopback more robust
Give the background nc process a bit of time to start before we attempt to
connect to it.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-10-11 13:24:24 +02:00
Siva Mahadevan 79042fd7ed tests/mac_ipacl: restore sysctls after modification
While here, use 'required_kmods' instead of ad-hoc
checks.

Signed-off-by: Siva Mahadevan <me@svmhdvn.name>

Reviewed by:	markj
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Pull request:	https://github.com/freebsd/freebsd-src/pull/1856
2025-10-08 14:34:41 +00:00
Siva Mahadevan 170aac9347 tests/mac_portacl: restore sysctls after modification
While here, use 'required_kmods' instead of ad-hoc
checks.

Signed-off-by: Siva Mahadevan <me@svmhdvn.name>

Reviewed by:	markj
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1855
2025-10-08 14:34:09 +00:00
Olivier Cochard 2e09ec7241 tests/aio: Add support for larger max_buf_aio to vectored_big_iovcnt test
Fix a test failure that occurs when max_buf_aio exceeds 31, as the
calculated buffer size exceeds the 16 KB memory disk device. Increase
the MD device size to 1 MB to prevent truncation.

Rename MD_LEN to DEVICE_IO_LEN for clarity and add a more
descriptive error message.

Reviewed by:	asomers
Approved by:	asomers
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D52914
2025-10-07 23:56:23 +02:00
Gleb Smirnoff d9c94e5eef tests/netinet: fix so_reuseport_lb_test flakyness
Stop the threads before exiting test body.  Otherwise there is a chance
threads would use the softc that is stored on the main thread stack after
it is destroyed and the test would fail.  Stop the threads in the reverse
order, so that listener is stopped after all connectors are stopped.

Tested by:	olivier
2025-10-07 14:02:29 -07:00
Dag-Erling Smørgrav 1b0fce2944 tarfs: Simplify sameness checks
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D52928
2025-10-07 18:23:58 +02:00
Robert Clausecker acd546f01e */*: remove recallocarray() compat shims following import into libc
libopenbsd retains recallocarray() during bootstrapping for now
as it is needed for mandoc.

Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D52864
2025-10-03 19:47:52 +02:00
John Baldwin dfd7d1610a filedesc: Close race between fcntl(F_SETFL) and ioctl(FIONBIO/FIOASYNC)
- Use the recently-added fsetfl_lock/unlock API to synchronize direct
  FIONBIO and FIOASYNC ioctls with fcntl(F_SETFL).

- While here, skip calling the underlying ioctl if the flag's current
  state matches the requested state.

- Also while here, only update the flag state if the underlying ioctl
  succeeds.  This fixes a bug where the flags represented the new
  state even if the underlying ioctl failed.  A test is added for this
  last case that a failing FIOASYNC on /dev/null doesn't result in
  setting O_ASYNC in the file flags.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D52721
2025-10-03 12:43:30 -04:00
John Baldwin 5c331f449e fcntlflags_test: Port to atf-c(3)
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D52720
2025-10-03 12:43:18 -04:00
Olivier Cochard 01d5a6f30c tests/ipfw: Update regression tests to match new 32-bit size rule numbers
Commit 4a77657cbc increased the size of several opcodes to ipfw_insn_u32.

Approved by:	ae
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D52876
2025-10-03 13:06:49 +02:00
Kristof Provost b93394a38b pf: fix 'natpass'
If an rdr (or nat) rule specifies 'pass' we don't run the filter rules, we just
pass the traffic. Or at least, we did until that got unintentionally broken.
Restore that behaviour and add a test case.

While here also fix nat:dummynet_mask, which relied on the broken behaviour.

MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D52838
2025-10-02 22:46:43 +02:00
Ryan Libby 54b24b9da8 bitstring_test: fix bit_nclear/bit_nset tests for last iteration
Also convert nearby ATF_REQUIRE_MSG to ATF_REQUIRE_INTEQ_MSG.

Reported by:	GCC -Wint-in-bool-context
Reviewed by:	asomers, des
Differential Revision:	https://reviews.freebsd.org/D45893
2025-10-02 09:40:16 -07:00
Kristof Provost c23b64fba9 netinet6 tests: accept an RA on an interface without /64 address
Excercise the code introduced in 9e792f7ef7
("sys/netinet6: Fix SLAAC for interfaces with no /64 LL address").

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-10-02 15:33:17 +02:00