FreeBSD/src 1092abatests/sys/kern exterr_test.c

exterror tests: harden the checks

Skip the message-content check on kernels that do not advertise the
exterr_strings feature, and pin the output format by clearing
EXTERROR_VERBOSE.

Reviewed by:            kib
MFC after:              1 week
Assisted-by:            Claude Code (Fable 5)
Differential Revision:  https://reviews.freebsd.org/D58322
DeltaFile
+23-1tests/sys/kern/exterr_test.c
+23-11 files

FreeBSD/src c8db6d4share/man/man9 exterror.9, sys/kern sys_generic.c

exterror: advertise error strings via kern.features.exterr_strings

Allow userland, in particular test cases for EXTERROR conversions,
to detect at run time whether extended errors include the
descriptive message strings, which depends on the EXTERR_STRINGS
kernel option and cannot be probed in any other way.

Reviewed by:            kib
MFC after:              1 week
Assisted-by:            Claude Code (Fable 5)
Differential Revision:  https://reviews.freebsd.org/D58321
DeltaFile
+12-1share/man/man9/exterror.9
+4-0sys/kern/sys_generic.c
+16-12 files

FreeBSD/src ced89d9sys/dev/watchdog watchdog.c

watchdog: Fix a couple type issues

* Force the type of the literal `1` passed to nstosbt() to ensure it's a
  64-bit type (or larger).  Otherwise it gets inconveniently typed to
  int, resulting in truncation.
* Use `flsll()` when converting sbt to power-of-2-nanoseconds to fix
  32-bit compatibility.

PR:             292616
Obtained from:  Hewlett Packard Enterprise
Fixes:  26d6617f3 ("watchdog: Convert to using sbintime_t format")

(cherry picked from commit d08cb1dc17486920c1506f175d77259e0ac3f3a3)
DeltaFile
+2-2sys/dev/watchdog/watchdog.c
+2-21 files

FreeBSD/src d4ddf8esys/dev/virtio/network if_vtnetvar.h

vtnet: Accept VIRTIO_NET_F_CTRL_RX_EXTRA

Although the driver does not issue the extra receive-mode commands
accepting the feature is harmless and some devices, notably Apple's
Virtualization.framework, offer their control-queue features as a
group and refuse FEATURES_OK unless the whole set is acknowledged.

Signed-off-by:  Faraz Vahedi <kfv at kfv.io>
Reviewed by:    adrian
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2322
DeltaFile
+1-0sys/dev/virtio/network/if_vtnetvar.h
+1-01 files

FreeBSD/src c5caf85sys/dev/virtio/network if_vtnet.c if_vtnetvar.h

vtnet: Implement VIRTIO_NET_F_GUEST_ANNOUNCE

When the device sets VIRTIO_NET_S_ANNOUNCE in the config status
field, for example after a VM migrates to a new host, announce
the interface's presence on the network so peers and switches
learn the new attachment point, then acknowledge the request
with the VIRTIO_NET_CTRL_ANNOUNCE_ACK control command, as per
VirtIO v1.3, 5.1.6.5.4.

The announcement raises iflladdr_event: the stack sends gratuitous
ARPs and unsolicited neighbor advertisements for the interface's
addresses, and stacked interfaces such as vlan(4) propagate the
event and announce theirs as well.  The event handlers may sleep,
so the work is deferred from the config change interrupt to a task
on taskqueue_thread; that context also allows the acknowledgement
to be skipped safely if the interface was stopped in the meantime,
in which case the device keeps the bit set and the request is
re-delivered with the next config change interrupt.


    [3 lines not shown]
DeltaFile
+88-0sys/dev/virtio/network/if_vtnet.c
+2-0sys/dev/virtio/network/if_vtnetvar.h
+90-02 files

FreeBSD/src 5481c2dsys/dev/virtio/network if_vtnet.c if_vtnetvar.h

vtnet: Retry feature negotiation without offloads

A device is permitted to reject an otherwise valid subset of its
offered features by refusing to accept FEATURES_OK (VirtIO v1.3,
2.2.2).  Apple's Virtualization.framework does this in practice;
it treats the offered CSUM/TSO offloads as all-or-nothing, while
vtnet's default request contains only part of that group because
of hw.vtnet.lro_disable that would drop the guest TSO bits, thus
negotiation fails and the device does not attach.

