FreeBSD/src f1de8e3tools/tools/nanobsd defaults.sh

nanobsd: Register the boot.config file in the metalog

Ensure that the boot.config file gets an entry in the metalog by
tgt_touch()ing it.  If a file is not present in the metalog, it gets
excluded from the final image when using "-U" (unprivileged builds).

MFC after:      2 weeks
DeltaFile
+1-0tools/tools/nanobsd/defaults.sh
+1-01 files

FreeBSD/src 5435998tools/tools/nanobsd legacy.sh defaults.sh

nanobsd: Adjust the order of the flags in makefs

The order of the flags matter in makefs(8). The -t (type) flag must come
before the -o (options) flag; otherwise, the options are reset.

Move the -t flag before the -o flag and remove the shim function
_xxx_adjust_code_size() that was created to align to the default makefs
FFS values.

It effectively prevented us from generating NanoBSD images using
unprivileged builds with the partitions internally aligned as intended.

Reviewed by:    senguptaangshuman17_gmail.com, imp
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D57226
DeltaFile
+0-13tools/tools/nanobsd/legacy.sh
+2-2tools/tools/nanobsd/defaults.sh
+2-152 files

FreeBSD/src c579927tools/tools/nanobsd defaults.sh

nanobsd: Use makefs -R flag to honor rounded sizes

Switch from the min/max size flag (-s) to the round-up flag (-R) when
invoking makefs(8).

Because the partition sizes passed to nano_makefs have already been
rounded up by calculate_partitioning(), using -s can cause makefs to try
to perform sizing adjustments that usually result in failures.

Reviewed by:    imp
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D57225
DeltaFile
+1-1tools/tools/nanobsd/defaults.sh
+1-11 files

FreeBSD/src ca2d402tools/tools/nanobsd legacy.sh

nanobsd: Fix code image size formatting

mkimg(8) parses sizes using expand_number(3).  It is an error to use "b"
as a suffix.  This is the result of a confusion with makefs(8), which
uses NetBSD's strsuftoll(3).

Reviewed by:    imp
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D57224
DeltaFile
+1-1tools/tools/nanobsd/legacy.sh
+1-11 files

FreeBSD/src 87150a2tools/tools/nanobsd legacy.sh

nanobsd: Refactor secondary code partition logic

Rearrange the conditional logic for building the secondary code slice
(altroot).

Reviewed by:    imp
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D57223
DeltaFile
+19-18tools/tools/nanobsd/legacy.sh
+19-181 files

FreeBSD/src 318a85dtools/tools/nanobsd legacy.sh

nanobsd: Explicitly set image size and secsz in mkimg

When building an unprivileged NanoBSD image, explicitly set the desired
image size, by passing --capacity to mkimg in bytes, and the logical
sector size (-S) to 512 bytes.

Reviewed by:    imp
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D57222
DeltaFile
+3-3tools/tools/nanobsd/legacy.sh
+3-31 files

FreeBSD/src f1de49ftools/tools/nanobsd legacy.sh

nanobsd: Offset code partition to a track boundary

Ensure the primary and secondary code partitions start at a proper track
boundary by applying a NANO_SECTS offset in bytes.

While track-boundary alignment is largely obsolete on modern storage,
this change maintains compatibility with current images (legacy).  A
future commit will transition to 1 MiB alignment boundaries.

Reviewed by:    imp
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D57221
DeltaFile
+3-3tools/tools/nanobsd/legacy.sh
+3-31 files

FreeBSD/src dadbbcctools/tools/nanobsd legacy.sh

nanobsd: Account for metadata overhead in code slice

The code slice size (CODE_SIZE) includes 16 sectors reserved for disk
metadata (see bsdlabel(8) offset).  Subtract these 16 sectors from the
total size passed to nano_makefs.

This prevents the generated filesystem from consuming the entire slice
allocation, ensuring there is enough space for the metadata without
overflowing the partition boundary.

Reviewed by:    imp
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D57220
DeltaFile
+9-5tools/tools/nanobsd/legacy.sh
+9-51 files

FreeBSD/src beddf2ctools/tools/nanobsd legacy.sh

nanobsd: Use rounded sizes for cfg and data slices

Use the calculated (rounded up) cfg and data sizes from the
_.partitioning file, instead of consuming them directly from the global
variables.  We obtain the size of the cfg and data slices by explicitly
searching for index 3 and 4 respectively in the _.partitioning file.

