FreeBSD/src f8cee1fcontrib/mtree mtree.c spec.c

Import latest mtree from NetBSD

Merge commit 'eb2ccba0c11b405ac613c3046997765317cc8b5c'

PR:             192839
PR:             219467
MFC after:      1 week
DeltaFile
+22-14contrib/mtree/mtree.c
+11-14contrib/mtree/spec.c
+6-10contrib/mtree/compare.c
+4-3contrib/mtree/create.c
+43-414 files

FreeBSD/src eb2ccba. mtree.c spec.c

Vendor import of NetBSD's mtree at 2025-12-19
DeltaFile
+22-14mtree.c
+12-15spec.c
+7-11compare.c
+4-3create.c
+45-434 files

FreeBSD/src fe53a8asys/net bpf_ifnet.c

bpf: add missing IFT_BRIDGE in the write method

Fixes:  8774a990ee4094f16d596d4b78e0f3239e5d0c88
DeltaFile
+1-0sys/net/bpf_ifnet.c
+1-01 files

FreeBSD/src 525766fsys/kern init_main.c

Revert "sys: Bump 32-bit kernel removal to 16.0"

32-bit powerpc and i386 kernels still exist in 14.x, so we don't want to
imply that those may persist until 16.0.  The message only claims that
the kernels "may be" removed in 15.0 anyhow.

This reverts commit c19688407a2c797e74762aebd90c1f1cc70ab726.

Reported by:    jhb
DeltaFile
+1-1sys/kern/init_main.c
+1-11 files

FreeBSD/src ed6612dusr.sbin/devinfo devinfo.c devinfo.8

Revert "devinfo: Add support for libxo"

This broke the human output formatting in several ways.

This reverts commit 4cf5878d27ddc9d3ca3ed870f88112c3b4f6fb69.
This reverts commit e8d6b58ef5a4afe0d155b6967c92d55f3bbd53fe.
This reverts commit c759aca606cee8352c1d739bf7a762c8a2ed2012.

PR:             291511
Reviewed by:    imp, des
Differential Revision:  https://reviews.freebsd.org/D54196

(cherry picked from commit 43b07bdbc5d24febc7a904d16f05f921c478eaa7)
DeltaFile
+37-179usr.sbin/devinfo/devinfo.c
+1-13usr.sbin/devinfo/devinfo.8
+1-1usr.sbin/devinfo/Makefile
+39-1933 files

FreeBSD/src 307cbd4sys/kern kern_proc.c kern_fork.c

proc: Fix proc_init / proc_dtor ordering issues

* Move the initialization of p_ktr into proc_init() and make the check
  in proc_dtor() unconditional.  Prior to this, it was possible to fail
  and invoke proc_dtor() after the first thread had been created (which
  was the condition for checking p_ktr in proc_dtor()) but before p_ktr
  had been initialized.

* Move the p_klist initialization in fork1() past the last possible
  failure point so we don't have to free it on failure.  We didn't,
  which meant we were leaking a knlist every time we failed to fork
  due to hitting the resource limit.

PR:             291470
MFC after:      1 week
Reviewed by:    kib
Differential Revision:  https://reviews.freebsd.org/D54215

(cherry picked from commit 026d962ef14dafe19fa73361bea6dcc95f141dfa)
DeltaFile
+4-4sys/kern/kern_proc.c
+2-2sys/kern/kern_fork.c
+6-62 files

FreeBSD/src 0c37e6esbin/ipf/libipf interror.c, sys/netpfil/ipfilter/netinet ip_sync.c

ipfilter: Prevent stack buffer overflow

When copying ipfs data from user space, don't just check that the payload
length is nonzero, but also that it does not exceed the size of the stack
buffer we're copying it into.

While we're at it, use a union to create a buffer of the exact size we
need instead of guessing that 2048 will be enough (and not too much).

Finally, check the size of the payload once it gets to where it's used.

MFC after:      3 days
Reported by:    Ilja Van Sprundel <ivansprundel at ioactive.com>
Reviewed by:    cy
Differential Revision:  https://reviews.freebsd.org/D54194

(cherry picked from commit a34c50fbd2a52bb63acde82e5aec4cb57880e39b)
DeltaFile
+37-14sys/netpfil/ipfilter/netinet/ip_sync.c
+5-0sbin/ipf/libipf/interror.c
+42-142 files

