HardenedBSD/src e26980dlib/libc/stdio open_wmemstream.c open_memstream.c, lib/libc/tests/stdio open_wmemstream_test.c open_memstream2_test.c

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/pledge
DeltaFile
+26-13lib/libc/stdio/open_memstream.c
+39-0lib/libc/tests/stdio/open_memstream2_test.c
+25-13lib/libc/stdio/open_wmemstream.c
+38-0lib/libc/tests/stdio/open_wmemstream_test.c
+128-264 files

HardenedBSD/src ff2a509lib/libc/stdio open_wmemstream.c open_memstream.c, lib/libc/tests/stdio open_wmemstream_test.c open_memstream2_test.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+26-13lib/libc/stdio/open_memstream.c
+39-0lib/libc/tests/stdio/open_memstream2_test.c
+25-13lib/libc/stdio/open_wmemstream.c
+38-0lib/libc/tests/stdio/open_wmemstream_test.c
+128-264 files

HardenedBSD/src 12ad577sys/dev/e1000 igb_txrx.c em_txrx.c

Merge branch 'freebsd/15-stable/main' into hardened/15-stable/main
DeltaFile
+61-18sys/dev/e1000/if_em.c
+9-1sys/dev/e1000/if_em.h
+2-2sys/dev/e1000/em_txrx.c
+1-1sys/dev/e1000/igb_txrx.c
+73-224 files

HardenedBSD/src 781defclib/libc/stdio open_wmemstream.c open_memstream.c

stdio: *memstream: decouple the buffer size from the stream length

It's useful to be able to track both facts with a single variable, but
it also makes it more difficult to change how the buffer size scales.

As an example, Apple's implementation seems to scale the buffer size by
1.5x on growth, presumably in an attempt to reduce trips into realloc().
This might be questionable in the face of stdio buffering, but avoiding
serious churn in the line- or un-buffered case is a net positive if
doing so isn't incredibly invasive.

Reviewed by:    des, jhb, obiwac
Sponsored by:   Klara, Inc.
Differential Revision:  https://reviews.freebsd.org/D57354
DeltaFile
+9-4lib/libc/stdio/open_memstream.c
+8-4lib/libc/stdio/open_wmemstream.c
+17-82 files

HardenedBSD/src 28327c5lib/libc/stdio open_wmemstream.c open_memstream.c

stdio: *memstream: slightly streamline growth function

Inverting the condition after realloc*() is a minor cleanup, but makes
the success path a little cleaner to ease a future change.

Reviewed by:    des, jhb
Sponsored by:   Klara, Inc.
Differential Revision:  https://reviews.freebsd.org/D57353
DeltaFile
+8-9lib/libc/stdio/open_memstream.c
+7-9lib/libc/stdio/open_wmemstream.c
+15-182 files

HardenedBSD/src a3a884clib/libc/stdio open_memstream.c open_wmemstream.c, lib/libc/tests/stdio open_wmemstream_test.c open_memstream2_test.c

stdio: *memstream: grow the buffer by 1.5x on write

This improves performance by reducing the number of allocations as we
write into the memstream, both in the fully buffered case with larger
memstreams and also more trivially in the line- and un-buffered case as
they flush back to the underlying buffer more often.

The inspiration for this was taken from Apple's implementation in
https://github.com/apple-oss-distributions/libc, but expanded to include
wmemstream for consistency.  I've added a test for the bug that I hit in
libder that caused me to notice this in the first place, and fixed that
bug in this version.

Reviewed by:    des, jhb (both slightly previous version)
Sponsored by:   Klara, Inc.
Differential Revision:  https://reviews.freebsd.org/D57355
DeltaFile
+39-0lib/libc/tests/stdio/open_memstream2_test.c
+38-0lib/libc/tests/stdio/open_wmemstream_test.c
+16-6lib/libc/stdio/open_wmemstream.c
+15-6lib/libc/stdio/open_memstream.c
+108-124 files

HardenedBSD/src 03125b9sys/dev/e1000 igb_txrx.c em_txrx.c

e1000: fix rx accounting for multi-descriptor packets

The receive paths accumulate ri->iri_len across the descriptors making
up a packet, then add that running total to rxr->rx_bytes on every
iteration of the loop.  A packet spanning descriptors of length l1, l2
and l3 thus contributes 3*l1 + 2*l2 + l3 instead of l1 + l2 + l3.

Single descriptor packets, the common case, are accounted correctly,
so this only shows up on jumbo frames.

