Commit graph

1886 commits

Author SHA1 Message Date
John Baldwin
7aee9d6c6d ktls CBC decrypt: Only increment iovec index when an entry is used
If an mbuf in the chain was skipped because it only contained bytes
from the header, the iovec index ('i') was incremented even though the
entry was not populated.  Only increment 'i' when an iovec entry is
consumed.

Add a new type of KTLS receive test which writes a single TLS record
via two separate write(2) calls over a TCP_NODELAY socket to trigger
a split in the mbuf chain in the kernel.  Test various split locations
including after the "plain" TLS header (5 bytes), after the full TLS
header, in the middle of the data payload, just before the start of
the trailer, and in the middle of the trailer.  These tests are also
run against all supported ciphers, not just CBC.  The 'header' test
for CBC ciphersuites was able to trigger the bug.

Approved by:	so
Security:	FreeBSD-SA-26:46.ktls
Security:	CVE-2026-49423
Sponsored by:	Chelsio Communications
2026-06-30 23:16:53 +02:00
Mark Johnston
92cf7227a1 posixshm: Fix handling of sendfile() with largepage objects
sendfile(2) can transmit POSIX shared memory objects.  Typically it will
look up and wire each page before sending it to a socket; once
transmission is complete, the page is unwired and typically released
back into the page queues.  sendfile() has an advisory flag, SF_NOCACHE,
which means, "try to free the page once transmission is complete."  This
is implemented in vm_page_release(), which expects to operate on managed
pages.

Pages belonging a largepage object are de-facto wired not explicitly so.
Thus, vm_page_release() will unwire and, having found no additional
references, free the page.  Because mappings of largepage objects are
unmanaged, userspace can still access the now freed page.

Fix the problem by explicitly wiring largepage pages.  Make the VM
object destructor responsible for unwiring and freeing them.

Add a regression test.

Approved by:	so
Security:	FreeBSD-SA-26:44.posixshm
Security:	CVE-2026-49427
Reported by:	Chris Jarrett-Davies <chrisjd@openai.com>
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D57832
2026-06-30 23:16:49 +02:00
Mark Johnston
9009c47d17 posixshm: Disallow truncation of largepage objects
We correctly handled ftruncate(), but not open(O_TRUNC).

Add a regression test.

Approved by:	so
Security:	FreeBSD-SA-26:44.posixshm
Security:	CVE-2026-49428
Reported by:	Chris Jarrett-Davies <chrisjd@openai.com>
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D57831
2026-06-30 23:16:46 +02:00
Mark Johnston
8038f63730 posixshm: Disallow fspacectl() on largepage objects
As with truncation, the operation isn't supported, but nothing prevented
it.

Add a regression test.

Approved by:	so
Security:	FreeBSD-SA-26:44.posixshm
Security:	CVE-2026-49428
Reported by:	Chris Jarrett-Davies <chrisjd@openai.com>
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D57830
2026-06-30 23:16:45 +02:00
Mark Johnston
2bafd2de76 unlinkat: Pass flags down to the work functions
The unlinkat(2) and funlinkat(2) system calls were ignoring
AT_RESOLVE_BENEATH.

Also pass pathseg through instead of assuming it's UIO_USERSPACE.

Add some tests which make sure that AT_RESOLVE_BENEATH is handled
properly by various system calls.

Approved by:	so
Security:	FreeBSD-SA-26:42.unlinkat
Security:	CVE-2026-49421
Reported by:	Yuxiang Yang, Yizhou Zhao, Ao Wang, Xuewei Feng, Qi Li, and Ke Xu from Tsinghua University using GLM-5.1 from Z.ai
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D57790
2026-06-30 23:16:42 +02:00
Mark Johnston
d058577e9b tests/libalias: Add a regression test for an alias_smedia bug
Approved by:	so
Security:	FreeBSD-SA-26:41.libalias
Security:	CVE-2026-49420
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D57747
2026-06-30 23:16:41 +02:00
Mark Johnston
3bb4da789a device_pager: Avoid double-insertion of pages into the pager list
Unmanaged device pager objects maintain a linked list of pages that were
returned from the fault handler.  Initially, such pages are valid, but
msync(MS_INVALIDATE) can mark them invalid (and clean).  They are not
removed from page tables (since they are unmanaged), but a subsequent
mlock() call can trigger a page fault that is handled by the pager.
dev_pager_getpages() then re-inserts the page into the linked list even
though it's already present there.

