HardenedBSD/src ac799fc — stand/libsa environment.c, sys/amd64/vmm/io ppt.c

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/pledge
DeltaFile
+32-22sys/fs/ext2fs/ext2_extents.c
+29-9sys/amd64/vmm/io/ppt.c
+19-11sys/netinet/in_pcb.c
+20-5sys/fs/ext2fs/ext2_alloc.c
+7-8stand/libsa/environment.c
+6-3sys/dev/snp/snp.c
+113-584 files not shown
+133-6210 files

HardenedBSD/src 8e14f05 — stand/libsa environment.c, sys/amd64/vmm/io ppt.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+32-22sys/fs/ext2fs/ext2_extents.c
+29-9sys/amd64/vmm/io/ppt.c
+19-11sys/netinet/in_pcb.c
+20-5sys/fs/ext2fs/ext2_alloc.c
+7-8stand/libsa/environment.c
+6-3sys/dev/snp/snp.c
+113-584 files not shown
+133-6210 files

HardenedBSD/src d888f02 — tests/sys/fs/fdescfs fdescfs_test.c

tests/fdescfs: add a license header

Differential Revision:  https://reviews.freebsd.org/D61230
Signed-off-by:  Nick Price <nprice at FreeBSD.org>
DeltaFile
+6-0tests/sys/fs/fdescfs/fdescfs_test.c
+6-01 files

HardenedBSD/src 2679104 — libexec/bootpd bootpd.c

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>
DeltaFile
+5-1libexec/bootpd/bootpd.c
+5-11 files

HardenedBSD/src 2bcf574 — sys/dev/acpica acpi.c

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
DeltaFile
+5-3sys/dev/acpica/acpi.c
+5-31 files

HardenedBSD/src 50bbc49 — sys/amd64/vmm/io ppt.c

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>
DeltaFile
+29-9sys/amd64/vmm/io/ppt.c
+29-91 files

HardenedBSD/src d0754fe — sys/netinet in_pcb.c

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>
DeltaFile
+17-9sys/netinet/in_pcb.c
+17-91 files

HardenedBSD/src e584648 — sys/netinet in_pcb.c

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>
DeltaFile
+2-2sys/netinet/in_pcb.c
+2-21 files

HardenedBSD/src f6bd65e — sys/dev/snp snp.c

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
DeltaFile
+1-0sys/dev/snp/snp.c
+1-01 files

HardenedBSD/src e035f27 — sys/dev/snp snp.c

snp(4): do not ignore errors from devfs_set_cdevpriv()

Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
DeltaFile
+5-3sys/dev/snp/snp.c
+5-31 files

HardenedBSD/src 5c0715d — sys/fs/ext2fs ext2_balloc.c ext2_alloc.c

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]
DeltaFile
+32-22sys/fs/ext2fs/ext2_extents.c
+20-5sys/fs/ext2fs/ext2_alloc.c
+4-0sys/fs/ext2fs/ext2_balloc.c
+56-273 files

HardenedBSD/src 97fd69b — stand/libsa environment.c

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
DeltaFile
+7-8stand/libsa/environment.c
+7-81 files

HardenedBSD/src 0bac72f — secure/lib/libcrypto/man/man3 ENGINE_add.3, secure/lib/libcrypto/man/man5 config.5

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/pledge
DeltaFile
+140-150sys/dev/clk/clk_fixed.c
+7-141sys/netpfil/pf/pf_ioctl.c
+49-46secure/lib/libcrypto/man/man3/ENGINE_add.3
+59-11sys/sys/libkern.h
+34-35sys/x86/iommu/amd_intrmap.c
+34-31secure/lib/libcrypto/man/man5/config.5
+323-414766 files not shown
+6,348-4,122772 files

HardenedBSD/src cb41c91 — secure/lib/libcrypto/man/man3 ENGINE_add.3, secure/lib/libcrypto/man/man5 config.5

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+140-150sys/dev/clk/clk_fixed.c
+7-141sys/netpfil/pf/pf_ioctl.c
+49-46secure/lib/libcrypto/man/man3/ENGINE_add.3
+59-11sys/sys/libkern.h
+34-35sys/x86/iommu/amd_intrmap.c
+34-31secure/lib/libcrypto/man/man5/config.5
+323-414766 files not shown
+6,348-4,122772 files

HardenedBSD/src 17ebd95 — sys/dev/acpica acpivar.h acpi.c, sys/dev/iicbus acpi_iicbus.c

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
DeltaFile
+22-4sys/dev/acpica/acpi.c
+21-0sys/dev/iicbus/acpi_iicbus.c
+3-0sys/dev/acpica/acpivar.h
+46-43 files