If FEATURES_OK is rejected, retry the negotiation once with every
offload-related feature stripped.  Changing the feature set after
a failed FEATURES_OK requires re-initialising from device reset
(VirtIO v1.3, 3.1.1), so the retry goes through virtio_reinit().

A NIC without offloads is preferable to no NIC at all.  Devices
that accept the initial feature set are unaffected, while those
that also reject the reduced set continue to fail attachment as
before.

    [4 lines not shown]
DeltaFile
+14-2sys/dev/virtio/network/if_vtnet.c
+16-0sys/dev/virtio/network/if_vtnetvar.h
+30-22 files

FreeBSD/src 5d479b7sys/compat/linuxkpi/common/src linux_80211_macops.c linux_80211.c

LinuxKPI: 802.11: always lock around (*set_{frag,rts}_threshold)

We would lock the downcalls during normal operation but not during
vap (vif) creation as there was no need for locking.
Add the missing locking there as drivers seem to always expect it
(by assertion) and cannot distinguish between state.
Add the assertions to the downcalls as we need both of them locked
and both of them can sleep.

PR:             296185 ("rtw89(4) freezes the system with INVARIANTS kernel")
Debugged by:    Artem Bunichev (temcbun gmail.com)
Sponsored by:   The FreeBSD Foundation
MFC after:      3 days
DeltaFile
+6-0sys/compat/linuxkpi/common/src/linux_80211_macops.c
+2-0sys/compat/linuxkpi/common/src/linux_80211.c
+8-02 files

FreeBSD/src 9724f3fbin/cat cat.c

cat: Fix a NULL pointer dereference

Check the `fdopen` return value before calling `cook_cat`.

Reviewed by:    markj, bnovkov
Differential Revision:  https://reviews.freebsd.org/D57741
MFC after:      1 week
DeltaFile
+2-1bin/cat/cat.c
+2-11 files

FreeBSD/src ba583f0share/man/man9 contigmalloc.9

contigmalloc.9: Correct typo

Reported by:    alc, rlibby
Fixes: caabdb3aefdc ("contigmalloc.9: Note that M_WAITOK may still return NULL")
DeltaFile
+1-1share/man/man9/contigmalloc.9
+1-11 files

FreeBSD/src caabdb3share/man/man9 contigmalloc.9

contigmalloc.9: Note that M_WAITOK may still return NULL

Reviewed by:    markj, bapt
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D58382
DeltaFile
+10-1share/man/man9/contigmalloc.9
+10-11 files

FreeBSD/src c185935lib/libc/gen exterr_cat_filenames.h, sys/dev/hwpmc hwpmc_mod.c

hwpmc: Add EXTERROR diagnostics to the hwpmc syscall path

Annotate validation failures in the PMC syscall handlers (allocate,
attach, read/write) with EXTERROR(), so pmc(3) callers see which
precondition failed, not a bare errno.

Register HWPMC_MOD in exterr_cat.h and the generated filenames.h.

Signed-off-by:  Andre Silva <andasilv at amd.com>
Reviewed by:    Ali Mashtizadeh <ali at mashtizadeh.com>, mhorne
Sponsored by:   AMD
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2180
DeltaFile
+79-31sys/dev/hwpmc/hwpmc_mod.c
+1-0lib/libc/gen/exterr_cat_filenames.h
+1-0sys/sys/exterr_cat.h
+81-313 files

FreeBSD/src 8c4d570lib/libc/gen exterr_cat_filenames.h, sys/dev/hwpmc hwpmc_ibs.c hwpmc_amd.c

hwpmc: Add EXTERROR diagnostics to the AMD and IBS allocators

Replace bare EINVAL in AMD/IBS allocation and config-validation with
EXTERROR(), so a failed pmc(3) allocation names the check and value.

Register HWPMC_AMD in exterr_cat.h and the generated filenames.h.

Signed-off-by:  Andre Silva <andasilv at amd.com>
Reviewed by:    Ali Mashtizadeh <ali at mashtizadeh.com>, mhorne
Sponsored by:   AMD
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2180
DeltaFile
+28-17sys/dev/hwpmc/hwpmc_ibs.c
+17-7sys/dev/hwpmc/hwpmc_amd.c
+1-1sys/sys/exterr_cat.h
+1-0lib/libc/gen/exterr_cat_filenames.h
+47-254 files

