FreeBSD/src d830774 — stand/userboot/userboot libuserboot.h main.c

stand: userboot: improve userdisk error handling

Currently, userdisk_init() iterates through disks and
checks whether DIOCGSECTORSIZE and DIOCGMEDIASIZE ioctls
are available for the device. If either ioctl fails, userdisk_init()
returns ENXIO with ud_info only partially initialized.
devinit() records the failure, but loader_main() ignores
devinit()'s return value, so later code may access an
uninitialized entry.

In certain cases this code can still boot from a disk even if
userdisk_init() returns ENXIO, for example, when the first of
two disks is valid and the second errors out.

To address this issue while not breaking the current behavior, do
the following:

 - Zero-initialize the userdisk_info array and use a zero media size
   to mark disks that do not support the ioctls mentioned above or

    [16 lines not shown]
DeltaFile
+32-13stand/userboot/userboot/userboot_disk.c
+6-3stand/userboot/userboot/main.c
+1-0stand/userboot/userboot/libuserboot.h
+39-163 files

FreeBSD/src e48eb1c — . .mailmap

mailmap: Add entry for longros

Approved by:    jrm (mentor)
Differential Revision:  https://reviews.freebsd.org/D60912
DeltaFile
+2-0.mailmap
+2-01 files

FreeBSD/src ec1754a — usr.bin/diff diff.c

diff: diff regular files when `-q` is specified again

c30a321a61ce accidentally modified the code paths when diffing regular
files to not diff them if `-q` was specified. Call `diffreg(..)` again,
regardless of whether or not `-q` was specified to restore the
functionality pre-c30a321a61ce, while only printing out the result to
the console if `-q` is not specified.

This change unbreaks diff so 2 files which differ are reported again via
the exit code when with `-q` is specified.

MFC after:      3 days
PR:             299643
Reviewed by:    des
Differential Revision: https://reviews.freebsd.org/D60910
Fixes: c30a321a61ce ("diff: support -qq to output absolutely nothing")
DeltaFile
+3-3usr.bin/diff/diff.c
+3-31 files

FreeBSD/src e8923c7 — sys/amd64/linux linux_sysvec.c, sys/amd64/linux32 linux32_sysvec.c

devfs: make persistent controlling terminal an ABI property

Linux leaves the session's controlling terminal in place after the
last file descriptor on the slave is closed, so a later open of
/dev/tty succeeds.  FreeBSD drops the session vnode reference on that
close. /dev/tty then fails, which breaks Linux programs such as xterm
that close the pty slave during startup and expect /dev/tty to keep
working.

When the closer is a Linux process, leave the session reference in
place.  Still pass FLASTCLOSE to the driver so the master sees hangup.
Native close behavior is unchanged.

Add the SV_PERSISTENT_CTTY sysentvec flag for ABIs that retain the
controlling terminal after the last slave descriptor is closed.  This
keeps the devfs behavior ABI-agnostic and allows other ABIs to request
the same semantics if needed.  Use the flag in devfs_close().

Reviewed by:    kib

    [2 lines not shown]
DeltaFile
+7-1sys/fs/devfs/devfs_vnops.c
+3-2sys/i386/linux/linux_sysvec.c
+2-1sys/amd64/linux32/linux32_sysvec.c
+1-1sys/arm64/linux/linux_sysvec.c
+1-1sys/amd64/linux/linux_sysvec.c
+1-0sys/sys/sysent.h
+15-66 files

FreeBSD/src 44961ed — share/man/man4 termios.4

termios.4: clarify the behavior on the last close of controlling terminal

Reviewed by:    kib
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D60701
DeltaFile
+6-6share/man/man4/termios.4
+6-61 files

FreeBSD/src 07ab87b — sys/powerpc/powerpc mp_machdep.c

powerpc: powerpc_ipi_handler(): Stop first, preempt last

Preemption should happen last so that other IPIs have a chance to be
executed in due course, in particular hardclockintr().  So, move
handling of IPI_PREEMPT at the end.

An IPI_STOP/IPI_STOP_HARD request should be processed immediately to
avoid risks that further processing changes the system state on panic,
or worse itself causes another panic on corrupted kernel state.