This patch fixes the problem by removing the linked list.  OBJ_PG_DTOR
is set, so vm_object_terminate_pages() does nothing, and
dev_pager_dealloc() instead handles cleanup of the object.

Add a regression test case which triggers a queue.h assertion failure in
unpatched kernels.

Note, in stable branches we should avoid changing the layout of struct
vm_object.

Approved by:	so
Security:	FreeBSD-SA-26:37.vm
Security:	CVE-2026-49418
Reported by:	slidybat
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D57743
2026-06-30 23:16:24 +02:00
Mark Johnston
515d4bcec6 imgact_elf: Clear no-ASLR and -WXORX flags earlier for setugid images
Otherwise an unprivileged user can disable randomization of the base
address for PIEs even if they are setugid.

Add a regression test.

Approved by:	so
Security:	FreeBSD-SA-26:32.elf
Security:	CVE-2026-49414
Reported by:	David Berard
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D57397
2026-06-10 08:45:22 +02:00
Mark Johnston
564070c417 sound: Fix software buffer lifetime issues
The channel buffer mapped by dsp_mmap_single() may be freed when the
device handle is closed, but the mapping persists beyond that, allowing
userspace to read or write memory owned by a different consumer.

Fix the problem by adding a reference counter to the sound buffer.
Define pager ops for the VM object returned by dsp_mmap_single() and use
them to manage the extra reference.

Add a regression test.

Approved by:	so
Security:	FreeBSD-SA-26:27.sound
Security:	CVE-2026-49417
Reported by:	Lexpl0it, 75Acol, Liyw979, Rob1n
Reviewed by	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D57393
2026-06-10 08:42:35 +02:00
Christos Margiolis
2845ed0a0e sound: Check for offset overflow in dsp_mmap_single()
Approved by:	so
Security:	FreeBSD-SA-26:27.sound
Security:	CVE-2026-45258
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
2026-06-10 08:42:33 +02:00
John Baldwin
b9ecbb4346 ktls: Don't attempt to modify non-anonymous mbufs on the receive path
Normally, data processed on the KTLS receive path is contained in
anonymous mbufs that can be modified in place.  Either the data
originates in receive buffers from a NIC driver, or for loopback
connections the data is anonymous-backed mbufs created when writing to
a socket.  One potential source of non-anonymous mbufs are mbufs
created by sendfile(2) which borrow the pages of the underlying file,
either via M_EXTPG or EXT_SFBUF that are sent over a loopback
connection.  For a well-formed loopback TLS session, the sender should
only use sendfile(2) if KTLS is enabled.  If TLS is fully handled in
userspace, the sender must use write(2) or send(2) which allocate
anonymous mbufs.  If KTLS transmit is enabled, then sendfile(2) on a
loopback connection will always use crypto via OCF and will allocate
anonymous pages to hold the encrypted data.

However, if sendfile(2) is used to send file-backed data directly over
a loopback connection where KTLS is not enabled on the sender side,
the KTLS receive path can modify the file-backed pages in place
overwriting the file's data.  One potential fix would be to replace
non-anonymous mbufs in a received TLS record with anonymous mbufs
(e.g. via m_dup()) before passing the record to OCF.  However, there
is no legitimate use case for using sendfile(2) over a loopback TLS
connection without using KTLS on the sender side, so instead simply
fail decryption requests and close the connection if non-anonymous
mbufs are encountered in the RX decryption path.

Add a test for this that verifies that the original data backing the
file descriptor used as the source for sendfile() is unchanged after
being processed.