This ensures that the final image has the rounded-up sizes, and not the
raw sizes.

Reviewed by:    imp
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D57219
DeltaFile
+4-2tools/tools/nanobsd/legacy.sh
+4-21 files

FreeBSD/src d2a9ad0tools/tools/nanobsd legacy.sh

nanobsd: Remove spurious exit call

Reviewed by:    imp
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D57217
DeltaFile
+0-1tools/tools/nanobsd/legacy.sh
+0-11 files

FreeBSD/src 9d133c7tools/tools/nanobsd legacy.sh

nanobsd: Get the code size by its partition index

Previously the code was assumed to be on the on the first line of the
_.partitioning file.  Instead, explicitly look up the size by its
partition index to make the parsing order-independent.

The _.partitioning file:

1. First column: starting sector.
2. Second column: size in 512-byte sectors.
3. Third column: partition index.

Get the code size by explicitly selecting when the partition index is 1.

Reviewed by:    imp
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D57216
DeltaFile
+3-3tools/tools/nanobsd/legacy.sh
+3-31 files

FreeBSD/src 689f746tools/tools/nanobsd legacy.sh

nanobsd: Use NANO_IMG1NAME

Do not hard-code _.disk.image, use NANO_IMG1NAME instead.

Reviewed by:    imp
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D57040
DeltaFile
+7-7tools/tools/nanobsd/legacy.sh
+7-71 files

FreeBSD/src 1dac971tools/tools/nanobsd legacy.sh

nanobsd: Minor style fixes

- Use $(...) notation instead of legacy backticked `...`
- Use tabs for indentation
- Indent continuation lines with 4 spaces

Reviewed by:    imp
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D57039
DeltaFile
+12-12tools/tools/nanobsd/legacy.sh
+12-121 files

FreeBSD/src aba599ainclude paths.h, usr.sbin/zzz zzz.8 zzz.c

zzz: Rewrite to use new power device

Previous script called acpiconf(8) (or apm(8) if ACPI wasn't supported,
although this was anyway redundant because APMIO just uses ACPI now).

Since a new generic power management interface was introduced, this isn't
sufficient, as this would only work for ACPI systems and for ACPI S3 suspend
(so no way to select suspend-to-idle). Rewrite in C to take advantage of the
new power interface.

We may want to add a switch to manually override the kern.power.suspend sysctl,
which is otherwise what the power device uses to decide which suspend type to
switch to (suspend-to-idle or firmware suspend), but this will require us to
amend the power interface.

Reviewed by:    olce, imp, mhorne, ziaee
Tested by:      mhorne
Approved by:    olce, imp, mhorne, ziaee
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D56918
DeltaFile
+41-45usr.sbin/zzz/zzz.8
+47-0usr.sbin/zzz/zzz.c
+0-41usr.sbin/zzz/zzz.sh
+3-1usr.sbin/zzz/Makefile
+1-0include/paths.h
+92-875 files

FreeBSD/src 7669a18etc/mtree BSD.usr.dist

mtree: usr: Add missing pkg/triggers entry

Reviewed by:    ivy
Fixes:          ea5e50c2985b ("packages: Add a mandoc package")
Differential Revision:  https://reviews.freebsd.org/D54682

(cherry picked from commit b8480379adcefaff0553aed1df67b249a0b194c8)
DeltaFile
+4-0etc/mtree/BSD.usr.dist
+4-01 files

FreeBSD/src 14b8531share/man/man4 Makefile, sys/amd64/conf MINIMAL

padlock: Restore padlock_rng to the amd64 build

Revert 88a53301e19 and d1ca01059d5 .  They removed padlock_rng from the
amd64 build under the mistaken belief that this device was available on
32-bit processors only.  But it's also available on the 64-bit Via Nano,
Nano X2, and some Zhaoxin CPUs.

PR:             295517
Fixes:          88a53301e19 ("padlock.4: only install on i386")
Fixes:          d1ca01059d5 ("padlock(4)/nehemiah: move i386-only entropy")
MFC after:      1 week
Reviewed by:    kib
Differential Revision: https://reviews.freebsd.org/D57215
DeltaFile
+0-7sys/i386/conf/NOTES
+1-4share/man/man4/Makefile
+1-3sys/modules/Makefile
+0-1sys/conf/files.i386
+1-0sys/conf/files.x86
+1-0sys/amd64/conf/MINIMAL
+4-152 files not shown
+6-158 files