While here, move IPI_AST handling just before IPI_PREEMPT.  We currently
do not need to do anything for it, but if we were to, it is likely that
would have to happen after other IPIs but IPI_PREEMPT.

Reviewed by:    jhibbits
Fixes:          9d5a22b928c2 ("MFp4: SMP support")
Fixes:          12640815f815 ("MFp4: SMP support")
Fixes:          7ed09a6778d3 ("powerpc: Rework IPI message processing")
MFC after:      1 week

    [2 lines not shown]
DeltaFile
+17-11sys/powerpc/powerpc/mp_machdep.c
+17-111 files

FreeBSD/src 3a0e2ca — sys/x86/x86 mp_x86.c

x86: ipi_bitmap_handler(): Account for IPIs correctly on COUNT_IPIS

A preemption could occur before the updates to the initial CPU's IPI
counters, leading to a potential non-atomic updates of these counters
from another CPU.

Reviewed by:    kib
Fixes:          ff326a187907 ("x86: Restore the critical section (...)")
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D60862
DeltaFile
+12-13sys/x86/x86/mp_x86.c
+12-131 files

FreeBSD/src b83bd6f — sys/x86/x86 mp_x86.c

x86: ipi_bitmap_handler(): Preempt last, reduce critical section

Preemption should happen last so that other IPIs have a chance to be
executed in due course, in particular hardclockintr().  So, move
handling of IPI_PREEMPT at the end.

Reduce the critical section to be in force only around hardclockintr(),
which needs it to execute entirely without preemption (because of code
it calls that can enter a critical section; interrupts are already
disabled in this handler, as usual).

The critical_exit() following hardclockintr() may cause preemption if
due.  If that happens, there is no need to preempt again on IPI_PREEMPT,
so make sure sched_preempt() is not called in this case.

This fixes inadvertent removal of the optimization that sched_preempt()
should be called outside of a critical section to perform an immediate
context switch in the case of IPI_HARDCLOCK and IPI_PREEMPT being
handled at the same time.

    [10 lines not shown]
DeltaFile
+27-18sys/x86/x86/mp_x86.c
+27-181 files

FreeBSD/src eefc98f — stand/userboot/userboot libuserboot.h main.c

stand: userboot: improve userdisk error handling

Currently, userdisk_init() iterates through disks and
checks whether DIOCGSECTORSIZE and DIOCGMEDIASIZE ioctls
are available for the device. If either ioctl fails, userdisk_init()
returns ENXIO with ud_info only partially initialized.
devinit() records the failure, but loader_main() ignores
devinit()'s return value, so later code may access an
uninitialized entry.

In certain cases this code can still boot from a disk even if
userdisk_init() returns ENXIO, for example, when the first of
two disks is valid and the second errors out.

To address this issue while not breaking the current behavior, do
the following:

 - Zero-initialize the userdisk_info array and use a zero media size
   to mark disks that do not support the ioctls mentioned above or

    [16 lines not shown]
DeltaFile
+32-13stand/userboot/userboot/userboot_disk.c
+6-3stand/userboot/userboot/main.c
+1-0stand/userboot/userboot/libuserboot.h
+39-163 files

FreeBSD/src ebf1041 — sys/dev/hyperv/utilities hv_kvp.c

hv_kvp: Fix some bugs and nits

- Use pending_mutex to synchronize several state flags.  In particular,
  ensure that two threads can't race to open the device file at the same
  time.[1]
- Fix an off-by-one in hv_kvp_dev_daemon_read() that would result in a
  one-byte OOB read if the caller supplied a large enough read buffer.[2]
- Change the device permissions to 0600: hv_kvp_dev_daemon_read()
  returns an error until the owning process registers itself with a
  write, so there's no sense in providing read-only access.
- Use bool instead of boolean_t.
- Don't return negative error numbers to userspace.
- Call seldrain() when closing the device.

Reported by:    pixelpop [1][2]
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D60387
DeltaFile
+28-39sys/dev/hyperv/utilities/hv_kvp.c
+28-391 files

FreeBSD/src a11b901 — sys/amd64/vmm/io vlapic.h vlapic.c