Add the per descriptor length instead.  iflib memsets the if_rxd_info
before each isc_rxd_pkt_get() call, so summing len gives the same total
as the final iri_len, and the frame error path that returns without
incrementing rx_packets keeps counting bytes exactly as before.

(cherry picked from commit 41a46c2d46aa4078c597ce3a0d19323cab988277)
DeltaFile
+2-2sys/dev/e1000/em_txrx.c
+1-1sys/dev/e1000/igb_txrx.c
+3-32 files

HardenedBSD/src ec14a02sys/dev/e1000 if_em.h if_em.c

e1000: Defer link-up notification until after TSO reset

em_automask_tso() changes the enabled TSO capabilities when the link
moves between 10/100 and 1000 Mb/s.  A running interface must be
reinitialized to apply the new capability set.  Do not publish
LINK_STATE_UP until the requested iflib reset has completed.

Replace link_active with an explicit state machine that distinguishes
the physical link, its publication to iflib, and an outstanding reset
barrier.  Preserve that barrier across a link flap with
DOWN_RESET_PENDING, and only publish DOWN if UP was previously
published.

Only request a reset for a running interface or for an initialization
while the interface is administratively up.  In other states the next
initialization will apply the capability changes, avoiding a reset
request that iflib's admin task could discard.

Reviewed by:    Faraz Vahedi <kfv at kfv.io>

    [3 lines not shown]
DeltaFile
+61-18sys/dev/e1000/if_em.c
+9-1sys/dev/e1000/if_em.h
+70-192 files

HardenedBSD/src a8d8953lib/libc/tests/secure fortify_uio_test.c, sbin/ifconfig ifgif.c

Merge remote-tracking branch 'rad/hardened/current/master' into hardened/current/pledge
DeltaFile
+270-34sys/net/if_gif.c
+194-0sbin/ifconfig/ifgif.c
+160-0tests/sys/netlink/test_rtnl_gif.c
+51-83sys/kern/kern_malloc.c
+80-20lib/libc/tests/secure/fortify_uio_test.c
+42-30sys/vm/uma_core.c
+797-16721 files not shown
+977-24127 files

HardenedBSD/src 78e8b0esbin/nvmecontrol nvmecontrol.8, sys/dev/acpica acpi.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+35-24sys/dev/acpica/acpi.c
+4-6sys/vm/uma_core.c
+4-4sys/kern/imgact_elf.c
+5-1sbin/nvmecontrol/nvmecontrol.8
+5-0sys/dev/igc/igc_base.c
+53-355 files

HardenedBSD/src aefd85fshare/man/man4 mt7921.4, sys/contrib/dev/mediatek/mt76 zzz_fw_ports_fwget.sh

Merge branch 'freebsd/15-stable/main' into hardened/15-stable/main
DeltaFile
+25-39share/man/man4/mt7921.4
+17-8sys/contrib/dev/mediatek/mt76/zzz_fw_ports_fwget.sh
+24-0usr.sbin/fwget/pci/pci_network_ittim
+7-7usr.sbin/fwget/pci/pci_network_mediatek
+1-0usr.sbin/fwget/pci/pci
+74-545 files

HardenedBSD/src cecb0f4sys/dev/igc igc_base.c

igc: Apply ASPM L1.2 workaround to all I226 devices

Classify I226_LMVP and I226_BLANK_NVM as I226 silicon so they
receive the I226-specific ASPM L1.2 workaround.

PR:             279245
MFC after:      1 week
Pull-Request:   https://github.com/freebsd/freebsd-src/pull/2318
DeltaFile
+5-0sys/dev/igc/igc_base.c
+5-01 files

HardenedBSD/src 868158fsbin/nvmecontrol nvmecontrol.8

nvmecontrol.8: Explain non-operational power modes

`nvmecontrol power -l ...` lists the available power modes.
Non-operational modes are marked with an asterisk. While here,
add <device-id | namespace-id> to the "nvmecontrol power" synopsis.

MFC after:              3 days
Reviewed by:            dab, imp, michaelo, ziaee
Differential Revision:  https://reviews.freebsd.org/D58480
DeltaFile
+5-1sbin/nvmecontrol/nvmecontrol.8
+5-11 files

HardenedBSD/src 21bc31csys/dev/acpica acpi.c

acpi: parse resources of not-present devices that are kept enabled

acpi_probe_child() keeps PCI link devices, the RTC,
and docking stations enabled even when _STA reports them not present,
but skipped acpi_parse_resources() for them. With an empty resource
list, resource-based hint matching (BUS_HINT_DEVICE_UNIT) cannot wire
such a device to its hinted unit, and the hinted ISA device is then
created as a duplicate.