Approved by:	so
Security:	FreeBSD-SA-26:26.ktls
Security:	CVE-2026-45257
Co-authored-by:	Drew Gallatin <gallatin@FreeBSD.org>
Sponsored by:	Chelsio Communications
Sponsored by:	Netflix
2026-06-10 08:42:32 +02:00
Andrey V. Elsukov
119b20a90f ipfw: treat ipv6 address with zero mask as 'any'
Make the behaviour similar for both IPv4 and IPv6. Also add
the corresponding tests.

PR:             294733
Differential Revision:	https://reviews.freebsd.org/D56618

(cherry picked from commit 2872268c7f6d473aae9b02ebb5d2c24fc2cff9b1)
2026-06-08 15:34:14 +02:00
Kristof Provost
4d0636d61d pf: do not reject rules with colliding hashes
We insert rules in pf_krule_global solely for the benefit of the
'keepcounters' feature. Failing to insert (beause the rule hash
collides, or an identical rule already exists) would be worse than
restoring counts to the wrong rule (or failing to restore them at all).

PR:		282863, 294860, 294859, 294858
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D56745

(cherry picked from commit a0e4c65f1814a7a677364dc29bb703f84323d175)
2026-06-02 07:33:28 +02:00
Vyacheslav Terehov
15be895f78 ipfw: fix parsing error in nat config port_range
Also fix the corresponding tests.

PR:		263240
Differential Revision:	https://reviews.freebsd.org/D57010

(cherry picked from commit 6eba055fcf5b0bbfbebcac59f5982d13815001b0)
2026-06-02 07:25:48 +02:00
Mark Johnston
ed2557cfa3 ptrace: Fix validation of PT_SC_REMOTE arguments
- Fix an off-by-one in the system call number check.  A value of
  SYS_MAXSYSCALL was permitted.
- Validate the system call number after we've dealt with
  syscall(2)/__syscall(2), since they pass the syscall number as an
  argument.
- When the syscall number is for syscall(2) or __syscall(2), we must
  make sure that nargs > 0 to avoid an underflow when shifting arguments
  down.

Add regression tests.

Approved by:	so
Security:	FreeBSD-SA-26:21.ptrace
Security:	CVE-2026-45253
Fixes:		140ceb5d95 ("ptrace(2): add PT_SC_REMOTE remote syscall request")
Reported by:	Yuxiang Yang, Yizhou Zhao, Ao Wang, Xuewei Feng, Qi Li, and Ke Xu from Tsinghua University using GLM-5.1 from Z.ai
Reviewed by:	kib, emaste
Differential Revision:	https://reviews.freebsd.org/D56978
2026-05-21 07:32:54 +02:00
Alan Somers
77b65f9135 fusefs: Handle buggy servers' LISTXATTR response
The fuse protocol requires server to respond to LISTXATTR with a
NUL-terminated string.  If they don't, report an error rather than
attempt to scan through uninitialized memory for a NUL.

Approved by:	so
Security:	FreeBSD-SA-26:20.fusefs
Security:	CVE-2026-45252
admbugs:	1039
Reported by:	Joshua Rogers
Sponsored by:	ConnectWise
2026-05-21 07:32:52 +02:00
Mark Johnston
c121cc691e procdesc: Make sure to drain selinfo sleepers in procdesc_free()
Otherwise they are left on a freed list after procdesc_free() is called.
This can be exploited to elevate privileges.

Remove the PDF_SELECTED micro-optimization.  doselwakeup() is a no-op if
no one ever called selrecord() on the file description, so I see no
reason to complicate the code to avoid the call.

Add some regression tests.

Approved by:	so
Security:	FreeBSD-SA-26:19.file
Security:	CVE-2026-45251
Reported by:	75Acol, Lexpl0it, fcgboy, and robinzeng2015
Reviewed by:	kib, oshogbo
Fixes:		cfb5f76865 ("Add experimental support for process descriptors")
Differential Revision:	https://reviews.freebsd.org/D56887
2026-05-21 07:32:50 +02:00
Kristof Provost
6b092a943c pf: fix duplicate rule detection for automatic tables
We should look at the table name for automatic tables as well. These
are different tables, so the rules using them are (or can be) different
as well.