FreeBSD/src 6eaa8edlib/libfetch common.c http.c

libfetch: Reduce copying

Reduce the amount of copying we do when performing buffered reads.

MFC after:      1 week
Reviewed by:    op
Differential Revision:  https://reviews.freebsd.org/D58113

(cherry picked from commit 60382b4a04fa39e9bf65b964b1b7b4bed6eaa56a)
DeltaFile
+29-16lib/libfetch/common.c
+18-23lib/libfetch/http.c
+12-11lib/libfetch/ftp.c
+2-0lib/libfetch/common.h
+61-504 files

FreeBSD/src 2902f7alib/libfetch common.h common.c

libfetch: Make fetch_ref an inline

Make fetch_ref() an inline and provide a fetch_deref().

MFC after:      1 week
Reviewed by:    op
Differential Revision:  https://reviews.freebsd.org/D57944

(cherry picked from commit d4e0e1fbc237f0765b9f32b291c087348031c921)
DeltaFile
+12-1lib/libfetch/common.h
+0-11lib/libfetch/common.c
+1-1lib/libfetch/ftp.c
+13-133 files

FreeBSD/src 29564d9usr.bin/fetch fetch.c fetch.1

fetch: Stop setting an alarm

Now that fetchTimeout works reliably, setting an alarm is not only no
longer necessary but counterproductive, as it will trigger even if the
connection is not actually stalled but merely slow.

While here, improve the wording of the manual page's description of the
various options for setting a timeout.

MFC after:      1 week
Reviewed by:    op
Differential Revision:  https://reviews.freebsd.org/D57911

(cherry picked from commit 3dddfe29248c47d1a80dc96a76a308ae910b2a24)
DeltaFile
+9-24usr.bin/fetch/fetch.c
+6-4usr.bin/fetch/fetch.1
+15-282 files

FreeBSD/src c83d4edlib/libfetch fetch.3

libfetch: Document fetchTimeout

Document the global fetchTimeout variable, now that it works reliably.

MFC after:      1 week
Reviewed by:    op
Differential Revision:  https://reviews.freebsd.org/D57910

(cherry picked from commit 27b411734c75a7a5abe641d7fbb99dfc622e9aba)
DeltaFile
+16-2lib/libfetch/fetch.3
+16-21 files

FreeBSD/src 02e82d4lib/libfetch common.c http.c

libfetch: Add read buffering

Previously, we would read FTP control connection messages and HTTP
reponse headers one character at a time.  Now, we read as much as will
fit in our buffer and look for a newline.  If there is data left over,
it will be reused by the next fetch_getln() call.  This also requires
the addition of a fetch_bufread() which takes the buffer into account,
otherwise the start of the HTTP response body will be stuck in the
buffer after we read the last line of the header.

This should noticeably improve HTTP performance, especially for small
transfers.

MFC after:      1 week
Reviewed by:    op
Differential Revision:  https://reviews.freebsd.org/D57907

(cherry picked from commit a1978277379cf65f1339ab062f335c6f1fa6239f)
DeltaFile
+87-22lib/libfetch/common.c
+24-41lib/libfetch/http.c
+4-7lib/libfetch/ftp.c
+3-1lib/libfetch/common.h
+118-714 files

FreeBSD/src 74a9217lib/libfetch common.c

libfetch: Apply timeout to connection attempts

Mark the socket non-blocking before connecting and poll for completion,
applying fetchTimeout if set.

MFC after:      1 week
Reviewed by:    op
Differential Revision:  https://reviews.freebsd.org/D57909

(cherry picked from commit 848f360c8f9ae8d1d97c61f5d63fc624926d5dcd)
DeltaFile
+42-7lib/libfetch/common.c
+42-71 files

FreeBSD/src edf0ba5lib/libfetch common.c common.h

libfetch: Overhaul socket read / write

* Make fetch_ssl_read() and fetch_ssl_write() behave more like read(2)
  and write(2), and drop fetch_socket_read() in favor of read(2).

* Don't request POLLERR, it's implied.

* Don't needlessly set errno, it's relatively costly.

* Always check for EAGAIN from writev(2), otherwise we will abort on a
  short write instead of proceeding to poll(2).