Modern AMI firmware reports the PNP0B00 RTC as not present while
handing timekeeping to the ACPI Time-and-Alarm device.

Reviewed by:    adrian, jhb
Differential Revision:  https://reviews.freebsd.org/D58047
DeltaFile
+35-24sys/dev/acpica/acpi.c
+35-241 files

HardenedBSD/src 1932bd2sys/kern imgact_elf.c

ptrace: Propagate errors from set_fpregs()

Otherwise ptrace(PT_SETREGSET) will not return errors to userspace.

Fixes:          cef05c5a62ba ("amd64: do not allow to set reserved bits in MXCSR for ptrace(PT_SETFPREGS)")
Reviewed by:    kib
Differential Revision:  https://reviews.freebsd.org/D58577
DeltaFile
+4-4sys/kern/imgact_elf.c
+4-41 files

HardenedBSD/src ea7d355sys/vm uma_core.c

uma: Fix KMSAN integration with malloc zones

In commit 459aa032e872 I dropped kmsan_mark() calls from malloc() on the
basis that UMA and kmem_malloc() would handle updates of the KMSAN
shadow map.  However, I missed that UMA explicitly does not handle this.

Modify UMA to only omit origin map updates for malloc zones.

Fixes:          459aa032e872 ("malloc: Refactor redzone and sanitizer handling")
Reviewed by:    rlibby
Differential Revision:  https://reviews.freebsd.org/D58574
DeltaFile
+4-6sys/vm/uma_core.c
+4-61 files

HardenedBSD/src 9f80b4esys/kern kern_malloc.c

HBSD: Resolve merge conflict

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
DeltaFile
+0-30sys/kern/kern_malloc.c
+0-301 files

HardenedBSD/src 3775f1dlib/libc/tests/secure fortify_uio_test.c, sbin/ifconfig ifgif.c

Merge remote-tracking branch 'rad/freebsd/current/main' into hardened/current/master

Conflicts:
        sys/kern/kern_malloc.c (unresolved)
DeltaFile
+270-34sys/net/if_gif.c
+194-0sbin/ifconfig/ifgif.c
+160-0tests/sys/netlink/test_rtnl_gif.c
+60-62sys/kern/kern_malloc.c
+80-20lib/libc/tests/secure/fortify_uio_test.c
+38-24sys/vm/uma_core.c
+802-14017 files not shown
+933-18523 files

HardenedBSD/src b5fe1bclibexec/rc/rc.d bthidd

rc.d/bthidd: Correct load_kld invocations

Pass a single module name to load_kld for kbdmux and vkbd, allowing
bthidd_prestart to load both modules successfully.

Fixes:          cfe1962a1925 (rc: Fix improper use of load_kld)
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
DeltaFile
+2-2libexec/rc/rc.d/bthidd
+2-21 files

HardenedBSD/src f7e7fabsys/compat/linuxkpi/common/include/linux xarray.h

linuxkpi: Add xa_insert_irq wrapper

This just invokes xa_insert similar to other xa_*_irq wrappers.

Reviewed by:    bz
Sponsored by:   Chelsio Communications
Differential Revision:  https://reviews.freebsd.org/D58576
DeltaFile
+3-0sys/compat/linuxkpi/common/include/linux/xarray.h
+3-01 files

HardenedBSD/src c7400festand/common load_elf.c

stand: Reject ELF files with PT_LOAD segments where filesz > memsz

Reviewed by:    jrtc27, kib
Differential Revision:  https://reviews.freebsd.org/D58543
DeltaFile
+6-0stand/common/load_elf.c
+6-01 files

HardenedBSD/src 486dfbbsys/kern link_elf.c

kld: Reject kernel modules with PT_LOAD segments where filesz > memsz

All sorts of places in the ELF loading code assume that filesz <=
memsz, so check that explicitly up front.

Reported by:    Jane Smith <thebugfixers at pm.me> (via D57785)
Reviewed by:    jrtc27, kib
Differential Revision:  https://reviews.freebsd.org/D58542
DeltaFile
+8-0sys/kern/link_elf.c
+8-01 files

HardenedBSD/src b9eaf9blib/libc/gen tls.c

libc: Reject static ELF exectables with PT_TLS segments were filesz > memsz

Reviewed by:    jrtc27
Differential Revision:  https://reviews.freebsd.org/D58558
DeltaFile
+4-0lib/libc/gen/tls.c
+4-01 files