MFC after:	3 days
Reported by:	Michael Sinatra <michael@burnttofu.net>
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit fb838352751767e756bd45cd2040fa464ed4de20)
2026-04-30 07:39:19 +02:00
Kristof Provost
920990c75a pf: improve SCTP validation
As per RFC5061 "4.2.  New Parameter Types" the add/delete IP address
parameters (0xc001, 0xc002) may not be present in an INIT or INIT-ACK
chunk. They are only allowed to be present in an ASCONF chunk.

This also prevents unbounded recursion while parsing an SCTP packet.

Approved by:	so
Security:	FreeBSD-SA-26:14.pf
Security:	CVE-2026-7164
PR:		294799
Reported by:	Igor Gabriel Sousa e Souza
MFC after:	3 days
Sponsored by:	Orange Business Services
2026-04-30 06:53:59 +02:00
Mark Johnston
53a2985c43 pkru: Fix handling of 1GB largepage mappings
pmap_pkru_update_range() did not handle the case where a PDPE has PG_PS
set.  More generally, the SET_PKRU and CLEAR_PKRU sysarch
implementations did not check whether the request covers a "boundary" vm
map entry.  Fix this, add the missing PG_PS test, and add some tests.

Approved by:	so
Security:	FreeBSD-SA-26:11.amd64
Security:	CVE-2026-6386
Reported by:	Nicholas Carlini <npc@anthropic.com>
Reviewed by:	kib, alc
Differential Revision:	https://reviews.freebsd.org/D56184
2026-04-29 22:12:56 +02:00
Mark Johnston
e1ed334011 tty: Avoid leaving dangling pointers in tty_drop_ctty()
The TIOCNOTTY handler detaches the calling process from its controlling
terminal.  It clears the link from the session to the tty, but not the
pointers from the tty to the session and process group.  This means that
sess_release() doesn't call tty_rel_sess(), and that pgdelete() doesn't
call tty_rel_pgrp(), so the pointers are left dangling.

Fix this by clearing pointers in tty_drop_ctty().  Add a standalone
regression test.

Approved by:	so
Security:	FreeBSD-SA-26:10.tty
Security:	CVE-2026-5398
Reported by:	Nicholas Carlini <npc@anthropic.com>
Reviewed by:	kib, kevans
Fixes:		1b50b999f9 ("tty: implement TIOCNOTTY")
Differential Revision:	https://reviews.freebsd.org/D56046
2026-04-29 22:12:55 +02:00
Kristof Provost
9b77f8cc18 pf tests: verify that we handle address range rules correctly
There's been a problem where rules which differed only in address ranges
were considered duplicates and not added. Test for this.

Approved by:	so
Security:	FreeBSD-SA-26:09.pf
Security:	CVE-2026-4748
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit ab74151e8d097b263237942c0b12277098bc9533)
(cherry picked from commit 958dbc87e9c59a2e9f83d84115ce03fb96e9b249)
2026-03-26 08:04:50 +01:00
Mark Johnston
3f73e4146d unix/tests: Add a regression test for fd transfer across jails
Approved by:	so
MFC after:	3 weeks

(cherry picked from commit 5843b8ee02)
(cherry picked from commit ac2279ea57b72d688cf0af5a6fa7f5dbd1d4521b)
2026-02-24 19:22:12 +01:00
Kristof Provost
78c3994ec7 if_ovpn: add interface counters
Count input/output packets and bytes on the interface as well, not just
in openvpn-specific counters.

PR:		292464
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 21d666a19331f31fb6dfa1e370de5a84a1a5cb46)
2026-02-18 13:03:31 +01:00
Mark Johnston
163ae89560 tests: Add a regression test for commit 7587f6d484
Approved by:	so
Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D50533

(cherry picked from commit a5dac34f6e)
(cherry picked from commit f56b66f1260a33e49c65bbc05213ec8267978a93)
2026-01-28 07:36:32 +01:00
Kristof Provost
561bb82223 pf: relax sctp v_tag verification
pf was too strict when validating SCTP tags. When a server receives a
retransmitted INIT it will reply with a random initiate tag every time.
However, pf saves the first initiate tag and expects every subsequent INIT_ACK
retransmission to have the same tag. This is not the case, leading to endless
INIT/INIT_ACK cycles.