HardenedBSD/src 92a634d — sys/dev/iicbus iicbus.h iicbus.c

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
DeltaFile
+3-0sys/dev/iicbus/acpi_iicbus.c
+1-1sys/dev/iicbus/iicbus.c
+1-0sys/dev/iicbus/iicbus.h
+5-13 files

HardenedBSD/src d5ad797 — sys/dev/acpica acpi.c

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
DeltaFile
+1-1sys/dev/acpica/acpi.c
+1-11 files

HardenedBSD/src 44c85f6 — sys/dev/amdgpio amdgpio.c

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
DeltaFile
+4-2sys/dev/amdgpio/amdgpio.c
+4-21 files

HardenedBSD/src 11ba27a — sys/dev/ichiic ig4_var.h ig4_acpi.c

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
DeltaFile
+12-2sys/dev/ichiic/ig4_iic.c
+2-0sys/dev/ichiic/ig4_acpi.c
+1-0sys/dev/ichiic/ig4_var.h
+15-23 files

HardenedBSD/src 5172cc8 — sys/x86/iommu amd_iommu.h amd_drv.c

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]
DeltaFile
+35-13sys/x86/iommu/amd_idpgtbl.c
+2-0sys/x86/iommu/amd_iommu.h
+2-0sys/x86/iommu/amd_drv.c
+39-133 files

HardenedBSD/src 014091f — sys/dev/iommu busdma_iommu.c

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
DeltaFile
+6-3sys/dev/iommu/busdma_iommu.c
+6-31 files

HardenedBSD/src 244a39a — sys/x86/iommu amd_intrmap.c

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
DeltaFile
+33-35sys/x86/iommu/amd_intrmap.c
+33-351 files

HardenedBSD/src bafddca — sys/x86/iommu intel_dmar.h amd_iommu.h, sys/x86/x86 msi.c

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
DeltaFile
+15-12sys/x86/iommu/intel_intrmap.c
+8-11sys/x86/x86/msi.c
+3-3sys/x86/iommu/iommu_utils.c
+3-2sys/x86/iommu/amd_intrmap.c
+1-1sys/x86/iommu/intel_dmar.h
+1-1sys/x86/iommu/amd_iommu.h
+31-303 files not shown
+34-339 files

HardenedBSD/src cb354d6 — crypto/openssl BSDmakefile

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
DeltaFile
+6-6crypto/openssl/BSDmakefile
+6-61 files

HardenedBSD/src a1c255f — secure/lib/libcrypto/man/man3 SSL_shutdown.3 ENGINE_add.3, secure/lib/libcrypto/man/man5 x509v3_config.5 fips_config.5

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
DeltaFile
+49-46secure/lib/libcrypto/man/man3/ENGINE_add.3
+34-31secure/lib/libcrypto/man/man7/EVP_PKEY-EC.7
+34-31secure/lib/libcrypto/man/man5/config.5
+33-30secure/lib/libcrypto/man/man5/fips_config.5
+32-29secure/lib/libcrypto/man/man5/x509v3_config.5
+32-29secure/lib/libcrypto/man/man3/SSL_shutdown.3
+214-196713 files not shown
+5,792-3,637719 files

HardenedBSD/src 9ef73e4 — include search.h, lib/libc/stdlib tdestroy.c

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.
DeltaFile
+1-1lib/libc/stdlib/tdestroy.c
+1-1include/search.h
+2-22 files

HardenedBSD/src 1660d69 — sys/dev/usb usbdevs, sys/dev/usb/quirk usb_quirk.c

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
DeltaFile
+1-0sys/dev/usb/usbdevs
+1-0sys/dev/usb/quirk/usb_quirk.c
+2-02 files

HardenedBSD/src d1b36c5 — sys/netipsec xform_ipcomp.c xform_esp.c

ipsec(4): remove not needed <netinet6/ip6_var.h>
DeltaFile
+0-1sys/netipsec/xform_ipcomp.c
+0-1sys/netipsec/xform_esp.c
+0-1sys/netipsec/xform_ah.c
+0-1sys/netipsec/ipsec_offload.c
+0-44 files

HardenedBSD/src 8f8c37d — sys/compat/linux linux_socket.c

linux(4): remove not needed <netinet6/ip6_var.h>
DeltaFile
+0-1sys/compat/linux/linux_socket.c
+0-11 files

HardenedBSD/src d1e76c3 — sys/dev/vmware/vmxnet3 if_vmx.c

vmx(4): remove not needed <netinet6/ip6_var.h>
DeltaFile
+0-1sys/dev/vmware/vmxnet3/if_vmx.c
+0-11 files