Commit Graph
312423 Commits
Author SHA1 Message Date
Konstantin Belousov 5f82dd8e91 capsicum: add CAP_PTRACE
The capability will allow the ptrace(2) on the procdesc.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58586
2026-08-28 14:52:31 +03:00
Konstantin Belousov 8c911d9a98 kern/kern_descrip.c: export filecaps_fill()
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D58094
2026-08-28 14:52:31 +03:00
Mark Johnston 44b83210c8 unix: Fix a socket leak
When connecting a unix domain stream socket, we
1. look up the peer (listening) socket,
2. allocate a new socket
3. add the new socket to the listening socket's queue

Prior to commit 26147c5154, this sequence of operations was
synchronized by a pool mutex, also acquired in uipc_close().

After commit 26147c5154, we drop the vnode pool lock immediately after
finding the peer socket via a filesystem lookup.  This creates a window
where it's possible for a connection to add a new socket to the
listening queue after the listening queue has been aborted.

Fix the race by restoring the old behaviour of holding the pool lock
across the solisten_enqueue() call.  This is a bit ugly since we need to
pass a mutex lock and a vnode through a couple of layers, but it seems
like a low-risk solution.  Alternately we could add some flag to the
listening socket which indicates that no new connections are to be
accepted, but I think this will require some changes to the generic
socket code.

Reported by:	pho
Fixes:		26147c5154 ("unix: pin the pathname peer by reference across the connect")
Reviewed by:	olce, kib, John Ericson <[email protected]>
Differential Revision:	https://reviews.freebsd.org/D59201
2026-08-28 11:10:22 +00:00
Jesús Daniel Colmenares Oviedo 2c68ad49f1 nullfs: Allow VSOCK to be mounted on top of another VSOCK
In the world of containers, mounting a unix(4) socket is a common
practice to allow communication between processes within containers.
For example, both Podman and Docker can expose a unix(4) socket,
and that same unix(4) socket can be mounted as a file accessible
to a process inside a container, allowing that application to control
Podman or Docker. Another example is PHP-FPM with NGINX, where,
instead of using TCP/IP for communication between containers, a
unix(4) socket is sufficient.

However, nullfs(4) and all related components do not allow mounting
a VSOCK on top of another. The current workaround involves creating
the socket in a directory and mounting that directory. This is an
option, though it does not provide a good user experience compared
to directly mounting a VSOCK on top of another, since the application
that creates the socket may create other sockets in that directory,
and the user may not wish to share them, or, worse yet, applications
that create unix(4) sockets may not provide any authentication at
all, as they may assume that security at the file system level is
sufficient.

Reviewed by:		dfr@
Approved by:		dfr@
Relnotes:		yes
Differential Revision:  https://reviews.freebsd.org/D59158
2026-08-28 01:12:46 -04:00
Mark Johnston c869a36fc9 rangelock: Fix format strings for 32-bit kernels
Reported by:	Jenkins
Fixes:		f1f58bdf7b ("acpi_pci: Honor device proximity for DMA tags")
2026-08-28 01:26:04 +00:00
Devin Teske 14df6e1e68 fortune: fall back to all databases if fortunes is missing
With no file argument, fortune looks for a database named fortunes
in FORTDIR. The base system has not shipped that file since
0538d7bbe6 (FreeBSD 12), only freebsd-tips, so the default
invocation failed even though a valid database remained. Callers
such as xlockmore's marquee and nose modes (fortune -s) then
displayed the error as the epigram.

If the named fortunes file is absent, scan every database in the
existing search path. /usr/local/share/games/fortune stays on that
path so fortune-mod-* packages keep working; when
fortune-mod-freebsd-classic restores the fortunes file, it is still
preferred. fortune -f with no arguments lists the same files that
would be searched.

MFC after:	1 week

