FreeBSD/src bfb1941 — sys/fs/cd9660 iso_rrip.h cd9660_vfsops.c, tests/sys/fs/cd9660 Makefile cd9660_test.sh

cd9660: Fix dereferencing invalid RR outlen ptr

`ISO_RRIP_ANALYZE` is constructed in four places. Two of the
initializers set the `outlen` field while the other two,
`cd9660_rrip_analyze` and `cd9660_rrip_offset`, leave it uninitialized.

The uninitialized paths can dereference an invalid pointer on error
paths which causes a kernel panic.

To fix, I zero out `ISO_RRIP_ANALYZE` in all four places where it's
initialized and check that `outlen` is non-null on the error path
in `cd9660_rrip_loop`.

While testing the above, I encountered another kernel panic due to
mounting continuing after the error branch. Evidently, the ISO continued
mounting through the normal ISO 9660 path then triggered a panic down
the line due to a very broken file system from the ISO. To fix that, I
propagate the error from the RR path then fail in the mount path.


    [13 lines not shown]
DeltaFile
+226-0tests/sys/fs/cd9660/rrip_corrupt.c
+72-0tests/sys/fs/cd9660/cd9660_test.sh
+17-6sys/fs/cd9660/cd9660_rrip.c
+10-0tests/sys/fs/cd9660/Makefile
+6-3sys/fs/cd9660/cd9660_vfsops.c
+1-1sys/fs/cd9660/iso_rrip.h
+332-102 files not shown
+335-108 files

FreeBSD/src d668d96 — usr.bin/top top.1 top.c

top: allow filtering by command name

top(1) already supports interactive command filtering using
the '/' key. Support it also with a command line
argument '-g' / '--grep'.

Reviewed by:    kib
Obtained from:  OpenBSD
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D61160
DeltaFile
+12-2usr.bin/top/top.c
+9-1usr.bin/top/top.1
+21-32 files

FreeBSD/src e89fac0 — sys/fs/cd9660 iso_rrip.h cd9660_vfsops.c, tests/sys/fs/cd9660 Makefile cd9660_test.sh

cd9660: Fix dereferencing invalid RR outlen ptr

`ISO_RRIP_ANALYZE` is constructed in four places. Two of the
initializers set the `outlen` field while the other two,
`cd9660_rrip_analyze` and `cd9660_rrip_offset`, leave it uninitialized.

The uninitialized paths can dereference an invalid pointer on error
paths which causes a kernel panic.

To fix, I zero out `ISO_RRIP_ANALYZE` in all four places where it's
initialized and check that `outlen` is non-null on the error path
in `cd9660_rrip_loop`.

While testing the above, I encountered another kernel panic due to
mounting continuing after the error branch. Evidently, the ISO continued
mounting through the normal ISO 9660 path then triggered a panic down
the line due to a very broken file system from the ISO. To fix that, I
propagate the error from the RR path then fail in the mount path.


    [13 lines not shown]
DeltaFile
+226-0tests/sys/fs/cd9660/rrip_corrupt.c
+72-0tests/sys/fs/cd9660/cd9660_test.sh
+17-6sys/fs/cd9660/cd9660_rrip.c
+10-0tests/sys/fs/cd9660/Makefile
+6-3sys/fs/cd9660/cd9660_vfsops.c
+1-1sys/fs/cd9660/iso_rrip.h
+332-102 files not shown
+335-108 files

FreeBSD/src e1e4790 — usr.sbin/bhyve rfb.c

bhyve: rfb: do not destroy a mutex that was never initialized

rfb_init()'s error path tests pixfmt_mtx against NULL, which only
compiles where pthread_mutex_t is a pointer, and destroys it.  Every
jump to that label is before the mutex is initialized, so there is
nothing to destroy.  The test and the destroy came in with the
SetPixelFormat support (D46402).

Signed-off-by:  Wanpeng Qian <wanpengqian at gmail.com>