Allow the tag to be updated as long as we've not gone past COOKIE_WAIT.

Add a test case to verify this.

MFC after:	2 weeks
See also:	https://redmine.pfsense.org/issues/16516
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit bc3b72ff48953551e0e8bd6e5a2c718ecd973285)
2025-12-17 08:00:53 +01:00
Kristof Provost
abdb9fc652 pf: handle divert packets
In a divert setup pf_test_state() may return PF_PASS, but not set the state
pointer. We didn't handle that, and as a result crashed immediately afterwards
trying to dereference that NULL state pointer.

Add a test case to provoke the problem.

PR:		260867
MFC after:	2 weeks
Submitted by:	Phil Budne <phil.budne@gmail.com>
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 66f2f1c83247f05a3a599d7e88c7e7efbedd16b5)
2025-12-03 11:32:11 +01:00
Alan Somers
f46cda60e3 tests/sys/netpfil/pf/sctp: make use of required.kmods
This greatly speeds up skipping a test that can't be run.

Sponsored by:	ConnectWise
Reviewed by:	kp
Differential Revision: https://reviews.freebsd.org/D53215

(cherry picked from commit 7648d2ebda22fe21ed385cc7d76813a1a9c17c99)
2025-11-24 08:36:02 +01:00
Kristof Provost
b7c3332cf8 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")

(cherry picked from commit faacc0d968816cf8714c974b6d8df6191cfb0e0d)
2025-11-20 12:18:05 -05:00
Kristof Provost
61338a007c 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")

(cherry picked from commit 1da3c0ca5b1decaa9cf55859cd134bdcd1218116)
2025-11-20 12:17:23 -05:00
Mark Johnston
063c85a7bf so_reuseport_lb_test: Add a test case for connected UDP sockets
Approved by:	so

(cherry picked from commit 1dd66c6ac2c146f540b2ff825fbee442354aeee5)
(cherry picked from commit 7272e2d029c20c3144d7aa49500dc86d70344030)
2025-10-23 08:09:21 +02:00
Dag-Erling Smørgrav
84a5cebd36 atf, kyua: Implement require.kmods.
This adds a metadata variable, require.kmods, and corresponding functions
or methods in C, C++, and shell, which allow a test to specify that it
requires particular kernel modules to run.  If the kernel modules are not
present, the test is skipped.  One might want to consider a kyua option
which makes it attempt to load the modules instead.

Differential Revision:	https://reviews.freebsd.org/D47470

(cherry picked from commit 83a1ee578c)
2025-10-07 12:08:43 +02:00
Kristof Provost
5631736429 if_ovpn: support IPv6 link-local addresses
MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D51596

(cherry picked from commit 60e92d17cf)
2025-09-08 10:20:17 +02:00
Lexi Winter
2e20b10703 ifconfig: Support VLAN ID in static/deladdr
Add an optional "vlan <n>" argument to the bridge static and deladdr
commands to allow addresses to be added to / removed from a particular
vlan.  No changes to if_bridge are required as the kernel API already
supports this, it just wasn't exposed in ifconfig.

Add tests for the new functionality, and improve the test for the
existing "static" command.

Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D51243

(cherry picked from commit 3650722abf)
2025-08-26 10:27:25 +02:00
Kristof Provost
bd2b9dbb4b pf tests: sync a state with an rtableid that doesn't exist
Create a state with an rtableid (i.e. fib) that doesn't exist on the receiving
side. This used to not be handled, and could provoke panics. Create such a
situation to ensure we still don't panic.

PR:		287981
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit f651e87be2)
2025-07-21 08:36:25 +02:00
Kristof Provost
b2c54d0714 pf: limit extra SCTP states
For SCTP we create states for all combinations of endpoints, to allow multihoming to work.
Malicious users could abuse this to fill our state table more easily
than they otherwise could, because we create states between all
combinations of endpoints. Limit this to no more than 8 extra endpoints
for each side of the connection.