amd64/vmm: Port vlapic interface changes from illumos (duplicate)

This is a port of the bits related to vlapic-enablement of the following
bhyve improvement from illumos:

  14598 bhyve vlapic should handle APICBASE changes
  https://www.illumos.org/issues/14598

A LAPIC can be enabled/disabled in two ways:
  - by the global-enable bit in the APICBASE MSR
  - by the software-enable bit in the APIC's SVR register

This change allows distinguishing between both forms of enablement where
that matters. The more involved changes to allow guests to modify the
APICBASE MSR are not included at this time.

Reviewed by:    corvink, markj
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D56347
DeltaFile
+44-30sys/amd64/vmm/io/vlapic.c
+0-1sys/amd64/vmm/io/vlapic.h
+44-312 files

FreeBSD/src 0ce9d6e — contrib/openbsm/bin/auditdistd proto_common.c

auditdistd: Fix build failure

Fixes:          4f19e4aca4f4 ("auditdistd: Use void pointers for opaque data")
Reported by:    garga@
DeltaFile
+1-1contrib/openbsm/bin/auditdistd/proto_common.c
+1-11 files

FreeBSD/src dff56e8 — sbin/hastd proto_common.c

hastd: Fix build failure

Fixes:          a5e6bee5a0bf ("hastd: Use void pointers for opaque data")
Reported by:    garga@
DeltaFile
+1-1sbin/hastd/proto_common.c
+1-11 files

FreeBSD/src 8430de4 — sys/conf files, sys/dev/wg if_wg.c

wg: fix the LINT-NOIP build

We don't have anything to tunnel without INET or INET6, so just smack
it with the same config(5) hammer that ovpn uses and exclude it from
such builds.

Reported by:    mjg
Reviewed by:    emaste, markj
Differential Revision:  https://reviews.freebsd.org/D60896
DeltaFile
+4-4sys/conf/files
+0-2sys/dev/wg/if_wg.c
+4-62 files

FreeBSD/src 8208040 — sys/netpfil/pf pf_lb.c, tests/sys/netpfil/pf nat.sh

pf: first-match-wins for nat rules, even in anchors

Ensure we stop evaluating nat rules if we find a match in a nat-anchor.

PR:             299320
MFC after:      1 week
Sponsored by:   Rubicon Communications, LLC ("Netgate")

(cherry picked from commit b5219c068fbc133dde91d5cf48423e34ce27bd4f)
DeltaFile
+91-0tests/sys/netpfil/pf/nat.sh
+4-0sys/netpfil/pf/pf_lb.c
+95-02 files

FreeBSD/src a5e6bee — sbin/hastd proto_uds.c proto_tcp.c

hastd: Use void pointers for opaque data

Use void, not char, for pointers to opaque data in our send and receive
functions.

Sponsored by:   Klara, Inc.
Reviewed by:    allanjude
Differential Revision:  https://reviews.freebsd.org/D60729
DeltaFile
+4-4sbin/hastd/proto_impl.h
+2-2sbin/hastd/proto_uds.c
+2-2sbin/hastd/proto_tcp.c
+2-2sbin/hastd/proto_socketpair.c
+2-2sbin/hastd/proto_common.c
+12-125 files

FreeBSD/src 4f19e4a — contrib/openbsm/bin/auditdistd proto_uds.c proto_tls.c

auditdistd: Use void pointers for opaque data

Use void, not char, for pointers to opaque data in our send and receive
functions.

Sponsored by:   Klara, Inc.
Sponsored by:   Qualys, Inc.
Reviewed by:    emaste
Differential Revision:  https://reviews.freebsd.org/D60728
DeltaFile
+4-4contrib/openbsm/bin/auditdistd/proto_impl.h
+2-2contrib/openbsm/bin/auditdistd/proto_uds.c
+2-2contrib/openbsm/bin/auditdistd/proto_tls.c
+2-2contrib/openbsm/bin/auditdistd/proto_tcp.c
+2-2contrib/openbsm/bin/auditdistd/proto_socketpair.c
+2-2contrib/openbsm/bin/auditdistd/proto_common.c
+14-146 files