FreeBSD/src be03b0fusr.sbin/syslogd syslogd_cap_log.c

syslogd: fix memory leak in casper_ttymsg()

nvlist_take_string_array(9) takes ownership of the array and its
strings. casper_ttymsg() freed neither, leaking memory on every
F_CONSOLE and F_TTY message. On long-running systems with high
error-rate syslog traffic routed to /dev/console, syslogd.casper grew
to hundreds of MB.

Use nvlist_get_string_array(9) to borrow the array instead. Update
casper_wallmsg() similarly.

Approved by:    src (des)
Closes:         https://github.com/freebsd/freebsd-src/pull/2222
Fixes:          61a29eca550b ("syslogd: Log messages using libcasper")
MFC after:      3 days
MFC to:         stable/15
PR:             295488
Reported by:    Pat Maddox <pat at patmaddox.com>
Reviewed by:    markj

    [3 lines not shown]
DeltaFile
+6-8usr.sbin/syslogd/syslogd_cap_log.c
+6-81 files

FreeBSD/src 3525c61lib/clang/libllvm Makefile

Fix building with LLVM_BINUTILS_BOOSTRAP but without CLANG_BOOTSTRAP

Without this change I get various undefined symbol errors when trying to
link llvm-nm and llvm-objcopy during the cross-tools stage.

Test Plan: builds now
Reviewed by:    dim, emaste
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D56873
DeltaFile
+35-35lib/clang/libllvm/Makefile
+35-351 files

FreeBSD/src 882181bsys/fs/p9fs p9_client.c p9_client.h

p9fs: Implement msize mount option and bump default to 128 KiB

QEMU warns when msize is <= 8192 due to degraded performance.
This change bumps our default msize to 128 KiB, matching the
Linux Kernel v5.15 and newer default. Linux supports even larger values,
but 128 KiB is a sensible default.

We also add a new 'msize' mount option to allow users to override
this value, and we validate it against our maximum supported MTU
(currently fixed by the UMA zone size).

Reviewed by:    markj
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D56496
DeltaFile
+8-1sys/fs/p9fs/p9_client.c
+5-2sys/fs/p9fs/p9_client.h
+1-1sys/fs/p9fs/p9fs_vfsops.c
+14-43 files

FreeBSD/src 675382fsys/dev/virtio/p9fs virtio_p9fs.c, sys/fs/p9fs p9_client.c p9_client.h

p9fs: Refactor buffer allocations to avoid zeroing large payloads

Allocating large buffers with M_ZERO adds unnecessary overhead since
the data is immediately overwritten. This change embeds the tc and rc
p9_buffer structs directly into p9_req_t so we only zero the small
metadata headers. The actual data payload is allocated with M_NOWAIT.

Embedding the metadata headers by value also allows the p9fs_buf_zone
UMA items to be sized exactly to P9FS_MTU, ensuring they are nicely
aligned.

This also adds proper error handling to p9_get_request() to handle
UMA allocation failures.

Reviewed by:    markj
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D56495
DeltaFile
+42-53sys/fs/p9fs/p9_client.c
+5-5sys/dev/virtio/p9fs/virtio_p9fs.c
+2-2sys/fs/p9fs/p9_client.h
+49-603 files

FreeBSD/src 004b593share/mk bsd.sys.mk

bsd.sys.mk: suppress some clang warnings for C++ for >= 19

I just tried building with system clang on one of my Linux systems which
happens to be version 19, and these warning suppressions are needed for
that version too: same errors as in the original commit.

Reviewed by:    imp
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D56874
DeltaFile
+0-2share/mk/bsd.sys.mk
+0-21 files

FreeBSD/src 77fd9e0crypto/openssh sshconnect2.c

upstream: fix hard-to-reach NULL deref during pubkey auth

To hit this, the user must be using a PEM style private key with no
corresponding .pub key adjacent to it.

OpenBSD-Commit-ID: b7150acc5322fa33f21491834d9471fbe3d30f20
(cherry picked from commit cf6c0b3b94cdc223f1b8be1ef2d93e993af5d976)