MFC after:	2 weeks
Sponsored by:	Orange Business Services

(cherry picked from commit cd0169c937)
2025-07-10 09:40:58 +02:00
Lexi Winter
574cdcf929 bridge: fix vlan(4) on a bridge member
If an interface is a bridge member, and a vlan(4) is also created on
that interface, and net.link.bridge.member_ifaddrs=0, then vlan(4)
will never see any incoming frames because bridge doesn't pass them
to the host for processing.

Work around this by checking for locally-addressed frames using the
MAC address of the interface we received the frame on, but only if
the frame has a .1q tag and there's a vlan trunk on the interface.

This behaviour is almost certainly "wrong" and it's not clear if we
really want to support this, but it did work in the past and the
member_ifaddrs change was not supposed to break it, so this restores
the previous behaviour.

PR:	287150
MFC after:	1 week
Reviewed by:	kevans, des
Approved by:	kevans (mentor), des (mentor)
Differential Revision:	https://reviews.freebsd.org/D50623

(cherry picked from commit a5fe142e08)
2025-07-09 10:05:43 +02:00
Lexi Winter
cd5b92eb56 bridge: allow IP addresses on members to be disabled
add a new sysctl, net.link.bridge.member_ifaddrs, which defaults to 1.

if it is set to 1, bridge behaviour is unchanged.

if it is set to 0:

- an interface which has AF_INET6 or AF_INET addresses assigned cannot
  be added to a bridge.
- an interface in a bridge cannot have an AF_INET6 or AF_INET address
  assigned to it.
- the bridge will no longer consider the lladdrs on bridge members to be
  local addresses, i.e. frames sent to member lladdrs will not be
  processed by the host.

update bridge.4 to document this behaviour, as well as the existing
recommendation that IP addresses should not be configured on bridge
members anyway, even if it currently partially works.

in testing, setting this to 0 on a bridge with 50 member interfaces
improved throughput by 22% (4.61Gb/s -> 5.67Gb/s) across two member
epairs due to eliding the bridge member list walk in GRAB_OUR_PACKETS.

Reviewed by:	kp, des
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D49995

(cherry picked from commit 0a1294f6c6)
2025-07-09 10:05:41 +02:00
Olivier Certner
4826471026
queue(3): Add simple tests for some macros for all list/tailq types
These essentially test building a list/tailq of 100 elements with
_INSERT_HEAD(), iterating over them with _FOREACH(), splitting it with
_SPLIT_AFTER() and concatenating back the results with _CONCAT(),
checking that the lists/tailqs at each step have the right number of
elements and at the expected positions.

Reviewed by:    markj
MFC after:      2 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D49975

(cherry picked from commit 4fa275a5f3)
2025-05-01 21:48:48 +02:00
Alan Somers
f390c81498 fusefs: slightly better debugging in the tests
If the kernel rejects a response written by the server, print it.  That
would most likely be due to an error in the test logic.

MFC after:	2 weeks
Sponsored by:	ConnectWise

(cherry picked from commit 564c732b5c)

fusefs: fix the 32-bit build after 564c732b5c

It's a  printf format specifier again.

MFC with:	564c732b5c
Sponsored by:	ConnectWise

(cherry picked from commit 52f7eb31ae)
2025-04-17 14:14:58 -06:00
Alan Somers
1c316af141 fusefs: add a test for the max_read= mount option
When set, this limits the amount of data that the kernel will request of
the server in any single read operation.  The option has always been
available in our fusefs implementation, but never covered by the test
suite.

MFC after:	2 weeks
Sponsored by:	ConnectWise

(cherry picked from commit 9f31c47460)
2025-04-17 14:14:58 -06:00
Alan Somers
d03aa29b82 fusefs: minor refactor in the tests
Do more work in MockFS's constructor's member initializer list, instead
of the body of the constructor.  It's easier to read this way.

Sponsored by:	ConnectWise