FreeBSD/src a317317 — lib/libpfctl libpfctl.c, sys/netpfil/pf pf_nl.h pf_ioctl.c

pf: Keep every chunk of a table that a ruleset defines

libpfctl sends a table definition in chunks of 256 addresses, each as
its own PFNL_CMD_INA_DEFINE.  The kernel treated every chunk as a new
definition and replaced the shadow table, so only the last chunk
survived.

Mark the chunks after the first with PF_ID_APPEND and have the kernel
add them to the shadow table in progress.  A request without the
attribute still replaces the shadow; one with it and no definition in
progress fails with EINVAL.  Old kernels ignore the attribute, so both
halves are needed; the ioctl sends all addresses at once and is not
affected.  Mask the flags userland passes to PFR_FLAG_ALLMASK, as
PFR_FLAG_APPEND is kernel-internal.

Add a test that defines a table of 1,000 addresses, also in an anchor.

Reviewed by:            kp
Fixes:                  219ce3063840 ("pf: convert DIOCRINADEFINE to netlink")

    [2 lines not shown]
DeltaFile
+70-0tests/sys/netpfil/pf/table.sh
+59-0sys/netpfil/pf/pf_table.c
+8-2lib/libpfctl/libpfctl.c
+5-0sys/netpfil/pf/pf_nl.c
+2-1sys/netpfil/pf/pf_ioctl.c
+1-0sys/netpfil/pf/pf_nl.h
+145-31 files not shown
+146-37 files

FreeBSD/src 6aa2c65 — sys/dev/spibus/controller/rockchip rk_spi.c

rk_spi: Do not change the clock with the driver lock held

The clock framework can sleep, it takes the clock topology sx lock.  Calling
clk_set_freq() and clk_get_freq() from rk_spi_hw_setup() with the driver
mutex held triggers a witness warning about a sleepable lock acquired after
a non-sleepable one, on the first transfer that raises the clock.

Set the clock in a new function that is called before taking the lock, and
only keep the register setup under the lock.
DeltaFile
+27-6sys/dev/spibus/controller/rockchip/rk_spi.c
+27-61 files

FreeBSD/src b82b744 — lib/libc/gen syslog.c getgrent.c, lib/libc/iconv bsd_iconv.c

libc: Preserve const qualifier on strchr(3), strrchr(3), and memchr(3) results

Reviewed by:    dteske, fuz
Approved by:    dteske (mentor), fuz (mentor)
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D59612

(cherry picked from commit 73d3c964be93034daf26a55ebac38c2152769f74)
DeltaFile
+4-3lib/libc/net/getaddrinfo.c
+2-2lib/libc/gen/getgrent.c
+1-2lib/libc/iconv/bsd_iconv.c
+2-1lib/libc/inet/inet_cidr_pton.c
+2-1lib/libc/gen/syslog.c
+1-1lib/libc/stdio/mktemp.c
+12-104 files not shown
+16-1410 files

FreeBSD/src 13d25dc — include wchar.h, sys/powerpc/include _stdint.h

libc: Add WCHAR_WIDTH in <wchar.h> as well

Define __WCHAR_WIDTH in sys/_types.h and derive WCHAR_WIDTH from
that, the same way as WCHAR_MIN and WCHAR_MAX, in both <wchar.h>
and <stdint.h> as per C23 §7.31.1 and §7.22.3.4, respectively.

Reviewed by:    fuz
Approved by:    fuz (mentor)
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D59385

(cherry picked from commit 72ed6f9c9dc95124cd81158d1c4437484a1b951e)
DeltaFile
+3-0sys/sys/stdint.h
+3-0include/wchar.h
+2-0sys/sys/_types.h
+0-1sys/x86/include/_stdint.h
+0-1sys/riscv/include/_stdint.h
+0-1sys/powerpc/include/_stdint.h
+8-32 files not shown
+8-58 files

FreeBSD/src 6ab9d00 — sys/arm/include _inttypes.h, sys/arm64/include _inttypes.h

libc: Add PRIb*, PRIB*, and SCNb* macros as per C23

Reviewed by:    fuz
Approved by:    fuz (mentor)
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D59293