Fixes:          dda0f9837b1c ("bhyve: support noVNC SetPixelFormat request")
Reviewed by:    markj
MFC after:      1 week
Sponsored by:   keelos.dev
Differential Revision:  https://reviews.freebsd.org/D61425
DeltaFile
+0-2usr.sbin/bhyve/rfb.c
+0-21 files

FreeBSD/src b386040 — usr.sbin/bhyve pci_nvme.c

bhyve: nvme: initialize the AEN condition variable

aen_cond is used with pthread_cond_wait() and pthread_cond_signal() but
never initialized.  That works where a zeroed pthread_cond_t is
initialized on first use; elsewhere pthread_cond_wait() fails at once
and aen_thr() spins with aen_mtx held.

Signed-off-by:  Wanpeng Qian <wanpengqian at gmail.com>

Reviewed by:    markj
MFC after:      1 week
Sponsored by:   keelos.dev
Differential Revision:  https://reviews.freebsd.org/D61424
DeltaFile
+1-0usr.sbin/bhyve/pci_nvme.c
+1-01 files

FreeBSD/src da507ac — sys/amd64/amd64 pmap.c, sys/arm64/arm64 pmap.c

pmap: Fix some bugs around accounting of wired mappings

The amd64 and arm64 pmaps failed to decrement the count when tearing
down a 1GB largepage mapping.  The riscv pmap failed to decrement the
count when unwiring a superpage mapping.

Reported by:    alc
Reviewed by:    bnovkov, alc, kib
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D61414
DeltaFile
+3-0sys/arm64/arm64/pmap.c
+2-0sys/riscv/riscv/pmap.c
+2-0sys/amd64/amd64/pmap.c
+7-03 files

FreeBSD/src e4b9fec — sys/kern link_elf.c

link_elf: validate the section headers in link_elf_load_file()

e_shentsize isn't checked, and e_shstrndx, sh_link and sh_name are used
unchecked.  Do what link_elf_obj.c does.

MFC after:      1 week
Reviewed by:    kib
Differential Revision:  https://reviews.freebsd.org/D61389
DeltaFile
+34-0sys/kern/link_elf.c
+34-01 files

FreeBSD/src e0f0834 — sys/kern link_elf.c

link_elf: bounds-check the dynamic section's tables

parse_dynamic() only checks the DT_HASH header.  nbuckets, nchains and
the other DT_* tables come from the module unchecked.  Check them
against the mapping, and reject a size without its table.

Reported by:    llm-postcr
MFC after:      1 week
Reviewed by:    kib
Differential Revision:  https://reviews.freebsd.org/D61387
DeltaFile
+77-27sys/kern/link_elf.c
+77-271 files

FreeBSD/src 35d9a9b — sys/kern link_elf.c

link_elf: validate symbol name offsets

st_name isn't checked against the string table size, for any of the
symbol tables used here.  Do what link_elf_obj.c does since 4e2c2842e.

Reported by:    llm-postcr
MFC after:      1 week
Reviewed by:    kib
Differential Revision:  https://reviews.freebsd.org/D61388
DeltaFile
+34-0sys/kern/link_elf.c
+34-01 files

FreeBSD/src 57bee49 — sys/kern sysv_msg.c

sysvmsg: Fix sequence number wraparound races

The SysV message queue code has the same problem that we fixed in the
semaphore code in SA-26:54.sysvsem and SA-26:64.sysvsem.  That is,
kern_msgrcv() and kern_msgsnd() are susceptible to TOCTOU races when
they sleep waiting for messages and queue space, respectively.  Unlike
the semaphore code, however, the message queue array is never resized
and there is no notion of message queue sets, so such races do not open
up any memory safety bugs.

Fix the races, following the pattern from the SysV semaphore changes:
use a global sequence number array with wide counters, to avoid changing
the KBI which is embedded in userspace tools.  Fix kern_msgsnd(), which
did not validate the sequence number at all after sleeping.  Use a
msgvalid() helper to factor out some duplicated checks.  Convert a
couple of local flag variables to bools.

Reported by:    Apex Security Research
Reviewed by:    kib

    [3 lines not shown]