FreeBSD/src b063e9csys/kern vfs_syscalls.c kern_jail.c

vfs: Let prison_enforce_statfs zero the fsid

Currently, we unconditionally zero the fsid before returning a struct
statfs to a jailed process.  Move this into prison_enforce_statfs() so
it only happens if enforce_statfs is greater than 1, or enforce_statfs
is 1 but the mountpoint is outside the jail.

PR:             291301
MFC after:      1 week
Reviewed by:    kib
Differential Revision:  https://reviews.freebsd.org/D54214

(cherry picked from commit d4f25d0c7957f0f1960028eec82625c2d6405537)
DeltaFile
+1-4sys/kern/vfs_syscalls.c
+3-0sys/kern/kern_jail.c
+4-42 files

FreeBSD/src 1a67e18sbin/ipf/libipf interror.c, sys/netpfil/ipfilter/netinet ip_sync.c

ipfilter: Prevent stack buffer overflow

When copying ipfs data from user space, don't just check that the payload
length is nonzero, but also that it does not exceed the size of the stack
buffer we're copying it into.

While we're at it, use a union to create a buffer of the exact size we
need instead of guessing that 2048 will be enough (and not too much).

Finally, check the size of the payload once it gets to where it's used.

MFC after:      3 days
Reported by:    Ilja Van Sprundel <ivansprundel at ioactive.com>
Reviewed by:    cy
Differential Revision:  https://reviews.freebsd.org/D54194

(cherry picked from commit a34c50fbd2a52bb63acde82e5aec4cb57880e39b)
DeltaFile
+37-14sys/netpfil/ipfilter/netinet/ip_sync.c
+5-0sbin/ipf/libipf/interror.c
+42-142 files

FreeBSD/src 90e09bfsys/kern vfs_syscalls.c kern_jail.c

vfs: Let prison_enforce_statfs zero the fsid

Currently, we unconditionally zero the fsid before returning a struct
statfs to a jailed process.  Move this into prison_enforce_statfs() so
it only happens if enforce_statfs is greater than 1, or enforce_statfs
is 1 but the mountpoint is outside the jail.

PR:             291301
MFC after:      1 week
Reviewed by:    kib
Differential Revision:  https://reviews.freebsd.org/D54214

(cherry picked from commit d4f25d0c7957f0f1960028eec82625c2d6405537)
DeltaFile
+1-4sys/kern/vfs_syscalls.c
+3-0sys/kern/kern_jail.c
+4-42 files

FreeBSD/src 00bdb83sys/kern kern_proc.c kern_fork.c

proc: Fix proc_init / proc_dtor ordering issues

* Move the initialization of p_ktr into proc_init() and make the check
  in proc_dtor() unconditional.  Prior to this, it was possible to fail
  and invoke proc_dtor() after the first thread had been created (which
  was the condition for checking p_ktr in proc_dtor()) but before p_ktr
  had been initialized.

* Move the p_klist initialization in fork1() past the last possible
  failure point so we don't have to free it on failure.  We didn't,
  which meant we were leaking a knlist every time we failed to fork
  due to hitting the resource limit.

PR:             291470
MFC after:      1 week
Reviewed by:    kib
Differential Revision:  https://reviews.freebsd.org/D54215

(cherry picked from commit 026d962ef14dafe19fa73361bea6dcc95f141dfa)
DeltaFile
+4-4sys/kern/kern_proc.c
+2-2sys/kern/kern_fork.c
+6-62 files

FreeBSD/src 594ed1asbin/ipf/libipf interror.c, sys/netpfil/ipfilter/netinet ip_sync.c

ipfilter: Prevent stack buffer overflow

When copying ipfs data from user space, don't just check that the payload
length is nonzero, but also that it does not exceed the size of the stack
buffer we're copying it into.

While we're at it, use a union to create a buffer of the exact size we
need instead of guessing that 2048 will be enough (and not too much).

Finally, check the size of the payload once it gets to where it's used.

MFC after:      3 days
Reported by:    Ilja Van Sprundel <ivansprundel at ioactive.com>
Reviewed by:    cy
Differential Revision:  https://reviews.freebsd.org/D54194

(cherry picked from commit a34c50fbd2a52bb63acde82e5aec4cb57880e39b)
DeltaFile
+37-14sys/netpfil/ipfilter/netinet/ip_sync.c
+5-0sbin/ipf/libipf/interror.c
+42-142 files