* Always check for EAGAIN from poll(2) even though it can't happen on
  FreeBSD; POSIX says it can, and it might in the future.

* Rewrite fetch_read() and fetch_writev() to be more similar to each
  other.  The main difference is that a partial read is treated as
  success while a partial write is treated as failure.


    [6 lines not shown]
DeltaFile
+131-87lib/libfetch/common.c
+2-2lib/libfetch/common.h
+133-892 files

FreeBSD/src 520105clib/libfetch common.c http.c

libfetch: Reduce copying

Reduce the amount of copying we do when performing buffered reads.

MFC after:      1 week
Reviewed by:    op
Differential Revision:  https://reviews.freebsd.org/D58113

(cherry picked from commit 60382b4a04fa39e9bf65b964b1b7b4bed6eaa56a)
DeltaFile
+29-16lib/libfetch/common.c
+18-23lib/libfetch/http.c
+12-11lib/libfetch/ftp.c
+2-0lib/libfetch/common.h
+61-504 files

FreeBSD/src 0786814lib/libfetch common.h common.c

libfetch: Make fetch_ref an inline

Make fetch_ref() an inline and provide a fetch_deref().

MFC after:      1 week
Reviewed by:    op
Differential Revision:  https://reviews.freebsd.org/D57944

(cherry picked from commit d4e0e1fbc237f0765b9f32b291c087348031c921)
DeltaFile
+12-1lib/libfetch/common.h
+0-11lib/libfetch/common.c
+1-1lib/libfetch/ftp.c
+13-133 files

FreeBSD/src 98bfed5usr.bin/fetch fetch.c fetch.1

fetch: Stop setting an alarm

Now that fetchTimeout works reliably, setting an alarm is not only no
longer necessary but counterproductive, as it will trigger even if the
connection is not actually stalled but merely slow.

While here, improve the wording of the manual page's description of the
various options for setting a timeout.

MFC after:      1 week
Reviewed by:    op
Differential Revision:  https://reviews.freebsd.org/D57911

(cherry picked from commit 3dddfe29248c47d1a80dc96a76a308ae910b2a24)
DeltaFile
+9-24usr.bin/fetch/fetch.c
+6-4usr.bin/fetch/fetch.1
+15-282 files

FreeBSD/src a69d286lib/libfetch fetch.3

libfetch: Document fetchTimeout

Document the global fetchTimeout variable, now that it works reliably.

MFC after:      1 week
Reviewed by:    op
Differential Revision:  https://reviews.freebsd.org/D57910

(cherry picked from commit 27b411734c75a7a5abe641d7fbb99dfc622e9aba)
DeltaFile
+16-2lib/libfetch/fetch.3
+16-21 files

FreeBSD/src ad7a144lib/libfetch common.c

libfetch: Apply timeout to connection attempts

Mark the socket non-blocking before connecting and poll for completion,
applying fetchTimeout if set.

MFC after:      1 week
Reviewed by:    op
Differential Revision:  https://reviews.freebsd.org/D57909

(cherry picked from commit 848f360c8f9ae8d1d97c61f5d63fc624926d5dcd)
DeltaFile
+42-7lib/libfetch/common.c
+42-71 files

FreeBSD/src b56f3ealib/libfetch common.c common.h

libfetch: Overhaul socket read / write

* Make fetch_ssl_read() and fetch_ssl_write() behave more like read(2)
  and write(2), and drop fetch_socket_read() in favor of read(2).

* Don't request POLLERR, it's implied.

* Don't needlessly set errno, it's relatively costly.

* Always check for EAGAIN from writev(2), otherwise we will abort on a
  short write instead of proceeding to poll(2).

* Always check for EAGAIN from poll(2) even though it can't happen on
  FreeBSD; POSIX says it can, and it might in the future.

* Rewrite fetch_read() and fetch_writev() to be more similar to each
  other.  The main difference is that a partial read is treated as
  success while a partial write is treated as failure.


    [6 lines not shown]
DeltaFile
+131-87lib/libfetch/common.c
+2-2lib/libfetch/common.h
+133-892 files

FreeBSD/src fdef039lib/libfetch common.c http.c

libfetch: Add read buffering