Reviewed by:    emaste
DeltaFile
+2-2crypto/openssh/sshconnect2.c
+2-21 files

FreeBSD/src b9d16b7sys/kern kern_sig.c, tests/sys/capsicum capmode.cc

sigqueue: In capability mode, only allow signalling self

This is copied from the check in kern_kill.

Reviewed by:    markj, oshogbo
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57244
DeltaFile
+9-3tests/sys/capsicum/capmode.cc
+10-0sys/kern/kern_sig.c
+19-32 files

FreeBSD/src c564074sys/netinet ip_divert.c

divert: Avoid using atomic_(load|store)_(acq|rel)_16

It's not implemented on some arches.  Use a plain int to count the
number of sockets in a divert lbgroup.

Reported by:    Jenkins
Fixes:          895a0ae67fe2 ("divert: Define semantics for SO_REUSEPORT_LB on divert sockets")
DeltaFile
+7-5sys/netinet/ip_divert.c
+7-51 files

FreeBSD/src 00b96a7sys/amd64/amd64 trap.c

amd64: Drop segment descriptor details from trap messsages

Segment descriptor contents are fixed on amd64 and not very interesting
compared to the other values that are displayed.

While here, include both the thread and process details of the current
thread and drop redundant output of the trap number.

Reviewed by:    kib
Differential Revision:  https://reviews.freebsd.org/D56989
DeltaFile
+3-13sys/amd64/amd64/trap.c
+3-131 files

FreeBSD/src 2750d95sys/netinet tcp_log_buf.c

tcp: fix TCP_ACCOUNTING build

The uninitialized timeval was discovered by the new clang.
DeltaFile
+1-0sys/netinet/tcp_log_buf.c
+1-01 files

FreeBSD/src 2ca9d92lib/libc/gen nlist.3

nlist.3: Add discouraged use notice

It is a relic from a.out days and is poorly specified. Although ELF
support was added to nlist, there are better ways to access ELF data.

Reviewed by:    kib
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57078

(cherry picked from commit 94b7a335683abcbcd76e8b67d37e21271d81590c)
(cherry picked from commit be2da08e0b5b82329e36a6cf3b98f9099c6184ce)
DeltaFile
+4-0lib/libc/gen/nlist.3
+4-01 files

FreeBSD/src 5083252lib/libc/gen nlist.3

nlist.3: Clarify which symbol table is used

nlist() requires section headers, and currently fetches symbol names
only from SHT_SYMTAB,

Reviewed by:    kib
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57065

(cherry picked from commit cd6bf930eafe850dc631feeaf8332832601f4225)
(cherry picked from commit e25366d46bf5cdd840d2827524f9ed29e2fcbc66)
DeltaFile
+5-3lib/libc/gen/nlist.3
+5-31 files

FreeBSD/src fea07b7lib/libc/gen nlist.3

nlist.3: Replace a.out(5) Xref with elf(5)

ELF support was added to nlist() in 1997, and a.out support was removed
in 2020.  The man page was not updated for either of these changes.

Fixes: 77909f597881 ("Initial elf nlist support, ...")
Fixes: 86cfa7e70b2b ("nlist: retire long-obsolete aout support")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 876a17321c896427d70de94101df4d888a19189b)

struct nlist is documented in both a.out(5) and stab(5), so add an Xref
to the latter.

(cherry picked from commit 762e451b318c8cbfddbcaaa92a218e8b45306eb9)
(cherry picked from commit 9d9651c49575e27f2873c10bb7fe855be29ff48a)
DeltaFile
+4-5lib/libc/gen/nlist.3
+4-51 files

FreeBSD/src 9d9651clib/libc/gen nlist.3

nlist.3: Replace a.out(5) Xref with elf(5)

ELF support was added to nlist() in 1997, and a.out support was removed
in 2020.  The man page was not updated for either of these changes.

Fixes: 77909f597881 ("Initial elf nlist support, ...")
Fixes: 86cfa7e70b2b ("nlist: retire long-obsolete aout support")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 876a17321c896427d70de94101df4d888a19189b)

struct nlist is documented in both a.out(5) and stab(5), so add an Xref
to the latter.

(cherry picked from commit 762e451b318c8cbfddbcaaa92a218e8b45306eb9)
DeltaFile
+4-3lib/libc/gen/nlist.3
+4-31 files