DeltaFile
+51-64sys/kern/sysv_msg.c
+51-641 files

FreeBSD/src 7311793 — sys/kern sysv_sem.c

sysvsem: Plug another place where we leak __sem_base to userspace

Leaking this pointer isn't harmful, but other places take care to clear
it, so handle this in SEM_STAT too.

Reviewed by:    imp, kib
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D61396
DeltaFile
+2-0sys/kern/sysv_sem.c
+2-01 files

FreeBSD/src 6b4a478 — sys/arm64/vmm/io vgic_v3.c

arm64/vmm: vgic_v3: Register the maintenance interrupt

If one is available, register the maintenance IRQ so that vmm can
receive and process guest exits when the maintenance IRQ is asserted.

Since vmm and vgic can still operate without it, print a warning but
attach the vgic regardless if the maintenance IRQ cannot be registered.

Signed-off-by: Kajetan Puchalski <kajetan.puchalski at arm.com>
Reviewed by:    andrew
Sponsored by:   Arm Ltd
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2530
DeltaFile
+94-2sys/arm64/vmm/io/vgic_v3.c
+94-21 files

FreeBSD/src d408529 — sys/arm64/arm64 gic_v3_acpi.c

arm64/gicv3: Expose the ACPI maintenance interrupt

The ACPI entry describing the maintenance interrupt INTID is already
available as "VgicInterrupt", but it is not exposed to the GIC driver.

Check that the value is valid and consistent between CPUs, then publish
it for the GIC driver to use under rid 0 if so.

Print a warning if the maintenance interrupt is configured to be
edge-sensitive in ACPI, as the GIC spec explicitly states "maintenance
interrupts are level-sensitive".

Signed-off-by: Kajetan Puchalski <kajetan.puchalski at arm.com>
Reviewed by:    andrew
Sponsored by:   Arm Ltd
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2527
DeltaFile
+47-4sys/arm64/arm64/gic_v3_acpi.c
+47-41 files

FreeBSD/src f3555a0 — usr.sbin/bsdinstall/scripts pkgbase.in

bsdinstall: Set TMPDIR in pkgbase install

The FreeBSD-base repository (aka "pkgbase") is now created using 'pkg
repo -l' in order to make 'pkg rwhich' work.  Unfortunately this makes
the data.pkg file considerably larger, and FreeBSD 15.2-BETA1 fails to
install using a remote repository since the installer has a small /tmp
(20 MB).

Run pkg commands with 'env TMPDIR=<chrootdir>/tmp' since the /tmp in
the system being installed is considerably larger than the tmpfs which
the installer runs with.  Create <chrootdir>/tmp first so we can ensure
it has 1777 permissions.

Reviewed by:    bapt
MFC after:      1 day
Differential Revision:  https://reviews.freebsd.org/D61380

(cherry picked from commit a7163bd76986282fdcb059b91301d3214da49642)
DeltaFile
+6-1usr.sbin/bsdinstall/scripts/pkgbase.in
+6-11 files

FreeBSD/src f6bd245 — usr.bin/man man.sh

man.sh: fix variable typo in debug output

MFC after:      3 days
DeltaFile
+1-1usr.bin/man/man.sh
+1-11 files

FreeBSD/src eca5b28 — libexec/nuageinit nuageinit.7 nuage.lua, libexec/nuageinit/tests Makefile nuage.sh

nuageinit: Add support for uid

Adds support for specifying an explicit UID when creating users through nuageinit. Both numeric and string UID values are supported. Invalid or negative UIDs are rejected. The new uid option is documented in nuageinit(7). Existing automatic UID allocation remains unchanged when no UID is specified. A UID already in use or out of range is left to pw(8) to reject.

PR:             293716
Reported by:    Einar Bjarni Halldórsson <einar at isnic.is>
Reviewed by:    dtxdf, bapt
Signed-off-by:  Kushagra Chauhan <zenzesama at gmail.com>
Differential Revision:  https://reviews.freebsd.org/D61174
DeltaFile
+27-0libexec/nuageinit/tests/adduser_uid.lua
+19-0libexec/nuageinit/tests/nuage.sh
+11-0libexec/nuageinit/nuage.lua
+3-1libexec/nuageinit/nuageinit.7
+1-0libexec/nuageinit/tests/Makefile
+61-15 files