HardenedBSD/src 535eb24libexec/rtld-elf rtld.c map_object.c

rtld: Reject ELF files with PT_LOAD or PT_TLS segments where filesz > memsz

All sorts of places in the ELF loading code assume that filesz <=
memsz, so check that explicitly up front.  The kernel already performs
this check for the PT_LOAD segments in the main binary and rtld in
imgact_elf.c.

Reviewed by:    jrtc27, kib
Differential Revision:  https://reviews.freebsd.org/D58541
DeltaFile
+12-0libexec/rtld-elf/map_object.c
+6-0libexec/rtld-elf/rtld.c
+18-02 files

HardenedBSD/src 80ee17cstand/common load_elf.c

stand: Improve error handling when loading ELF files

Previously all the 'goto out' statements after the image was loaded into
memory returned success rather than an error.  This is despite comments
indicating some of these conditions were in fact errors, and some of
these error conditions (such as missing PT_DYNAMIC) are treated as errors
in the kernel linker.

In addition, when failing to looking up the symbols for the linker
set, those cases returned failure leaking memory (though it's clear
from the original code from commit ca49b3342d1e that only the second
failure was intended to be an actual error).

To avoid more confusion, move the assignment of `ret` to just before
the `out` label so that `goto out` always returns an error.  This is a
more consistent pattern with other code in the tree that tends to use
labels for the error case.

Restructure some other code to avoid a few bogus errors.

    [6 lines not shown]
DeltaFile
+20-18stand/common/load_elf.c
+20-181 files

HardenedBSD/src 8aec309stand/common load_elf.c

stand: Remove a pointless goto

Commit 505222d35fea removed a batch of code that this goto used to skip
around.

Reviewed by:    olce, kib, markj
Fixes:          505222d35fea ("Implement the long-awaited module->file cache database.  A userland tool (kldxref(8)) keeps a cache of what modules and versions are inside what .ko files.  I have tested this on both Alpha and i386.")
Differential Revision:  https://reviews.freebsd.org/D58539
DeltaFile
+0-3stand/common/load_elf.c
+0-31 files

HardenedBSD/src 7bea49bshare/man/man4 mt7921.4

mt76: mt7921: update man page

Adjust the man page to what other LinuxKPI wlan man pages say and look
like as it has been a while since I wrote it.  The man page is not yet
hooked up to the build on purpose as the driver is not yet enabled in
the tree.

Sponsored by:   The FreeBSD Foundation
Reviewed by:    ziaee (earlier version)
Differential Revision: https://reviews.freebsd.org/D58479

(cherry picked from commit 3afa2628ccd22f81527406bbf6a4dca54d964afc)
DeltaFile
+25-39share/man/man4/mt7921.4
+25-391 files

HardenedBSD/src 42b89d4sys/contrib/dev/mediatek/mt76 zzz_fw_ports_fwget.sh

mt76: update script to to deal with 7921 and 7925 flavors

Update the mt76/zzz_fw_ports_fwget.sh script to set fwget to download
mt7921 and mt7925 rather than the these days non-existent mt792x flavor.

Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57242

(cherry picked from commit b1f3726f7a677ae230135d19491ce97f2866e7c2)
DeltaFile
+17-8sys/contrib/dev/mediatek/mt76/zzz_fw_ports_fwget.sh
+17-81 files

HardenedBSD/src 3b569c3usr.sbin/fwget/pci pci pci_network_mediatek

fwget: update MediaTek firmware listings to match ports

Update fwget(8) to download wifi-firmware-mt76-kmod-mt7921, and
wifi-firmware-mt76-kmod-mt7925 firmware packages instead of the
no longer available mt792x version.
Add another PCI vendor to recognize ITTIM IDs for mt7921-based
MediaTek cards.

(bz reduced the license in the ittim file to an SPDX tag and updated
the commit message, given this is only half the work from the review)

Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D57242

(cherry picked from commit 7925256edc74a8c60435dce1c2c2a8f3dd1ef1a3)
DeltaFile
+24-0usr.sbin/fwget/pci/pci_network_ittim
+7-7usr.sbin/fwget/pci/pci_network_mediatek
+1-0usr.sbin/fwget/pci/pci
+32-73 files

HardenedBSD/src 82e4762sbin/route route_netlink.c

route(8): Add null check for prefsrc option

Reported by:    Shawn Webb <shawn.webb at hardenedbsd.org>, bms
Fixes:  dd235f097af4 ("route(8): Add prefsrc option in netlink")
DeltaFile
+2-1sbin/route/route_netlink.c
+2-11 files