bootpd: clamp the DHCP reply length to the packet buffer
A client could set the DHCP maximum-message-size option to a large
value; dovend_rfc1048() derived the reply length from it with no upper
bound, so the trailing bzero() of the vendor area ran far past the
MAX_MSG_SIZE packet buffer. A value >= 0x8000 read into a signed short
instead went negative and slipped past the length clamps, leaving
sendto() to read a huge length from the buffer.
Read msgsz unsigned and clamp the reply length to the buffer size.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D61009
Signed-off-by: Nick Price <nprice at FreeBSD.org>
acpi: set up the sysctl tree before acpi_machdep_init()
On amd64 and i386, acpi_machdep_init() adds hw.acpi.reset_video under
acpi_sysctl_tree. Since the tree moved to the end of attach, it no
longer exists at that point, so sysctl_add_oid() drops the node and the
sysctl documented in acpi(4) is missing. Found with KUBSAN.
acpi_machdep_init() cannot fail, so calling it after the tree does not
leave knobs behind on a failed attach.
Fixes: 7f031c9f6b9f ("acpi: Move sysctl tree set up at end of initialization")
Signed-off-by: Nick Price <nprice at FreeBSD.org>
Reviewed by: olce
Differential Revision: https://reviews.freebsd.org/D60797
vmm: don't hold the global PPT lock while resetting a device
`ppt_assign_device()` holds the global PPT lock across the save/reset/restore. `pcie_flr()` can wait up to the reset timeout, and every PPT operation on every VM stalls behind it.
Reserve the function with `resetting` and drop the lock for the reset, as `ppt_reset_device()` already does (D58864). Set `ppt->vm` first so a competing assign or `ppt_detach()` gets EBUSY at once instead of sleeping out the reset. Clear it if the assign fails.
Apply matching changes to `ppt_unassign_device()` which may actually take longer on properly-functioning hardware due to teardown duration.
Reviewed by: adrian, markj
Differential Revision: https://reviews.freebsd.org/D60188
Signed-off-by: Nick Price <nprice at FreeBSD.org>
inpcb: reject a reversed ephemeral port range
vxlan, geneve and the RDMA CM take portrange.first and last as an
ordered pair and divide by zero when first == last + 1.
Refuse a write that would put first above last or hifirst above hilast.
Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D61010
Signed-off-by: Nick Price <nprice at FreeBSD.org>
inpcb: treat the ephemeral port range as inclusive
in_pcb_lport_dest() sizes [first, last] as last - first, so the random
start never picks last and the search tries one port too few.
With first == last the random start divides by zero: once root sets the
range, any user's connect() panics the host.
Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D61010
Signed-off-by: Nick Price <nprice at FreeBSD.org>
snp(4): drain snp_outpoll before destroying the open data
kib' note: comparing to the original submission, seldrain() is called
before cv_destroy().
PR: 301062
MFC after: 1 week
ext2fs: fix post-commit review issues in multi-block allocator
Fix 8 issues identified in post-commit review of e590490:
POSTCR-1: ext2_clusteralloc() asserted MA_NOTOWNED while holding
EXT2_LOCK, causing INVARIANTS panic on successful cluster lookup.
Changed assertion to MA_OWNED.
POSTCR-2: ext2_balloc() IO_SYNC and ext4_ext_split() error paths freed
blocks after bwrite() failure, but brelse() had redirtied the buffer
which still named the freed block. Added B_INVALONERR flag before
bwrite() to invalidate buffers on error (4 locations in ext2_balloc.c,
3 in ext2_extents.c).
POSTCR-3: ext4_ext_get_blocks() freed new run when ext4_ext_dirty()
failed, but extent remained in i_data or cached leaf buffer. Simplified
ext4_ext_dirty() error handling to use B_INVALONERR instead of manual
getblk/bundirty/brelse.
[24 lines not shown]
libsa add boot_serial to is_restricted_var allow list
NOTE: variables that get passed by boot_setenv() will not have '='
so for these we need to leave that out.
It doesn't matter much unless the variable we want to allow is
also a prefix for something we do not.
Sponsored by: Hewlett Packard Enterprise Development LP
Reviewed by: kevans, imp
Differential Revision: https://reviews.freebsd.org/D61856
acpi_iicbus: Return _DSD properties of the I2C children
acpi_iicbus has no bus_get_property method, so device_get_property()
on one of its children reaches acpi(4) through
bus_generic_get_property(). acpi_bus_get_prop() then takes the
child's acpi_iicbus ivars for a struct acpi_device and follows garbage
pointers: on an HP ZBook Ultra G1a, a driver reading _DSD of its I2C
device froze the machine.
Answer for the I2C children from their own ACPI handle, with a _DSD
cache in the ivars, through a helper split out of acpi_bus_get_prop().
Reviewed by: wulf, imp
Approved by: wulf, imp
MFC after: 1 week
Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/117
acpi_iicbus: Free the ivars of deleted children
acpi_iicbus_child_deleted() replaces iicbus_child_deleted() but only
detached the ACPI data, so the ivars and their resource list leaked
with every deleted child. It also used the ivars without checking
them, while iicbus_add_child_common() can leave a child without any.
Check them and call iicbus_child_deleted() at the end.
Reviewed by: wulf, imp
Approved by: wulf, imp
Fixes: 9b7938dcf338 ("iicbus(4): Add support for ACPI-based children enumeration")
MFC after: 1 week
Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/117
acpi: Return the handle of a reference property, not its target
acpi_bus_get_prop() copied the first bytes of the namespace node a
_DSD reference points to, instead of the handle itself, when a caller
asked for such a property with a type other than DEVICE_PROP_HANDLE.
Reviewed by: wulf, imp
Approved by: wulf, imp
Fixes: 99e6980fcf5e ("device_get_property: add a HANDLE case")
MFC after: 1 week
Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/117
amdgpio: Add PNP info for devmatch
amdgpio is not in GENERIC and exports no PNP info, so devmatch(8)
never loads it, and GPIO consumers on AMD systems find no controller
unless amdgpio is in kld_list.
Export the ACPI ids so devmatch(8) loads the module at boot.
Reviewed by: imp
Approved by: imp
Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/116
ig4: Add an AMD generation with a 150 MHz clock
AMDI0010 controllers attached as Atom, whose timings assume a 100 MHz
input clock, but they run from 150 MHz (Linux drivers/acpi/acpi_apd.c),
so the bus runs above the 400 kHz of fast mode and the SDA hold time
is a third short. The median of 200 timed 1 KB reads on an HP ZBook
Ultra G1a gives an effective 472 kHz before and 348 kHz after.
Give them their own generation: the Atom timings with a 150 MHz clock,
and of the Atom register handling only the DesignWare FIFO depth and
component version checks, not the Intel LPSS private registers. It
sorts before IG4_SKYLAKE, so IG4_HAS_ADDREGS() stays false.
Reviewed by: wulf, imp
Approved by: wulf, imp
MFC after: 1 week
Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/114
amdiommu: Skip the invalidation after PTE-only maps
amdiommu_map_buf() waited for an invalidation after every map, so each
busdma load cost a command round trip and a completion interrupt. A
128 KB NVMe read raised 51 IOMMU interrupts on a Ryzen 7 7735HS and 66
on a Ryzen AI Max+ PRO 395, where reads ran at 200 MB/s instead of
900 MB/s without the IOMMU.
Filling non-present PTEs needs no invalidation unless the capability
header reports NpCache, which is how Linux handles it. A new PDE still
does: unmap frees empty page table pages and clears their PDE before
the deferred invalidation runs, and skipping the flush then produced
IO_PAGE_FAULTs from nvme(4). A concurrent map that uses such a PDE
before its flush completes flushes too.
With this change the same reads raise 19 and 33 interrupts, and the
second machine reads at 400 to 440 MB/s.
Reviewed by: kib, kbowling
[3 lines not shown]
iommu: Identity-map contexts when DMA remapping is disabled
With hw.amdiommu.enable=1 alone, interrupt remapping is on and DMA
remapping is off. amdiommu_ir_find() still instantiates a context for
each MSI source, and it got a translating domain with an empty page
table while busdma kept handing out physical addresses, so every DMA
from these devices faulted. On a Ryzen 7 7735HS the USB devices
attached in an endless loop.
Treat a unit with DMA remapping disabled like a device with remapping
disabled: give the context the identity mapping.
Reviewed by: kib, kbowling
Approved by: kib, kbowling
Fixes: 0f5116d7efe3 ("AMD IOMMU driver")
MFC after: 1 week
Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/113
amdiommu: Free and align interrupt remapping entries
amdiommu_ir_free_irte() cleared the IRTE but never returned its index,
so a device's 32 default entries run out: a driver using 32 MSI-X
vectors gets ENOMEM from pci_alloc_msix() on its second attach. Free
the block with vmem_xfree(), now that msi_release() hands a group over
whole, and allocate it with vmem_xalloc() aligned on its size, since
the device ORs the message number into the MSI data, which is the IRTE
index.
As the entries are now reused, invalidate the interrupt table under the
DeviceID it is installed at, the IVRS-resolved ctx->context.rid, not
the PCI requester ID, which differs for aliased devices.
Reviewed by: kib, kbowling, imp
Approved by: kib, kbowling
Fixes: 0f5116d7efe3 ("AMD IOMMU driver")
MFC after: 1 week
Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/112
x86: Release the IOMMU entries of an MSI group at once
msi_alloc() takes the interrupt remapping entries of a multiple-message
MSI group as one block, but msi_release() returned them one message at
a time. The DMAR driver frees each with vmem_free(cookie, 1): the
extra messages, released first, do not start a vmem segment, so
releasing a group with interrupt remapping on fails an assertion or
dereferences a NULL segment.
Pass the whole group to iommu_unmap_msi_intr() with its count, and free
the block at once in the DMAR driver, with one interrupt entry cache
invalidation for the range, its index mask capped at the unit's MHMV.
The AMD driver keeps clearing each entry for now.
Reviewed by: kib, kbowling, imp
Approved by: kib, kbowling
Fixes: 0a110d5b172e ("Use VT-d interrupt remapping block (IR) to perform FSB messages translation.")
MFC after: 1 week
Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/112
crypto/openssl: correct messages printed out when copying manpages
Prior to this change section 1's message applied to 3/5/7 and vice
versa. Now the right message is printed out by the Makefile with its
respective operation.
MFC after: 1 week
crypto/openssl: sync manpages with current release
The content in the manpages matches 3.5.4 today and we're on 3.5.9.
Update to 3.5.9's content so the manpages reflect the shipped release.
MFC after: 1 week
tdestroy(3): Take posix_tnode * like the other tsearch(3) functions
tdestroy(3) was originally a glibc extension. glibc does not use
posix_tnode (yet), and when tdestroy(3) was pulled in its signature was
not updated to match the other tsearch(3) functions.
Fixes: b8c99e7d912f ("libc: add glibc-compatible tdestroy(3)")
Sponsored by: Klara, Inc.
Add USB quirk for WCH-Link adapter
WCH-Link is a debug adapter from QinHeng Electronics that features a
(proprietary) debug bridge for their RISC-V MCUs, as well as a serial
gateway, implemented as a CDC device. The CDC's call management
descriptor declares the data interface to be 1, but it is actually
interface 2. UQ_IGNORE_CDC_CM has already been implemented before to
handle this kind of firmware bug, so just add this quirk for WCH-Link.
Reported by: Holm Tiffe
MFC after: 1 week