FreeBSD/src faac795sys/kern kern_proc.c kern_fork.c

proc: Fix proc_init / proc_dtor ordering issues

* Move the initialization of p_ktr into proc_init() and make the check
  in proc_dtor() unconditional.  Prior to this, it was possible to fail
  and invoke proc_dtor() after the first thread had been created (which
  was the condition for checking p_ktr in proc_dtor()) but before p_ktr
  had been initialized.

* Move the p_klist initialization in fork1() past the last possible
  failure point so we don't have to free it on failure.  We didn't,
  which meant we were leaking a knlist every time we failed to fork
  due to hitting the resource limit.

PR:             291470
MFC after:      1 week
Reviewed by:    kib
Differential Revision:  https://reviews.freebsd.org/D54215

(cherry picked from commit 026d962ef14dafe19fa73361bea6dcc95f141dfa)
DeltaFile
+4-4sys/kern/kern_proc.c
+2-2sys/kern/kern_fork.c
+6-62 files

FreeBSD/src 3ed0824sys/vm vm_glue.c

vm: Fix kstack alignment assertion

The expectation that the allocation will be aligned to the kstack size
only applies when allocating from a kstack arena, not when allocating a
non-standard size from the kernel arena.

MFC after:      1 week
Sponsored by:   Klara, Inc.
Sponsored by:   NetApp, Inc.
Fixes:          7a79d0669761 ("vm: improve kstack_object pindex calculation to avoid pindex holes")
Reviewed by:    bnovkov, siderop1_netapp.com
Differential Revision:  https://reviews.freebsd.org/D54171

(cherry picked from commit a35545ee02680cee04c354b50182dd94d4489666)
DeltaFile
+6-4sys/vm/vm_glue.c
+6-41 files

FreeBSD/src b431599sys/kern vfs_syscalls.c kern_jail.c

vfs: Let prison_enforce_statfs zero the fsid

Currently, we unconditionally zero the fsid before returning a struct
statfs to a jailed process.  Move this into prison_enforce_statfs() so
it only happens if enforce_statfs is greater than 1, or enforce_statfs
is 1 but the mountpoint is outside the jail.

PR:             291301
MFC after:      1 week
Reviewed by:    kib
Differential Revision:  https://reviews.freebsd.org/D54214

(cherry picked from commit d4f25d0c7957f0f1960028eec82625c2d6405537)
DeltaFile
+1-4sys/kern/vfs_syscalls.c
+3-0sys/kern/kern_jail.c
+4-42 files

FreeBSD/src 4100bd6. ObsoleteFiles.inc, share/man/man1 builtin.1

usr.bin: Remove intrinsic utilities

These utilities can only function correctly if implemented as shell
builtins and exist only because POSIX previously required them.  As of
POSIX 2024, they have all been reclassified as intrinsic utilities and
are no longer required to exist in PATH.  We can therefore retire them.
Cf. XBD 1.7, XRAT C.1.8, Austin Group bug 854.

Note that kill(1) is also considered an intrinsic utility (because
only the shell can interpret job IDs correctly), but we have a working
standalone implementation, which we will keep.

PR:             291686
Relnotes:       yes
Reviewed by:    imp, emaste
Differential Revision:  https://reviews.freebsd.org/D54239
DeltaFile
+16-22share/man/man1/builtin.1
+0-19usr.bin/alias/Makefile
+17-0ObsoleteFiles.inc
+0-10usr.bin/alias/Makefile.depend
+1-2usr.bin/Makefile
+0-3usr.bin/alias/generic.sh
+34-561 files not shown
+34-577 files

FreeBSD/src 33bc1fbsys/netlink netlink_snl.h

netlink: Don't overwrite existing data in a linear buffer in snl_writer

First, a bit of background on some of the data structures netlink uses
to manage data associated with a netlink connection.

- struct linear_buffer contains a single virtually-contiguous buffer
  of bytes.  Regions of this buffer are suballocated via lb_allocz()
  which uses a simple "bump" where the buffer is split into an
  allocated region at the start and a free region at the end.  Each
  allocation "bumps" the boundary (lb->offset) forward by the
  allocation size.

  Individual allocations are not freed.  Instead, the entire buffer is
  freed once all of the allocations are no longer in use.

  Linear buffers also contain an embedded link to permit chaining
  buffers together.