FreeBSD/src 70d08c6 — sys/kern p1003_1b.c

p1003_1b: Add capability mode checks

The sched_* syscalls can operate either on the calling process (by
setting pid = 0) or by specifying a pid.  They are allowed in capability
mode, but previously were not scoped to only operating on the calling
process.

Reviewed by:    olce
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57346
DeltaFile
+11-0sys/kern/p1003_1b.c
+11-01 files

FreeBSD/src df0fc3a — lib/libc/stdlib strtoul.3 strtol.3

strto{u,}l.3: Fix base for which 0b prefix is accepted

Fixes:  76edfabbecde ("libc: Document support for binary integers.")
Sponsored by:   Klara, Inc.
DeltaFile
+4-2lib/libc/stdlib/strtoul.3
+4-2lib/libc/stdlib/strtol.3
+8-42 files

FreeBSD/src 431cc94 — sys/kern uipc_syscalls.c

user_connectat: correctly pass fd through

In the original adaptation of connect/connectat to use user_connectat in
CheriBSD, I failed to pass the fd through in the connectat case and
always passed AT_FDCWD.  This did trigger failures in the unix_connectat
test which I somehow missed in prior test runs.

Reported by:    llm-postcr
DeltaFile
+1-1sys/kern/uipc_syscalls.c
+1-11 files

FreeBSD/src 74ae9ac — libexec/rc/rc.d sshd

rc: Generate ML-DSA44/Ed25519 host keys by default

Commit bd9d7cdd1420 ("OpenSSH: Update to 10.5p1") introduced support for
ML-DSA44/Ed25519 host keys.

Generate these keys by default when the sshd service is first started.

Reported by:    Herbert J. Skuhra
Reviewed by:    emaste
Differential Revision:  https://reviews.freebsd.org/D61433
DeltaFile
+6-3libexec/rc/rc.d/sshd
+6-31 files

FreeBSD/src 7b5a98c — lib/libc/locale wcstod.3 wcstol.3, lib/libc/stdlib strtod.3 strtoul.3

libc: Refer to xlocale(3) in strto*/wcsto* manpages

Mention the extended locale (_l) versions of strtol(3), strtoul(3),
strtod(3), wcstol(3), and wcstod(3) and point to xlocale(3).

While here, add missing serial commas in function lists and widen the
strtol(3) RETURN VALUES table columns to fit INTMAX_MIN/INTMAX_MAX.

Obtained from:  https://github.com/apple-oss-distributions/libc (partially)
Sponsored by:   Klara, Inc.
DeltaFile
+11-3lib/libc/stdlib/strtol.3
+10-2lib/libc/stdlib/strtoul.3
+7-4lib/libc/locale/wcstol.3
+5-4lib/libc/stdlib/strtod.3
+6-3lib/libc/locale/wcstod.3
+39-165 files

FreeBSD/src 88c5709 — sys/cam/scsi scsi_pass.c

pass(4): Don't drop the periph lock before selrecord() in passpoll()

passpoll() checked the done queue while holding the peripheral lock,
dropped the lock, and only then called selrecord().  A CCB completing
in the window between the unlock and the selrecord() call sent its
selwakeuppri() before the polling thread was on the selinfo list, so
the wakeup was lost and select(2) or poll(2) slept until another
completion arrived or the timeout expired.

Call selrecord() before dropping the lock.  This lock order is
already established: passdone() calls selwakeuppri(), which takes
the selinfo lock, while holding the peripheral lock.

kqueue is not affected, since the knlist is backed by the peripheral
mutex.

Reported by:    llm-postcr
Fixes:          a9934668aa13
MFC after:      1 week

    [2 lines not shown]
DeltaFile
+1-1sys/cam/scsi/scsi_pass.c
+1-11 files