Reviewed by:	ziaee, fuz
Differential Revision:	https://reviews.freebsd.org/D59057
2026-08-27 17:57:53 -07:00
Mark Johnston 2e376cca37 rangelock: Reimplement _rangelock_cookie_assert()
After rangelocks were reimplemented, _rangelock_cookie_assert() became a
stub.  Re-provide an implementation.

Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D59222
2026-08-27 23:29:40 +00:00
Kevin Bowling f1f58bdf7b acpi_pci: Honor device proximity for DMA tags
A PCI function with its own _PXM still inherits a DMA tag carrying
the upstream bridge's proximity domain. Resolving an SR-IOV VF's
locality through its PF therefore does not affect the domain used for
DMA allocations.

Create and cache a private child tag when the function, or a VF's
owning PF, has an explicit _PXM. Parent it to the existing PCI or IOMMU
tag so its constraints remain intact, then apply the function's domain
without mutating a shared tag.

pci_get_dma_tag() already performs the IOMMU lookup, so remove the
duplicated lookup in the ACPI subclass while here.

Reviewed by:	jhb
MFC after:	2 weeks
Sponsored by:	BBOX.io
Differential Revision:	https://reviews.freebsd.org/D59063
2026-08-27 15:51:10 -07:00
Kevin Bowling 5f78d02469 acpi_pci: Cache PCI proximity domains
A PCI function's _PXM is stable for the lifetime of its device
instance, but CPU and DMA locality queries may evaluate it repeatedly.
SR-IOV amplifies this because every VF resolves locality through the
same PF.

Cache successful mappings and the stable absence of _PXM on the
locality source device, and share that result between CPU and domain
queries. Continue to retry generic evaluation or mapping errors rather
than making a potentially transient failure permanent.

Reviewed by:	jhb
MFC after:	2 weeks
Sponsored by:	BBOX.io
Differential Revision:	https://reviews.freebsd.org/D59207
2026-08-27 15:49:56 -07:00
Kevin Bowling dc4f80da18 acpi_pci: Preserve CPU locality queries for descendants
bus_generic_get_cpus() preserves the original leaf device while
forwarding a request through the bus hierarchy. Consequently,
acpi_pci_get_cpus() may receive a descendant below a PCI function
rather than one of the PCI bus's direct children.

Only apply the SR-IOV PF-locality mapping to direct PCI children.
Preserve the previous ACPI CPU-locality lookup for descendants so their
unrelated bus ivars are not interpreted as PCI device information.

Reviewed by:	jhb
MFC after:	2 weeks
Sponsored by:	BBOX.io
Differential Revision:	https://reviews.freebsd.org/D59206
2026-08-27 15:48:47 -07:00
Abdelkader Boudih 51c30180ea video: bump __FreeBSD_version for V4L2 cropping and overlay symbols
Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D59208
2026-08-27 20:04:47 +01:00
Abdelkader Boudih d5016a8204 video: add V4L2 cropping, control menu and overlay symbols
Adds missing structs symbols for V4L2.

video(4) capture devices do not crop, expose menu controls or support
overlay, and return ENOTTY for the new ioctls.
Applications enumerate these unconditionally and degrade gracefully
at run time, but fail to build when the declarations are missing.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D59203
2026-08-27 20:04:47 +01:00
Ryan Campbell fef9077cf8 netipsec: Implement pr_disconnect for PF_KEY sockets
Otherwise close() fails.

PR:		297977
Reviewed by:	glebius
Fixes:		ea7be1293b ("keysock: do not use raw socket code")
MFC after:	1 week
2026-08-27 18:33:58 +00:00
Alexander Leidinger 8f0789bee7 hwpmc tests: the sampling log file
Nine ATF cases covering PMC_OP_CONFIGURELOG and the descriptor-less
log operations: which descriptors are accepted, when a log is required
in the first place, and what the log operations do without one.

