sockstat: improve consistency
Include the entries of the BBLOG STATE column in the computation
of the column width as done also for other columns.
Also set first to falso only when needed.
MFC after: 3 days
MFC to: stable/15
MFC to: stable/14
Sponsored by: Netflix, Inc.
chflags: use Capsicum capability mode
Run the file-hierarchy traversal inside Capsicum capability mode
using the fts_openat(3) API. This confines chflags to the directory
hierarchies named on the command line, so a malicious or buggy tree
cannot redirect it at files elsewhere via a crafted symbolic link.
Because AT_FDCWD is rejected in capability mode, a directory descriptor
for the parent directory of every argument with an absolute path or a
path containing ".." is opened once before cap_enter(). Once every
descriptor is open, cap_enter() is called and the traversal acts through
fd-relative operations: chflagsat(fts_parent->fts_dirfd, fts_name).
With -L chflags follows symbolic links, which may point outside the
named hierarchy; chflag now rejects such accesses. The new
--dereference-links-unsafely option disables the sandbox to restore the
historical behavior for the rare callers that rely on it. But if the
symbolic was link was named directly on the command line, chflags will
still follow it (unless -h was given).
[10 lines not shown]
chflags: fix indentation style bugs
Several lines in the flags-parsing block used spaces instead of
tabs for indentation. Convert them to tabs to match style(9).
No functional change.
Sponsored by: Google LLC (GSoC 2026)
rtwn: allow non-zero interface indexes
The endpoints we want won't always be on interface 0. Instead, allow the
interface index to be specified in driver_info when probing.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D59107
rtwn: add rtwn_efuse_preread
This would be used to switch to the "WiFi bank" before reading the rom.
The 8723bu will need this, currently a nop on all chips.
Differential Revision: https://reviews.freebsd.org/D59106
amd_iommu: Bound IVHD device-entry parsing
Validate the IVRS table and every subtable length before using either
to form iterator bounds. Reject truncated typed IVHD blocks instead of
passing them to a type-specific callback.
Within each IVHD payload, correct the lower-bound comparison for
extended range entries and validate fixed-size entries, paired range
terminators, the fixed HID body, and the variable HID UID before
dereferencing or advancing. Malformed firmware can no longer drive
either iterator beyond its enclosing object.
Reviewed by: kib
MFC after: 2 weeks
Sponsored by: BBOX.io
Differential Revision: https://reviews.freebsd.org/D58724
bhyvectl: Generalize bhyve IPC code
Move the nvlist-based bhyve IPC code into a separate function.
No functional change intended.
Reviewed by: rew
Differential Revision: https://reviews.freebsd.org/D54652
bhyve: Generalize the IPC thread
Move the code for the snapshotting IPC thread into a separate file
and define macros for adding new IPC commands.
No functional change intended.
Reviewed by: rew
Differential Revision: https://reviews.freebsd.org/D54650
hwpmc: build hwpmc_rapl.c into the i386 module
The module's i386 source list compiles the files that call
pmc_rapl_initialize() and pmc_rapl_finalize() but not the one that defines
them, so the i386 hwpmc.ko has both undefined and cannot be loaded.
Fixes: a99d04f39dab ("hwpmc: add RAPL energy-counter class (AMD + Intel)")
Assisted-by: Claude Code (Opus 5)
hwpmc: do not register RAPL when the unit register reads as zero
An energy status unit of zero means one joule per raw tick, which no part
reports; it is what a hypervisor returns for an MSR it does not implement.
Both energy rows are scaled by that field, so the class would be
registered with counters that read zero forever.
Refuse it, as the class is already refused when no energy MSR responds.
Assisted-by: Claude Code (Opus 5)
hwpmc: probe the RAPL unit MSR instead of faulting on it
The RAPL probe read MSR_RAPL_POWER_UNIT with a bare rdmsr(). RAPL is not
enumerated by CPUID on either vendor and the register is absent on older
Intel and AMD parts and under a hypervisor that does not emulate it, so
the read raises #GP and loading hwpmc panics the machine.
Read it with rdmsr_safe() and return ENXIO when it is not there, as this
function already does for the energy MSRs. Both callers already drop the
class when the probe fails.
Fixes: a99d04f39dab ("hwpmc: add RAPL energy-counter class (AMD + Intel)")
Assisted-by: Claude Code (Opus 5)
route/fib_algo: Free leaked radix_masks in radix_lockless
radix_lockless algorithm creates its own radix tree and
allocates its own radix_masks by directly calling rnh_addaddr().
However, during destruction, it only frees the radix_tree without
freeing its allocated radix_masks.
Fix the leak by calling rn_delete() during radix_destroy().
PR: 297339
Reviewed by: melifaro
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D59112
ixgbe: Probe additional controller variants
The shared base code already selects and configures the 82598 BX,
82599 KR, 82599 SFP Express Module, X552 XFI, X553 QSFP, and X553 N
QSFP device IDs, but the FreeBSD probe table omits them while DPDK lists
them.
MFC after: 2 weeks
Sponsored by: BBOX.io
igb: Report 82580 memory ECC errors
82580 exposes clear-on-read, saturating corrected error counters for
the receive and transmit packet buffers. Its two PCIe command memories
expose RW1C indications for uncorrectable ECC errors.
Sample the packet buffer counters and PCIe indications from the regular
hardware statistics update. Fatal recovery samples the PCIe indications
from the serialized admin path rather than the interrupt filter. Thus,
either the regular statistics pass or recovery reads and clears each
indication, but they cannot both account it. Also preserve indications
observed while initialization is completing.
Expose the exact packet buffer error total and observed PCIe command
memory indications under the memory_errors sysctl node. Multiple PCIe
errors between samples can collapse into one indication per memory.
Validated on an Intel I340-T2 (82580, revision 1). A clean boot and
three down/up cycles left the packet-buffer, PCIe, and region-specific
[10 lines not shown]
e1000: Recover from 82580 memory errors
82580 reports fatal parity and uncorrectable ECC errors through ICR.FER
and its four region PEIND hierarchy. Region specific status registers
identify PCIe, DMA transmit, DMA receive, DMA host, and LAN port
memories that can leave traffic stopped.
Enable the documented DMA, PCIe, packet-buffer, and host-owned LAN
parity and ECC checks only after initializing queue and filter tables.
Leave the flexible filter parity controls under management firmware
ownership. Capture read-clear and RW1C status in the interrupt filter
and keep FER masked until the admin task resolves the event.
Reset for a host-owned region or an unknown FER source. Leave
management-only recovery to firmware. Use CTRL.RST before master
disable because fatal 82580 memory errors can stop PCIe traffic. Do not
use CTRL.DEV_RST: specification update item 9 declares that bit reserved
and says it must always be written as zero. Wait for EEPROM auto read
completion; STATUS bit 21 is reserved on 82580, not PF_RST_DONE.
[21 lines not shown]
ixgbe: Correct the PFVFRSSRK index range comment
PFVFRSSRK contains ten 32-bit RSS key words, numbered 0 through 9.
The previous inclusive range incorrectly ended at 10.
Sponsored by: BBOX.io
(cherry picked from commit f177ff939a91a3d710752438b13aff53d5afc725)
ixv: Reject unsupported E610 Hyper-V VFs
E610 Hyper-V VFs use PCI configuration space communication instead of
the native PF/VF mailbox. The generic E610 match currently attaches
native mailbox operations to those devices, and the imported Hyper-V
subdevice identifier is incorrect.
Correct the subdevice identifier to 0x00ff, as used by DPDK shared
ixgbe code, and reject that subtype until ixv has a complete Hyper-V
operations table.
Sponsored by: BBOX.io
(cherry picked from commit 08c41a679b281505eb7f1fd0cb528f3c1fe87fed)
iflib: Support recoverable initialization failure
The ifdi_init method cannot report an error, so iflib always marks an
interface running and enables its interrupts after the callback returns.
Drivers whose hardware initialization depends on an unavailable peer can
only return early and leave a falsely running interface.
Add iflib_init_failed() so a callback can leave the interface stopped.
Also add a conditional reset request for asynchronous recovery: it is
discarded if the interface is administratively down when the admin task
runs, preventing a queued retry from resurrecting a stopped interface.
Do not restore saved driver flags after an MTU or capability change when
initialization failed. Restoring the pre-init flags would overwrite the
stopped result with stale RUNNING state.
Document that reset requests require the caller to schedule the admin
task, that output remains blocked during recovery, and that iflib rather
than the driver owns the driver flags.
[2 lines not shown]
ixgbe: Correct the PFVFRSSRK index range comment
PFVFRSSRK contains ten 32-bit RSS key words, numbered 0 through 9.
The previous inclusive range incorrectly ended at 10.
Sponsored by: BBOX.io
(cherry picked from commit f177ff939a91a3d710752438b13aff53d5afc725)
ixv: Reject unsupported E610 Hyper-V VFs
E610 Hyper-V VFs use PCI configuration space communication instead of
the native PF/VF mailbox. The generic E610 match currently attaches
native mailbox operations to those devices, and the imported Hyper-V
subdevice identifier is incorrect.
Correct the subdevice identifier to 0x00ff, as used by DPDK shared
ixgbe code, and reject that subtype until ixv has a complete Hyper-V
operations table.
Sponsored by: BBOX.io
(cherry picked from commit 08c41a679b281505eb7f1fd0cb528f3c1fe87fed)
iflib: Support recoverable initialization failure
The ifdi_init method cannot report an error, so iflib always marks an
interface running and enables its interrupts after the callback returns.
Drivers whose hardware initialization depends on an unavailable peer can
only return early and leave a falsely running interface.
Add iflib_init_failed() so a callback can leave the interface stopped.
Also add a conditional reset request for asynchronous recovery: it is
discarded if the interface is administratively down when the admin task
runs, preventing a queued retry from resurrecting a stopped interface.
Do not restore saved driver flags after an MTU or capability change when
initialization failed. Restoring the pre-init flags would overwrite the
stopped result with stale RUNNING state.
Document that reset requests require the caller to schedule the admin
task, that output remains blocked during recovery, and that iflib rather
than the driver owns the driver flags.
[2 lines not shown]
dpaa/qman: Fix various pool allocation bugs
* Set qman_channel_base after determining if QMan is v3, otherwise this
global stays at 0x21, which messes up the shift in
qman_portal_static_dequeue_channel().
* Fix the base shift in qman_portal_static_dequeue_channel(), there are
only 15 channels available, not 16, so starting at a shift of 15
yields shifting into the portal-specific channel.
* Correct vmem pool names for QMan resource pools.
dpaa/eth: fast-path single-page TX frame build
The TX SG-build loop in dpaa_eth_if_start_locked() walked page
boundaries with PAGE_MASK arithmetic even for buffers that lived
entirely within one page -- the common case, since MCLBYTES
is smaller than PAGE_SIZE. Add a fast path that emits a single SGT
entry for wholly-in-one-page segments and skips the inner while
entirely.
Fix the following bugs while we're here:
1. "if (m->m_len == 0) continue;" in the outer loop never
advanced m -- any zero-length mbuf hung the TX path in an
infinite loop. Fix this by switching to a for loop, with the
advancement in the post-clause.
2. In the inner (page-splitting) loop, the cap
"if (m->m_len < ssize) ssize = m->m_len;" compared against
the mbuf's original length, not the remaining bytes. A single mbuf
[11 lines not shown]
libc: Implement bsearch_s(), document bsearch_b(), and add unit tests
- Implement bsearch_s() as per §K.3.6.3.2 in C23, first specified
in C11. It behaves identically to bsearch(), except the callback
is called with a third argument, context, which is passed through
from the caller, and it also performs runtime constraint checking
on its arguments.
- Document bsearch_b(), bsearch_s(), and add history section
- Add rudimentary unit tests for bsearch(), bsearch_b(), and bsearch_s()
Reviewed by: dteske, fuz
Approved by: dteske (mentor), fuz (mentor)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D58876
snd_hdsp*: malloc(9) with M_WAITOK
Perform the allocations outside the lock section so that we can use
M_WAITOK. Holding the lock here is actually not really necessary and we
could just as well remove it, but keep it for consistency.
Sponsored by: The FreeBSD Foundation
MFC after: 1 month
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D59079
bhyve: Do not panic on invalid input in HDA emulation
The emulated HDA controller passed values taken from guest registers and
from guest memory straight into assert(), so a guest could abort bhyve
with values the emulation did not expect. Reject them instead.
In case the guest asked to start something and it failed, clear the
corresponding run/enable bit.
PR: 256379, 256381, 256382, 256383, 256384, 256385, 256386, 256498
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: bnovkov, jhb
Differential Revision: https://reviews.freebsd.org/D59082
rc.d/bgfsck: use the correct variable name
The name of the script and the name used internally for rc.conf differ,
as such the hardcoded disabling of service jails for the didn't work.
Fix by using the correct name.
Fixes: f99f0ee14e3af rc.d: add a service jails config to all base system services
(cherry picked from commit 84d8d2878a6efbb2c97a591054f1fc42b7d406ab)
etc/rc.subr: svcj - use the filename for services
We have ports and basesystem services, where the internal name and the
filename differ. While the documentation recommends to keep them in
sync, the reality is different. For service jails use the basename of
the service filename.
Fixes: 2efbd48 rc: add service jails framework
Suggested by: joneum
MFC after: 1 week
MFC to: stable/15
(cherry picked from commit d0f0a3b89b932b776b76278fa6885f19e8b30cbb)