- snl_state contains various state for a netlink connection including

    [52 lines not shown]
DeltaFile
+9-11sys/netlink/netlink_snl.h
+9-111 files

FreeBSD/src c8b3b60sys/netinet ip_output.c

tcp: fix checksum calculation bug

The new function in_delayed_cksum_o() was introduced to compute
the checksum in the case the mbuf chain does not start with the
IP header. The offset of the IP header is specified by the
parameter iph_offset.
If iph_offset was positive, the function computed an incorrect
checksum.

Reviewed by:            sobomax, tuexen
Fixes:                  5feb38e37847 ("netinet: provide "at offset" variant of the in_delayed_cksum() API")
MFC after:              1 week
Differential Revision:  https://reviews.freebsd.org/D54269
DeltaFile
+2-2sys/netinet/ip_output.c
+2-21 files

FreeBSD/src 8da838asys/dev/virtio/network if_vtnet.c

vtnet: improve consistency

Use sbuf_new_for_sysctl() instead of sbuf_new_auto() when exposing
the flags via sysctl.

MFC after:              1 week
DeltaFile
+6-8sys/dev/virtio/network/if_vtnet.c
+6-81 files

FreeBSD/src 634d9c0share/man/man4 vtnet.4, sys/dev/virtio/network if_vtnet.c virtio_net.h

vtnet: expose features via sysctl tree

Right now the 64-bit flags field needs to be casted to a 32-bit field,
because clang warns if more than 32-bits are used.
Once clang is fixed, this restriction will be removed and more bits
will be added.

Reviewed by:            markj, Timo Völker
MFC after:              1 week
Differential Revision:  https://reviews.freebsd.org/D54288
DeltaFile
+18-0sys/dev/virtio/network/if_vtnet.c
+8-0sys/dev/virtio/network/virtio_net.h
+3-1share/man/man4/vtnet.4
+29-13 files

FreeBSD/src d2cb9cashare/man/man9 printf.9, sys/kern subr_prf.c

printf.9: Support more than 32 bits in %b

This will be usable after clang has been extended to accept length
modifiers for %b when compiling kernel code.
But we need FreeBSD to support it first...

Reviewed by:            markj, Timo Völker
MFC after:              1 week
Differential Revision:  https://reviews.freebsd.org/D54286
DeltaFile
+31-9sys/kern/subr_prf.c
+18-7share/man/man9/printf.9
+49-162 files

FreeBSD/src a79e227sbin/ipf/libipf interror.c, sys/netpfil/ipfilter/netinet fil.c ip_fil.h

ipf: copy{in,out}ptr -> ipf_copy{in,out}_indirect

These functions take the source or destintation address indirectly from
a potentially missaligned buffer.  Rename them to refect this and to
free up the copy{in,out}ptr names.

Some of the code in question is dead code and doesn't or won't compile,
but I've changed it all for consistency.

NB: If the pointers are actually stored under aligned then this code is
broken with CHERI.

Reviewed by:    cy
Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Differential Revision:  https://reviews.freebsd.org/D54232
DeltaFile
+4-4sys/netpfil/ipfilter/netinet/fil.c
+3-2sys/netpfil/ipfilter/netinet/ip_fil.h
+3-2sys/netpfil/ipfilter/netinet/ip_auth.c
+2-2sys/netpfil/ipfilter/netinet/ip_scan.c
+2-2sys/netpfil/ipfilter/netinet/ip_proxy.c
+2-2sbin/ipf/libipf/interror.c
+16-141 files not shown
+18-167 files

FreeBSD/src ebb0e51sys/kern init_main.c

thread0: Clear td_rux stats in proc0_post

proc0_post aims to reset the CPU usage accounting for all threads and
processes in the system to zero once the time of day is verified.
However, not all of the per-thread stats were not being cleared,
resulting in over-reported time for thread0 post-boot.

Reviewed by:    olce, kib, markj
Fixes:          bed4c5241663 ("Implement RUSAGE_THREAD. Add td_rux...")
Differential Revision:  https://reviews.freebsd.org/D54040
(cherry picked from commit dafe50ebd874ca3ccd5908c441cee9f478c501f0)
DeltaFile
+6-2sys/kern/init_main.c
+6-21 files

FreeBSD/src 444d2f9tools/build/mk OptionalObsoleteFiles.inc, usr.sbin/bsdinstall/scripts mount_aux mount