FreeBSD/src 6442a92 — sys/cam/scsi scsi_pass.c

pass(4): Wake select/kqueue waiters when an immediate CCB completes

In the CAMIOQUEUE ioctl, a queued CCB completes through passdone(),
which moves it to the done queue and calls selwakeuppri() and
KNOTE_LOCKED() so that a consumer blocked in select(2), poll(2) or
kevent(2) wakes up and collects the CCB with CAMIOGET.  An immediate
CCB (e.g. XPT_DEV_ADVINFO or XPT_DEV_MATCH) is instead executed
synchronously in the ioctl and moved to the done queue directly,
with no notification, so a consumer sleeping while waiting for its
completion never wakes up until some other queued I/O completes.

Send the same notification that passdone() sends.  The peripheral
lock is held at this point and backs the knlist, so KNOTE_LOCKED()
is the correct variant.

A version of this fix has been in production use at Spectra Logic
since 2024.

Co-authored-by: Dave Baukus <daveb at spectralogic.com>

    [5 lines not shown]
DeltaFile
+4-1sys/cam/scsi/scsi_pass.c
+4-11 files

FreeBSD/src 6e87733 — sys/kern vfs_acl.c, sys/sys syscallsubr.h

__acl_*(2): add kern_ implementations

Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+35-24sys/kern/vfs_acl.c
+15-0sys/sys/syscallsubr.h
+50-242 files

FreeBSD/src 22dd3a0 — sys/kern sys_procdesc.c, sys/sys syscallsubr.h

pdgetpid(2): add user_pdgetpid

Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+9-3sys/kern/sys_procdesc.c
+1-0sys/sys/syscallsubr.h
+10-32 files

FreeBSD/src 65e94d4 — sys/kern uipc_syscalls.c, sys/sys socket.h syscallsubr.h

uipc_syscalls.c: add kern_ and user_ implementations

Rename accept1 and sendit to user_accept and user_sendit.

Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+79-52sys/kern/uipc_syscalls.c
+21-0sys/sys/syscallsubr.h
+1-1sys/sys/socket.h
+101-533 files

FreeBSD/src 0e10082 — sys/kern uipc_shm.c, sys/sys syscallsubr.h

uipc_shm.c: add kern_ implementations

Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+17-6sys/kern/uipc_shm.c
+3-0sys/sys/syscallsubr.h
+20-62 files

FreeBSD/src 1b2f03f — sys/kern sys_pipe.c, sys/sys syscallsubr.h

pipe2(2): add kern_pipe2

Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+9-3sys/kern/sys_pipe.c
+1-0sys/sys/syscallsubr.h
+10-32 files

FreeBSD/src ff3f704 — sys/dev/acpica acpi_cpu.c

acpi_cpu: Bring back setting BM_RLD on resume

enable_idle(), which was called on resume before 427747fc16c9
("acpi_cpu: No longer disable idle during suspend"), also set BM_RLD.

This commit brings back just setting BM_RLD on resume because some
firmware might not be doing this itself on some machines.

Reviewed by:    olce
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D61431
DeltaFile
+24-6sys/dev/acpica/acpi_cpu.c
+24-61 files

FreeBSD/src 427747f — sys/dev/acpica acpi_cpu.c

acpi_cpu: No longer disable idle during suspend

This had been introduced in 3331373ce733 ("Disable CPU idle states
during suspend and reenable them during resume.") to work around C-state
selection logic which would skip C-states which returned immediately,
considering them "broken".

This workaround is incompatible with suspend-to-idle however, which
requires CPUs to be in their idle states, and is no longer relevant
either way since b0baaaaecf1a ("Avoid comparing negative signed to
positive unsignad values.") removed the C-state skipping logic the
previous change was working around.

Reviewed by:    olce
Sponsored by:   The FreeBSD Foundation
Pull Request:   https://ron-dev.freebsd.org/FreeBSD/src/pulls/71
Differential Revision:  https://reviews.freebsd.org/D60649
DeltaFile
+2-28sys/dev/acpica/acpi_cpu.c
+2-281 files