(cherry picked from commit ab420c44bc7c45bf344cb03b289e60109f57aaee)
DeltaFile
+45-0sys/x86/include/_inttypes.h
+45-0sys/riscv/include/_inttypes.h
+45-0sys/powerpc/include/_inttypes.h
+45-0sys/arm64/include/_inttypes.h
+45-0sys/arm/include/_inttypes.h
+225-05 files

FreeBSD/src dca5970 — include stdbool.h

libc: Remove incorrectly defined __STDC_VERSION_STDBOOL_H__

C23 does not define __STDC_VERSION_STDBOOL_H__ for <stdbool.h>.
Feature test macros of this form only apply to headers where the
standard explicitly mandates one.

Reviewed by:    fuz
Approved by:    fuz (mentor)
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D59136

(cherry picked from commit 2712d1380fcd8dd61d043b2242f20767e8f2f347)
DeltaFile
+0-4include/stdbool.h
+0-41 files

FreeBSD/src 8f76613 — include stdio.h

libc: Add _PRINTF_NAN_LEN_MAX per C23

Reviewed by:    fuz
Approved by:    fuz (mentor)
MFC after:      1 month
Differential Revision: https://reviews.freebsd.org/D58842

(cherry picked from commit 10d5a548596ce7c111ea4a463d3f7d5f0cb1ae4f)
DeltaFile
+4-0include/stdio.h
+4-01 files

FreeBSD/src d3bad28 — share/misc bsd-family-tree

bsd-family-tree: polish grammar and style

Reviewed by:    ziaee
DeltaFile
+28-26share/misc/bsd-family-tree
+28-261 files

FreeBSD/src a2a0e5e — sys/netpfil/pf pf.c

pf: check extension header length.

pf_walk_header6() advances the packet offset for each IPv6 extension
header.  It was not checked that this does not exceed the packet
length if no next header was processed.  When used with af-to rules,
this could trigger a panic: m_copydata: null mbuf.

from Acts1631; OK henning@ sashan@

MFC after:      1 week
Obtained from:  OpenBSD, bluhm <bluhm at openbsd.org>, 6d56112588
Sponsored by:   Rubicon Communications, LLC ("Netgate")

(cherry picked from commit ccb19b359aae4b7e7315ad61d33d9a35d85849d1)
DeltaFile
+14-3sys/netpfil/pf/pf.c
+14-31 files

FreeBSD/src 3cbfe09 — sys/netpfil/pf pf.c

pf: check AH header length.

pf_walk_header() advances the packet offset for each AH extension
header.  It was not checked that this does not exceed the packet
length if no next header was processed.  Fix it like in IPv6.

OK henning@ sashan@

MFC after:      1 week
Obtained from:  OpenBSD, bluhm <bluhm at openbsd.org>, fcd4e5522e
Sponsored by:   Rubicon Communications, LLC ("Netgate")

(cherry picked from commit b4d2c9835c0edfddd1d6742afa86d4873ccfad16)
DeltaFile
+11-2sys/netpfil/pf/pf.c
+11-21 files

FreeBSD/src e6fb3b5 — sys/sys vnode.h

vfs: unbreak builds when MAC is not defined

Sorts out powerpc.QORIQ64 build failure.

Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+9-0sys/sys/vnode.h
+9-01 files

FreeBSD/src dbbff47 — sys/dev/gve gve_tx_dqo.c, sys/dev/random random_harvestq.c

Retire bogus predicts on case statements.

They are ignored by clang.

No functional changes (nor .o changes).

Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+3-3sys/kern/kern_malloc.c
+1-1sys/dev/random/random_harvestq.c
+1-1sys/dev/gve/gve_tx_dqo.c
+5-53 files

FreeBSD/src 93c05b7 — release/tools oci-image-static.conf

OCI: Remove dead code

We don't need to pick a repository URL when all we're doing is enabling
one which was specified in /etc/pkg/.

Reviewed by:    dch, imp
Fixes:  c73ae6734899 ("release/tools: use same pkg settings ...")
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D60868
DeltaFile
+0-8release/tools/oci-image-static.conf
+0-81 files