bsdinstall: Mount /dev and /packages after using the shell to partition disks

Normally after partitions are created by the installer, the 'mount'
script is used to mount the target disk partitions under /mnt.  The
tail end of this script also mounts a couple of additional filesystems
under /mnt so that chrooted programs can work such as devfs and
/packages.

When the "Shell" option is used to permit the user to manually mount
the destination filesystem, the "mount" script is not used as the user
is instructed to mount the target filesystems and construct
/mnt/etc/fstab, etc.  However, this means that the user is responsible
for mounting devfs (which is not included in /etc/fstab) and /packages
as well.  The help message for the "Shell" option doesn't mention
these requirements, so users may not know to do so.  This can lead to
confusing errors as chrooted commands can fail to find needed /dev
entries.  For example, running fwget to fetch wireless firmware fails
because /dev/pci doesn't exist.


    [12 lines not shown]
DeltaFile
+39-0usr.sbin/bsdinstall/scripts/mount_aux
+1-9usr.sbin/bsdinstall/scripts/mount
+1-0usr.sbin/bsdinstall/scripts/Makefile
+1-0usr.sbin/bsdinstall/scripts/auto
+1-0tools/build/mk/OptionalObsoleteFiles.inc
+43-95 files

FreeBSD/src 6a99a27sys/kern subr_rman.c

rman: Simplify initialization of internal globals

Use TAILQ_HEAD_INITIALIZER and MTX_SYSINIT to remove the 'once' code
from rman_init.

Reviewed by:    des
Differential Revision:  https://reviews.freebsd.org/D54142

(cherry picked from commit a35eae89cbddaac73d3b6c2b5c1b90e3a0c00997)
DeltaFile
+3-9sys/kern/subr_rman.c
+3-91 files

FreeBSD/src 84140c9share/man/man4 nvmf_tcp.4

nvmf_tcp.4: Don't quote the document description given to .Nd

Reported by:    ziaee

(cherry picked from commit d8556d2bad4074258fb11c0c7ee997ad78dadf87)
DeltaFile
+1-1share/man/man4/nvmf_tcp.4
+1-11 files

FreeBSD/src c358d6csys/kern init_main.c

proc0_post: Clear relevant thread stats directly

rufetch() has several other effects besides clearing these per-thread
stats most of which are explicitly discarded by the subsequent calls
to ruxreset().  Just clear the relevant stats directly instead.

Reviewed by:    olce, kib, markj
Differential Revision:  https://reviews.freebsd.org/D54050

(cherry picked from commit acd02443a952b1f5412d35d03f081ad48bae34d7)
DeltaFile
+6-3sys/kern/init_main.c
+6-31 files

FreeBSD/src c512446sys/kern init_main.c

thread0: Stop calling thread0 "swapper"

Just leave it as "kernel".  While here, replace "parked" with "-" (the
typical wait channel for idle threads).

Reviewed by:    olce, kib, markj
Differential Revision:  https://reviews.freebsd.org/D54039

(cherry picked from commit 431b3b224db2a69d09c359ce1cfb37ba3da4705c)
DeltaFile
+3-3sys/kern/init_main.c
+3-31 files

FreeBSD/src b35c637sys/kern init_main.c, sys/sys proc.h

ruxreset: Add an inline function to reset all the stats in rusage_ext

Use it in proc0_post to reset per-process CPU usage.

Suggested by:   olce
Reviewed by:    olce, kib
Differential Revision:  https://reviews.freebsd.org/D54049

(cherry picked from commit 3f8ed605dbd0ee211ce8fe59c0c072b916d6311c)
DeltaFile
+12-0sys/sys/proc.h
+1-4sys/kern/init_main.c
+13-42 files

FreeBSD/src 6cafc75sys/arm/arm pmap-v6.c, sys/i386/i386 pmap.c

sys: Remove/update references to the swapper process in various comments

Reviewed by:    olce, markj
Differential Revision:  https://reviews.freebsd.org/D54051

(cherry picked from commit f6910b09a2302df9b3b1666deb89037c831a4e4c)
DeltaFile
+1-4sys/sys/sleepqueue.h
+1-1sys/i386/i386/pmap.c
+1-1sys/arm/arm/pmap-v6.c
+1-1sys/sys/proc.h
+1-1sys/vm/vnode_pager.c
+5-85 files