Previously, we would read FTP control connection messages and HTTP
reponse headers one character at a time.  Now, we read as much as will
fit in our buffer and look for a newline.  If there is data left over,
it will be reused by the next fetch_getln() call.  This also requires
the addition of a fetch_bufread() which takes the buffer into account,
otherwise the start of the HTTP response body will be stuck in the
buffer after we read the last line of the header.

This should noticeably improve HTTP performance, especially for small
transfers.

MFC after:      1 week
Reviewed by:    op
Differential Revision:  https://reviews.freebsd.org/D57907

(cherry picked from commit a1978277379cf65f1339ab062f335c6f1fa6239f)
DeltaFile
+87-22lib/libfetch/common.c
+24-41lib/libfetch/http.c
+4-7lib/libfetch/ftp.c
+3-1lib/libfetch/common.h
+118-714 files

FreeBSD/src 2e38926sys/dev/hid u2f.c

hid: u2f: stop interrupts on last-close

This fixes an issue with the Solo2 (and likely some of the Nitrokey
family) where hangs would occur with OpenSSH- it issues a CANCEL prior
to closing the device unconditionally, and without draining the read
endpoint we end up seeing the response to that CANCEL the next time
OpenSSH tries to connect.  This throws the entire command/response
sequence out of whack.

This call used to break Yubikeys in some situations, but the fix that
landed in 28d85db46b48 ("xhci: Do not drop and add bits in xhci") seems
to have addressed that- presumably we sometimes end up stopping the
command and desyncing at the controller level.  This probably implies
that we need a SYNCWRITE HID quirk, but that requires a little more work
in usbhid_sync_xfer() and this doesn't seem to cause any problems in
normal usage.

Reviewed by:    aokblast, wulf
Differential Revision:  https://reviews.freebsd.org/D58199
DeltaFile
+0-3sys/dev/hid/u2f.c
+0-31 files

FreeBSD/src a5307a5sys/dev/usb/video uvideo.c

uvideo: fix use-after-free in mmap buffer lifetime management

The uvideo driver freed the mmap buffer (contigmalloc'd) in several
paths (VIDIOC_STREAMOFF, last close, detach) without coordinating
with the lifetime of existing user-space mmap mappings.  This could
lead to use-after-free when user-space continued to access the
mapped memory after the backing pages had been freed.

Fix this by switching from the simple d_mmap callback to d_mmap_single
with custom cdev_pager_ops, and by attaching the contig buffer to a
single shared vm_object created at REQBUFS time:

- uvideo_reqbufs() allocates a uvideo_mmap_state (independent of the
  softc) and a shared vm_object via cdev_pager_allocate() that spans
  the whole buffer; the softc holds one reference to it.
- uvideo_cdev_mmap_single() simply hands out additional references to
  that shared object; the requested offset selects which buffer is
  mapped.  The VM system tracks mapping lifetime through the object
  reference count, so no per-mapping bookkeeping is needed.

    [18 lines not shown]
DeltaFile
+162-14sys/dev/usb/video/uvideo.c
+162-141 files

FreeBSD/src a141337usr.sbin/bsdinstall/scripts netconfig

bsdinstall/netconfig: use a better heuristic for wlan dev desc

For devices like the rtw88, they will show up in `ifconfig -l` as
rtw880, rtw881, etc. We want to query the rtw88.0 and rtw88.1 sysctl
respectively, not rtw.880.

Chances are that there aren't more than 9 wlan devices using the same
driver. Use a better heuristic to get the device description.

Reviewed by:    bz
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit c4b0b13cadac46b7c2cdfeeedeffa596c62568fa)
DeltaFile
+1-1usr.sbin/bsdinstall/scripts/netconfig
+1-11 files

FreeBSD/src d860a73usr.bin/awk/tests/bugs-fixed bug_fix_test.sh

awk/tests: xfail inf-nan-torture on riscv64

The fix for this is being tracked upstream here:
https://github.com/onetrueawk/awk/issues/269

While here, just cd into $SRCDIR while executing tests,
since the test engine isolates every testcase's working
directory. This ensures that the xfail actually applies
to the next command.

Reviewed by:    mhorne
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit d0b1a389003b1e6ff5bcf35a7c04654ea7ff87bd)
DeltaFile
+8-4usr.bin/awk/tests/bugs-fixed/bug_fix_test.sh
+8-41 files