(cherry picked from commit 3f83f32d7d)
2025-04-17 14:14:57 -06:00
Kristof Provost
0da1817868 pfctl: fix recursive printing of NAT rules
pfctl_show_nat() is called recursively to print nat anchors. This passes the
anchor path, but this path was modified by pfctl_show_nat(), leading to issues
printing the anchors.

Make a copy of the path ('npath') before we modify it. Ensure we do this
correctly by sprinking in 'const', and add a test case to verify that we do now
print things correctly.

Reported by:	Thomas Pasqualini <thomas.pasqualini@orange.com>
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 58164dcb55)
2025-04-16 09:34:56 +02:00
Kristof Provost
1463d5ff13 if_ovpn: fix use-after-free of mbuf
m_unshare() can return a new mbuf pointer. We update the 'm' pointer in
ovpn_udp_input(), but if we decide to pass on the packet (e.g. because it's for
an unknown peer) the caller (udp_append()) continues with the old 'm' pointer,
eventually resulting in a use-after-free.

Re-order operations in ovpn_udp_input() so that we don't modify the 'm' pointer
until we're committed to keeping the packet.

PR:		283426
Test case by:	takahiro.kurosawa@gmail.com
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 04a7134c1e)
2025-04-15 09:27:09 +02:00
Konstantin Belousov
ca3222c4fc ptrace_test: add test for expanded reporting of syscall args
(cherry picked from commit 526becbf6e)
2025-04-07 04:28:23 +03:00
Mark Johnston
ba224cec67 fibs tests: Fix test failures and simplify
The tests previously expected the invoker to pass a list of FIBs to use.
However, they now run in separate VNET jails, so we can simply expand
the FIB array as needed in each test.  Modify each test to simply set
net.fibs as needed and grab FIB numbers starting at 1.

A number of tests were also broken by commit 9206c79961
("usr.bin/netstat: -n should not print symbolic names"), so fix those.

Reviewed by:	asomers
Fixes:		9206c79961 ("usr.bin/netstat: -n should not print symbolic names")
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D48585

(cherry picked from commit 81b076e43a)

Note, the netstat-related changes described above are not merged.
2025-04-06 18:08:18 +00:00
Vincenzo Maffione
984e3d813e netmap: fix unit tests
After ad874544d9, interface name
validation has been removed, resulting in two unit tests failures.
Drop the failing tests since they no longer apply.

Reported by:	markj

(cherry picked from commit ee5804da11)
2025-04-06 18:05:05 +00:00
Christos Margiolis
1728d26682 sound: Implement AFMT_FLOAT support
Even though the OSS manual [1] advises against using AFMT_FLOAT, there
are applications that expect the sound driver to support it, and might
not work properly without it.

This patch adds AFMT_F32_LE|BE (as well as AFMT_FLOAT for OSS
compatibility) in sys/soundcard.h and implements AFMT_F32_LE|BE <->
AFMT_S32_LE|BE conversion functions. As a result, applications can
write/read floats to/from sound(4), but internally, because sound(4)
works with integers, we convert floating point samples to integer ones,
before doing any processing.

The reason for encoding/decoding IEEE754s manually, instead of using
fpu_kern(9), is that fpu_kern(9) is not supported by all architectures,
and also introduces significant overhead.

The IEEE754 encoding/decoding implementation has been written by Ariff
Abdullah [2].

[1] http://manuals.opensound.com/developer/AFMT_FLOAT.html
[2] https://people.freebsd.org/~ariff/utils/ieee754.c

PR:		157050, 184380, 264973, 280612, 281390
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D47638

(cherry picked from commit e1bbaa71d6)
2025-04-06 02:28:14 +02:00
Kristof Provost
7fa5f4995f pf tests: test table information export via snmp_pf
Event:		Tokyo Hackathon 202503
(cherry picked from commit 3658680080)
2025-04-03 18:41:25 +02:00
Kristof Provost
3410b98ce2 pf tests: add a basic snmp_pf test case
Event:		Tokyo Hackathon 202503
(cherry picked from commit c849f53332)
2025-04-03 18:41:25 +02:00