MFC after:	1 month
MFC to:		stable/15
MFC to:		stable/14
Assisted-by:	Claude Code (Opus 5)
2026-08-27 16:02:48 +02:00
Alexander Leidinger bea7b932b9 hwpmc: add credential-transition exec tests (keep and drop)
The companion to pmc_exec_test.c, which covers only the drop side of a
credential-changing exec.  Three cases cover what the drop must not
overreach into: an exec that changes no credentials keeps the PMC, a
set-id exec whose credential change the kernel suppresses for a traced
target keeps it too, and a set-id fexecve(2) drops it.  They exercise
the permission logic FreeBSD-SA-26:56.hwpmc reworked, not the defect
it fixed.

All three pass on a debug (INVARIANTS+WITNESS) kernel.  The two
keep-cases were each observed to fail on a kernel mutated to detach
unconditionally.

MFC after:	1 month
MFC to:		stable/15
MFC to:		stable/14
Assisted-by:	Claude Code (Opus 4.8)
2026-08-27 16:02:45 +02:00
Alexander Leidinger d00da14532 hwpmc tests: process-attachment lifecycle and ownership cases
Seven ATF cases covering process-attachment teardown orderings: a
target that exits before it is detached, the owner that exits before
its target (hwpmc's other unlink path), releasing a still-running
attached PMC, row exhaustion with out-of-order release, and
PMC_F_DESCENDANTS inheritance including a fork storm.

All pass on a debug (INVARIANTS+WITNESS) and a KASAN kernel.

MFC after:	1 month
MFC to:		stable/15
MFC to:		stable/14
Assisted-by:	Claude Code (Opus 5)
2026-08-27 16:02:42 +02:00
Alexander Leidinger 17fca802de hwpmc: add tests for handle validation and the privilege boundaries
A pmc_id_t is a packed integer that the driver hands to userland and
accepts back on eleven operations, and nothing tested what happens when
one comes back forged, stale, or belonging to another process.  Neither
was there a test that an unprivileged caller is refused the operations
that need a privilege.

The cases use a SOFT-class PMC wherever the counter itself does not
matter, so they run on a machine with no PMU.

MFC after:	1 month
MFC to:		stable/15
MFC to:		stable/14
Assisted-by:	Claude Code (Opus 5)
2026-08-27 16:02:39 +02:00
Alexander Leidinger 068957e040 hwpmc: add regression tests for a credential-changing exec
This tests what FreeBSD-SA-26:56.hwpmc fixed.

exec_setgid_drops_pmc asserts the kernel takes a process-mode PMC away
when its target execs a set-gid program its owner is not entitled to
trace.

exec_setuid_no_double_unlink lets the target exec a set-uid program;
the teardown must unlink the process descriptor exactly once, and
completing at all is the assertion.

Both need an unprivileged owner and must not drop privileges themselves,
since p_candebug() would then refuse the target to its own owner; they
ask for require.user instead.

MFC after:	1 month
MFC to:		stable/15
MFC to:		stable/14
Assisted-by:	Claude Code (Opus 5)
2026-08-27 16:02:36 +02:00
Alexander Leidinger df537ff152 hwpmc tests: sort the list of test programs
MFC after:	1 month
MFC to:		stable/15
MFC to:		stable/14
2026-08-27 16:02:18 +02:00
Mark Johnston d6f5c6531e netmap: Use ckdint.h helpers to check for overflow
This addresses a bug in the addition overflow check added in commit
319414a926 ("netmap: Handle overflow when computing ring sizes"): that
overflow wasn't actually caught by the check because "len" is promoted
to size_t.

PR:		297300
Fixes:		319414a926 ("netmap: Handle overflow when computing ring sizes")
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D58896
2026-08-27 13:33:10 +00:00
Mark Johnston 00a793def7 pf: Fix fallout from the STATE_LOOKUP macro removal
Commit 8572367b68 ("pf: remove STATE_LOOKUP") introduced two seemingly
unintentional changes with respect to divert(4)-injected packets (i.e.,
the PACKET_LOOPED case): we no longer return the matching state, and
direct callers of pf_find_state() now treat matches of diverted packets
the same as having no matching state at all.

This seems inadvertent, and breaks certain rulesets which use divert-to.
Fix them, and add a regression test case.

Fixes:		8572367b68 ("pf: remove STATE_LOOKUP")
Reviewed by:	kp
MFC after:	2 weeks
Sponsored by:	OPNsense
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D59015
2026-08-27 13:33:10 +00:00
Pouria Mousavizadeh Tehrani 901a242269 ifconfig: Add netlink support for reading ifgroup
Read interface groups from IFLAF_GROUP netlink attribute.

Reviewed by:	glebius
Differential Revision:	https://reviews.freebsd.org/D58644
2026-08-27 16:34:55 +03:30
Pouria Mousavizadeh Tehrani 2f8f892ca3 rtnetlink: Add FreeBSD-specific IFLAF_GROUP support
Netlink IFLA_GROUP works with a single group id, in our
implementation an interface can be joined to multiple groups
and it works with group name.
Store interface groups in IFLAF_GROUP attribute.

Reviewed by:	glebius, melifaro
Discussed with:	markj
Differential Revision: https://reviews.freebsd.org/D58643
2026-08-27 16:34:53 +03:30
Olivier Certner b7cff2a8c4 UPDATING: Fix entry for getgroups(2)/setgroups(2)
Fix a typo, grammar, and generally rephrase for better clarity.

Fixes:          3463f02706 ("UPDATING: add an entry for [gs]etgroups")
MFC after:      1 day
MFC to:         stable/15
Sponsored by:   The FreeBSD Foundation
2026-08-27 15:00:06 +02:00
Timo Völker bb50bb45f5 vtnet: move offload functions to virtio_net.h
Move the functions vtnet_rxq_csum() and vtnet_txq_offload() and the
subfunctions they call from if_vtnet.c to virtio_net.h. This allows
us to call these functions from if_tuntap.c and if_ptnet.c.
virtio_net.h already contained a copy of these functions, but a copy
of an outdated version. The functions evolved in if_vtnet.c.
In if_vtnet.c, the copy has never been used because it increments
counters in their own functions.
This patch removes the outdated copy from virtio_net.h and moves the
new version of the functions from if_vtnet.c to virtio_net.h.
if_tuntap.c, if_ptnet.c, and if_vtnet.c just call these functions,
and if_vtnet.c increments its counters depending on the return value.

Reviewed by:		tuexen
MFC after:		1 month
MFC to:			stable/15
Differential Revision:	https://reviews.freebsd.org/D57299
2026-08-27 05:15:17 +02:00
Emmanuel Vadot 75ccab52f8 dts: Bump freebsd,dts-version to 7.1 2026-08-27 14:42:23 +02:00
Emmanuel Vadot 69ed3df4f5 Import device-tree files from Linux 7.1 2026-08-27 14:40:06 +02:00
Emmanuel Vadot 0cd4430a93 Import device-tree files from Linux 7.0 2026-08-27 14:39:14 +02:00
Emmanuel Vadot 96fb1ebd28 Import device-tree files from Linux 6.19 2026-08-27 14:38:16 +02:00
Emmanuel Vadot 1537cf7382 Import device-tree files from Linux 6.18 2026-08-27 14:35:40 +02:00
Igor Ostapenko 36afb137b6 netpfil tests: Make divapp packet loop handling opt-in
This generalizes the divapp logic and makes it usable for other test
scenarios such as diverted TCP connections.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D59067
2026-08-27 11:47:24 +00:00
Peter Holm 2b93d98aab stress2: Use the new version of fsx in ports instead of the older one in tools/regression
Suggested by:	 asomers
2026-08-27 10:28:45 +02:00
Bjoern A. Zeeb d1057074b2 LinuxKPI: 802.11: assert wiphy lock for lkpi_bss_info_change() and MO
Finish reviewing all callers for lkpi_80211_mo_link_info_changed() and
lkpi_80211_mo_bss_info_changed(), which are called from
lkpi_bss_info_change() only.  Add the lockdep_assert_wiphy() to
lkpi_bss_info_change() and make sure all callers are holding the
wiphy lock.

PR:		297228
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2026-08-27 07:59:40 +00:00
Emmanuel Vadot e541832e0c Import device-tree files from Linux 7.1 2026-08-27 09:08:15 +02:00
Emmanuel Vadot 070a687a2a Import device-tree files from Linux 7.0 2026-08-27 09:06:44 +02:00
Emmanuel Vadot 93922de2d5 Import device-tree files from Linux 6.19 2026-08-27 09:04:47 +02:00
Emmanuel Vadot 8b46e9538c Import device-tree files from Linux 6.18 2026-08-27 09:01:50 +02:00
Emmanuel Vadot 80bac43c22 i2c/sensor/w83793g: Fix unused function warning
w83793g_writereg is unused so silence it.

Fixes:	cd3cc6e910 ("i2c/sensors: Add driver for W83793 hardware monitor")
2026-08-27 09:00:21 +02:00
Jaeyoon Choi 3ecee9314d ufshci: reject new requests on a failed controller
A failed controller accepted new requests, but nothing ever
completed them, so the caller waited forever. The admin retry
path could also resubmit a request to a dead queue.

Reject new submits and admin retries on a failed controller.
The submit check runs under the queue lock, so it cannot race
with the queue walk in the fail path.

Reviewed by:		imp (mentor)
Sponsored by:           Samsung Electronics
Differential Revision:	https://reviews.freebsd.org/D58948
2026-08-27 05:08:38 +00:00
Jaeyoon Choi e59d4ec66f ufshci: handle a recovery reset before the SIM attach
When the first start attempt fails early, the recovery reset
runs the start sequence again without a SIM. That pass still
looked up the WLUN, so it dereferenced a NULL SIM and panicked.

Attach the SIM whenever it does not exist yet. Also make the
WLUN lookup return NULL when there is no SIM.

Reviewed by:		imp (mentor)
Sponsored by:           Samsung Electronics
Differential Revision:	https://reviews.freebsd.org/D58947
2026-08-27 05:08:38 +00:00
Jaeyoon Choi 746278a6dd ufshci: build valid fake responses for manual completion
The manual completion wrote the fake response to the wrong
descriptor for task management slots. It also left the task tag
at zero, which tripped the task tag check under INVARIANTS.

Write the fake response where the completion path reads it.
Copy the task tag from the request.

Reviewed by:		imp (mentor)
Sponsored by:           Samsung Electronics
Differential Revision:	https://reviews.freebsd.org/D58946
2026-08-27 05:08:38 +00:00
Jaeyoon Choi 7682b8f376 ufshci: claim trackers before failing them
ufshci_req_queue_fail() drops the queue lock to complete each
tracker. In that window the completion path could complete the
same tracker again.

Claim the slot before dropping the lock, so the completion scan
skips it. Reserved slots are left to their submit thread, which
completes them itself. The manual request completion helper
lost its only caller, so drop it.

Reviewed by:		imp (mentor)
Sponsored by:           Samsung Electronics
Differential Revision:	https://reviews.freebsd.org/D58945
2026-08-27 05:08:37 +00:00
Jaeyoon Choi 1258ae2bcb ufshci: run the controller fail path only once
Two threads could run ufshci_ctrlr_fail() at the same time.
Each one walked the queues and completed the same trackers
again, which caused a double free and a panic.

Turn is_failed into an atomic gate, so only the first caller
walks the queues. The reset task now returns early on a failed
controller instead of re-enabling it.

Reviewed by:		imp (mentor)
Sponsored by:           Samsung Electronics
Differential Revision:	https://reviews.freebsd.org/D58944
2026-08-27 05:08:37 +00:00
Kevin Bowling 1a2a88684a acpi_pci: Inherit PF locality for SR-IOV VFs
SR-IOV VFs are instantiated from their PF and intentionally do not
receive an ACPI handle by matching their runtime BDF.  Consequently,
ACPI locality queries for a VF fall back to the upstream bus.  This is
usually sufficient, but loses a _PXM supplied specifically for the PF.

Use the PCI core's owning-PF accessor for BUS_GET_DOMAIN and
BUS_GET_CPUS requests made for a VF.  This preserves the VF's lack of
an ACPI handle while allowing its CPU and NUMA placement to follow the
PF.

Reviewed by:	jhb
MFC after:	2 weeks
Sponsored by:	BBOX.io
Differential Revision:	https://reviews.freebsd.org/D59062
2026-08-26 22:01:34 -07:00
Kevin Bowling 8b74806161 acpi_pci: Do not match SR-IOV VFs to ACPI devices
SR-IOV VFs are instantiated dynamically from their PF rather than
enumerated from ACPI.  A VF's runtime slot and function can match an
unrelated _ADR below the bridge.  acpi_pci_save_handle() stores that
handle in the VF's devinfo before acpi_pci_update_device() runs.

If the handle is already bound to another device_t whose parent is not
acpi0, acpi_pci_update_device() panics under INVARIANTS.  Without
INVARIANTS, the VF retains the unrelated handle, so subsequent ACPI
lookups, including NUMA and power-management operations, can act on the
wrong namespace node.

Skip ACPI namespace matching for VFs.

Reviewed by:	jhb
MFC after:	2 weeks
Sponsored by:	BBOX.io
Differential Revision:	https://reviews.freebsd.org/D59061
2026-08-26 22:00:38 -07:00
Rick Macklem c54fbc9e83 chflags.1: Change dontcache to nocache
Commit 290e563166 changed the flag's name from dontcache
to nocache. This patch fixes the man page.

This is a content change.

Reviewed by:	kib (earlier version)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D58181
Fixes:	4830670a3f ("chflags.1: Document the new UF_DONTCACHE flag")
2026-08-26 15:19:26 -07:00
Rick Macklem 290e563166 chflags: Add a new UF_NOCACHE flag
This internet draft (which is close to being an RFC)
specifies a new NFSv4.2 attribute which tells the NFSv4.2
client to not cache file data. (Similar to O_DIRECT, but
triggered by this attribute set on the file on the NFSv4.2
server and not by the application's open(2).)

https://datatracker.ietf.org/doc/draft-ietf-nfsv4-uncacheable-files/

This patch adds a new chflags(1) flag called UF_NOCACHE to
implement this.

Patches for NFS and ZFS will be done separately.

This is a redo of the patch, with a requested name change
and a #ifdef in strtofflags.c so that it doesn't break some
Linux cross build.  The name change was requested by fuz@.

Reviewed by:	kib (earlier version)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D58181
2026-08-26 14:55:20 -07:00
ShengYi Hung 0f59df8386 xhci: Only reset the data toggle value when the USB stack asks for it
The previous patch assumes that we don't want to reset toggle bit in
STOPPED_STEP. However, a device can explicitly call
usbd_clear_data_toggle if necessary. As a result, instead of not
dropping the bit unconditionally, we added a field in xhci to specify
that we want to drop it, so that usbd_clear_data_toggle can handle it
correctly.

Reported by:    oh
Reviewed by:    kevans
Tested by:      oh
Fixes:		28d85db46b ("xhci: Do not drop and add bits in xhci")
MFC after:	3 days
Differential Revision:  https://reviews.freebsd.org/D59186
2026-08-26 15:52:11 -05:00
Bryan Drewery 4a20c0a9cd sched_ule: Fix spelling of csr_cpu in comment.
Commit 08063e9f98 renamed cs_cpu to csr_cpu.
2026-08-26 13:49:52 -07:00
John Baldwin 0ffad4ce56 bhyve: Tidy lobits handling in pci_passthru
- The lobits field in the "physical" BAR settings is never used, so
  don't bother setting it.

- Expand the comment explaining why the existing lobits are preserved
  (namely, to preserve the prefetch flag on memory BARs).

Reviewed by:	bnovkov
Differential Revision:	https://reviews.freebsd.org/D58894
2026-08-26 15:31:01 -04:00