FreeBSD/src 9f4cc50 — tools/tools/locale Makefile, tools/tools/locale/etc alternativemonths.conf charmaps.xml

locale: stop parsing charmaps.xml

Since we are now only updating UTF-8 locales, this files is not really
useful anymore, get the locale list from the BASE_LOCALES_OF_INTEREST
passed via arguments, and replace the only useful case (alternative
months) by a simple plain testfile.
DeltaFile
+0-713tools/tools/locale/etc/charmaps.xml
+0-183tools/tools/locale/tools/charmaps.pm
+25-7tools/tools/locale/tools/cldr2def.pl
+13-0tools/tools/locale/etc/alternativemonths.conf
+3-2tools/tools/locale/Makefile
+41-9055 files

FreeBSD/src 5c0f483 — tools/tools/locale Makefile

locale: drop 20 unused locales from the Makefile

The POSIX sources of these locales are generated by GeneratePOSIX but
never read: cldr2def.pl only consumes the sources of the locales listed
in charmaps.xml.
DeltaFile
+1-4tools/tools/locale/Makefile
+1-41 files

FreeBSD/src a5416fc — crypto/openssl/include/openssl opensslv.h, secure/lib/libcrypto/man/man3 EC_GROUP_new.3 EVP_EncryptInit.3

crypto/openssl: commit generated files for 3.5.10 release

MFC after:      1 day
MFC with:       cbbbed654506
DeltaFile
+11-10secure/lib/libcrypto/man/man3/PEM_read_bio_PrivateKey.3
+19-2secure/lib/libcrypto/man/man7/RAND.7
+10-8secure/lib/libcrypto/man/man3/EVP_EncryptInit.3
+7-7secure/lib/libcrypto/man/man7/openssl-env.7
+5-5crypto/openssl/include/openssl/opensslv.h
+7-2secure/lib/libcrypto/man/man3/EC_GROUP_new.3
+59-34901 files not shown
+977-950907 files

FreeBSD/src cbf9467 — etc/mtree BSD.tests.dist, tests/sys/fs Makefile

tests: add UFS synchronous write durability tests

Check that once fsync(2), fdatasync(2), or a write(2) with O_SYNC or
O_DSYNC returns, the new data, the file size and every block pointer
leading to the data are on disk.  The cases append a block, fill a hole,
append the first block that needs an indirect block and append below an
existing indirect block.  Two more append after another write left a
new direct block unsynced, which with soft updates cuts the size and the
later pointers of an inode written meanwhile.  With O_SYNC and O_DSYNC
on soft updates, those also check that the open already made the
unsynced block durable.
Each case runs on UFS without soft updates, with soft updates and with
SU+J.

The file systems live on md(4) and the checks read the inode, the
indirect block and the data block straight from the device with libufs
right after the synchronous call returns.  There is no cache in front
of the disk device, so this shows what would survive a crash at that
moment without having to crash anything.

    [8 lines not shown]
DeltaFile
+386-0tests/sys/fs/ufs/sync_test.c
+9-0tests/sys/fs/ufs/Makefile
+2-0etc/mtree/BSD.tests.dist
+1-0tests/sys/fs/Makefile
+398-04 files

FreeBSD/src 5d73fd0 — sys/ufs/ffs ffs_softdep.c ffs_vnops.c

ufs: make fdatasync(2) and O_DSYNC writes update the inode

ffs_syncvnode() in the DATA_ONLY case and ffs_write() for IO_DATASYNC
decide whether the inode has to be written by testing IN_SIZEMOD and
IN_IBLKDATA against ip->i_flags, the chflags(2) word, instead of the
in-core state ip->i_flag.  IN_SIZEMOD and IN_IBLKDATA alias UF_READONLY
and UF_ARCHIVE, so for ordinary files the test was always false: after
an fdatasync() or an O_DSYNC write that extended a file or filled a
hole, the data blocks were on disk but the inode size and block pointers
were not, and a crash before the syncer got to the inode lost the
"synced" data.  Files with uarchive or urdonly set got a synchronous
inode write on every call instead.

journal_mount() has the same mixup and sets IN_MODIFIED in i_flags,
which leaves UF_OPAQUE set on the in-core .sujournal inode.  The
synchronous ffs_update() that follows writes the inode regardless, so
only the stray flag is fixed here.

Fixes:  7428630b757 ("UFS: write inode block for fdatasync(2) if pointers in inode where allocated")

    [11 lines not shown]
DeltaFile
+2-2sys/ufs/ffs/ffs_vnops.c
+1-1sys/ufs/ffs/ffs_softdep.c
+3-32 files

FreeBSD/src 666fde7 — tools/test/stress2/misc nlink6.sh

stress2: add a test for forced unmount racing mkdir at UFS_LINK_MAX

On a soft updates file system, keep a directory at UFS_LINK_MAX with
workers removing and recreating subdirectories in it, so that mkdir(2)
keeps going through ufs_sync_nlink(), and force-unmount, check and
remount the file system in a loop.  The workers work relative to the
directory: a lookup through the mount point would wait for the unmount
on the covered vnode lock and never race with it.  Before the fix, the
first forced unmount deadlocked with mkdir(2) sleeping in vfs_busy().

With dtrace=1, count the vfs_busy() calls made during an unmount by
caller, and the mkdir(2) calls that synced and restarted with ERELOOKUP
during an unmount, which shows that the race was hit.

Sponsored by:   Sippy Software, Inc.
Reviewed by:    pho
Tested by:      pho
Differential Revision:  https://reviews.freebsd.org/D60204
MFC after:      1 month

    [2 lines not shown]
DeltaFile
+191-0tools/test/stress2/misc/nlink6.sh
+191-01 files

FreeBSD/src 674a9cd — sys/ufs/ffs ffs_vnops.c

ufs: flush soft updates dependencies for O_SYNC and O_DSYNC writes

For a synchronous write, ffs_write() writes the data buffers with
bwrite() and then the inode with ffs_update(vp, 1).  With soft updates,
a new block pointer can only reach the disk after the dependencies of
the block, such as the cylinder group map that allocates it, are
written.  Until then initiate_write_inodeblock_ufs[12]() and
initiate_write_indirdep() roll the pointer, and for an extending write
the size, back in the buffer being written.  Nothing in the write path
flushes those dependencies, so the inode went out with the old size and
pointers, ffs_update() cleared IN_SIZEMOD and IN_IBLKDATA, and a crash
before the syncer rewrote the inode lost data that O_SYNC or O_DSYNC
promised was on stable storage.  The same held for a new block below an
indirect block, which ffs_balloc() writes synchronously but with the
pointer rolled back.

When soft updates are enabled and the write allocated blocks, finish it
with ffs_syncvnode(), as fsync(2) and fdatasync(2) do: it flushes the
dependencies, rewrites the rolled back indirect blocks and writes the

    [32 lines not shown]
DeltaFile
+59-1sys/ufs/ffs/ffs_vnops.c
+59-11 files

FreeBSD/src f86a242 — sys/ufs/ffs ffs_vnops.c

ufs: make fdatasync(2) write dirty indirect blocks

A data-only ffs_syncvnode() skips dirty indirect blocks on file systems
without soft updates, and with soft updates stops making passes once
only indirect blocks are left dirty.  Indirect blocks only get dirty
when the block pointers in them change, and those pointers are what
makes a newly allocated block reachable.  So when fdatasync() follows
a write that extended the file or filled a hole past the direct blocks,
the data and the inode size reached the disk but the pointer to the new
block did not, and a crash lost the "synced" data.  With soft updates
the indirect block was usually written once, with the new pointer
rolled back, and never rewritten.

POSIX requires fdatasync() to write the metadata needed to retrieve the
data, which 52488b51489 already acknowledged for the inode, so treat
dirty indirect blocks the same way for a data-only sync as for a full
one.  This restores the loop to what it was before 2f514f92cf0.  Plain
overwrites, the case data-only sync is meant to speed up, do not dirty
indirect blocks and still write neither them nor the inode.

    [10 lines not shown]
DeltaFile
+15-35sys/ufs/ffs/ffs_vnops.c
+15-351 files

FreeBSD/src ec28cf2 — sys/ufs/ffs ffs_vnops.c

ufs: do not let a rolled back inode write end a data-only sync

With soft updates, ffs_syncvnode() writes the inode between its passes
while buffers are still dirty.  That write can go out with new block
pointers rolled back, for instance a new indirect block whose contents
are only written in a later pass, yet ffs_update() clears IN_SIZEMOD
and IN_IBLKDATA because the write was synchronous.  A data-only sync
then decides at the end that the inode need not be written, and
fdatasync(2) or an O_DSYNC write that allocated the first indirect
block returned with the on-disk inode not pointing to it.

Note on entry whether a data-only sync has to write the inode, and base
the final write, done once all dependencies are flushed, on that alone:
nothing else can set IN_SIZEMOD or IN_IBLKDATA meanwhile, as the vnode
is locked.  A full sync always writes the inode last and was not
affected.

Sponsored by:   Sippy Software, Inc.
Reviewed by:    kib

    [5 lines not shown]
DeltaFile
+9-2sys/ufs/ffs/ffs_vnops.c
+9-21 files

FreeBSD/src 4b6d4f0 — tools/test/stress2/misc gnop7.sh gnop6.sh

stress2: Fix script bugs in gnop6.sh, gnop7.sh and fdatasync*.sh

gnop6.sh recorded the checkfs result with "checkfs ... || s=1 && s=0",
which the shell parses as "(checkfs || s=1) && s=0", so the test passed
even when the file system check failed.

gnop7.sh only sets s when unmount or fsck_ffs fails and ends with
"exit $s".  On a clean run s is unset, and the script exits with the
status of the preceding "[ $notloaded ] && gnop unload", which is 1
whenever geom_nop was already loaded, for instance by an earlier test.

fdatasync.sh and fdatasync2.sh ran "df -i $RUNDIR" before creating the
directory.  With a RUNDIR that does not exist yet, df failed, the test
printed "[: -lt: unexpected operator" and the free inode check was
skipped.

Reviewed by:    pho
Differential Revision:  https://reviews.freebsd.org/D60136
Sponsored by:   Sippy Software, Inc.

    [3 lines not shown]
DeltaFile
+1-2tools/test/stress2/misc/fdatasync2.sh
+1-2tools/test/stress2/misc/fdatasync.sh
+1-1tools/test/stress2/misc/gnop6.sh
+1-0tools/test/stress2/misc/gnop7.sh
+4-54 files

FreeBSD/src c87adb9 — sys/ufs/ufs ufs_lookup.c ufs_vnops.c

ufs: report a mismatched ".." in ufs_dirrewrite()

When ufs_rename() moves a directory to a new parent and ufs_dirrewrite()
fails to rewrite its ".." entry, it reports "bad dir ... rename: missing
.. entry" whatever the error.  ufs_dirrewrite() never finds a missing
"..", though: it fails with EIDRM when the ".." entry names another inode
than the expected one, and otherwise only when the directory block cannot
be read or written.  The latter happens for every directory rename in
flight when the device goes away under a forcibly unmounted file system,
and the log then fills with reports of directories that are intact on
disk.

Report the EIDRM case with ufs_dirbad() in ufs_dirrewrite() itself, so
that all of its callers get the same diagnostic, and drop the report
from ufs_rename().  Errors from the lower layers are not reported, as
usual for an I/O initiator.

Reviewed by:    kib
MFC after:      2 weeks

    [3 lines not shown]
DeltaFile
+1-3sys/ufs/ufs/ufs_vnops.c
+2-0sys/ufs/ufs/ufs_lookup.c
+3-32 files

FreeBSD/src a0eb12c — sys/ufs/ufs ufs_vnops.c

ufs: do not busy or reference the mount in ufs_sync_nlink()

With soft updates, mkdir(2), link(2) and rename(2) into a directory
whose i_nlink is at UFS_LINK_MAX while i_effnlink is below it call
ufs_sync_nlink1() to sync the file system and restart.  It busied the
mount with vfs_busy(mp, 0), which sleeps for as long as an unmount is in
progress.  The caller is still between vn_start_write() and
vn_finished_write() there, and the unmount, once it has set
MNTK_UNMOUNT, goes on to suspend writes in VFS_UNMOUNT() and waits in
vfs_write_suspend() for that write to end.  Neither could make progress,
and every later vfs_busy() of the mount, such as from getfsstat(2) or a
lookup crossing the mount point, hung behind them.

The window is wide: after setting MNTK_UNMOUNT, the unmount waits for
the busy references to drain, which includes another thread already
syncing in ufs_sync_nlink1(), and for vfs_periodic().  A forced unmount
of a file system with a directory at the link limit under mkdir/rmdir
load hits it within seconds.


    [21 lines not shown]
DeltaFile
+19-23sys/ufs/ufs/ufs_vnops.c
+19-231 files

FreeBSD/src ad272cf — tools/test/stress2/misc mkdir_blkreuse.sh

stress2: add a reproducer for the flush_newblk_dep() "Bad newblk" panic

flush_pagedep_deps() drops the soft updates lock to obtain the vnode of
a new directory.  If its MKDIR_BODY dependency completes in that window,
the lookup of the directory's first block in flush_newblk_dep() can find
a stale allocindir left behind by a previous owner of the same block,
relocated by ffs_reallocblks() and freed, and panic.

The test grows interleaved files past UFS_NDADDR to keep clusters being
relocated, while other workers create subdirectories in a parent with
IN_ENDOFF set, so that ffs_vput_pair() syncs it, and fsync() them to
complete the mkdir dependencies.  The file system layout and the way
the writers put their blocks on disk are arranged so that a new
directory takes over a freed block whose dependency is still retained;
the details are in the script.  With dtrace=1, the test also counts how
often this precondition is met, which works on a fixed kernel too.

PR:             297976
Reviewed by:    kib, pho

    [5 lines not shown]
DeltaFile
+584-0tools/test/stress2/misc/mkdir_blkreuse.sh
+584-01 files

FreeBSD/src 7a1e61b — sys/ufs/ffs ffs_softdep.c

ffs: revalidate mkdir dependencies after vnode lookup

flush_pagedep_deps() drops the soft updates lock while obtaining the
vnode of a newly created directory with get_parent_vp().  The
MKDIR_BODY dependency may complete during this interval, invalidating
the diradd selected before the lock was dropped.

Once the directory's allocdirect is retired, the lookup of its first
block by block number in flush_newblk_dep() can find an older
dependency for a previous use of the same physical block.  The newblk
hash is not unique by block number: when ffs_reallocblks() relocates a
cluster, the completed allocindirs of the old blocks stay on the
indirdep's ir_completehd until the indirect block pointer in the inode
is written, while the old blocks are already free and may be allocated
to a new directory.  flush_newblk_dep() then finds a D_ALLOCINDIR where
it expects a D_ALLOCDIRECT and panics with "flush_newblk_dep: Bad
newblk".

Retain the vnode returned by get_parent_vp(), reacquire the soft

    [35 lines not shown]
DeltaFile
+170-55sys/ufs/ffs/ffs_softdep.c
+170-551 files

FreeBSD/src cbbbed6 — crypto/openssl/crypto/objects obj_dat.h, crypto/openssl/test sslapitest.c safe_math_test.c

crypto/openssl: update to 3.5.10

This change updates the OpenSSL source to 3.5.10.  This is a security
bugfix release which addresses several issues--Medium being the highest
severity issue.  Users are strongly encouraged to update to this
release.

Please see the original vendor commit for more details.

Merge commit '7ee6425d9f3b6d5fba45b5b525953e4d0b662eff'
DeltaFile
+2,523-2,523crypto/openssl/crypto/objects/obj_dat.h
+846-1crypto/openssl/test/radix/quic_tests.c
+649-3crypto/openssl/test/quicapitest.c
+583-3crypto/openssl/test/evp_extra_test.c
+402-46crypto/openssl/test/safe_math_test.c
+420-0crypto/openssl/test/sslapitest.c
+5,423-2,576165 files not shown
+9,613-3,351171 files

FreeBSD/src d419e49 — lib/libthr/thread thr_private.h thr_create.c

libthr: Skip unwinding for thread normal returrn

For a thread returns normally, there is no needeed to unwind the stack.
We split the exit code with a common implementation and pass unwind
to check whether we need to unwind the stack or not.

Reviewed by:    kib
MFC after:      2 weeks
Differential Revision: https://reviews.freebsd.org/D62265
DeltaFile
+15-0lib/libthr/thread/thr_exit.c
+1-1lib/libthr/thread/thr_create.c
+1-0lib/libthr/thread/thr_private.h
+17-13 files

FreeBSD/src e76f099 — lib/libthr/thread thr_pspinlock.c

libthr: Fix shared spinlock leak

pshared_destroy takes key instead of the real lock as
parameter.

Reviewed by:    kib
MFC after:      2 weeks
Differential Revision: https://reviews.freebsd.org/D62259
DeltaFile
+2-1lib/libthr/thread/thr_pspinlock.c
+2-11 files

FreeBSD/src 4e03345 — sys/contrib/zstd/lib zstd.h, sys/contrib/zstd/lib/compress zstd_compress.c

MFV: zstd 1.6.0

Security:       CVE-2026-124851
MFC after:      3 days

(cherry picked from commit 0412a4034e277629245c8bd87978680216bb06b5)
DeltaFile
+775-214sys/contrib/zstd/lib/compress/zstd_compress.c
+713-235sys/contrib/zstd/programs/fileio.c
+439-105sys/contrib/zstd/programs/util.c
+5-364sys/contrib/zstd/lib/legacy/zstd_v02.c
+209-112sys/contrib/zstd/lib/zstd.h
+253-65sys/contrib/zstd/programs/zstd.1
+2,394-1,09577 files not shown
+4,703-2,09683 files

FreeBSD/src eca31f2 — stand loader.mk defs.mk, stand/efi/loader Makefile

loader: Add defines for ZLIB_CFLAGS, BZIP2_CFLAGS and ZSTD_CFLAGS

These are scattered in several places, so centralize the setting of
these flags.

Sponsored by:           Netflix
Differential Revision:  https://reviews.freebsd.org/D57861

(cherry picked from commit 53811ed6237972f92a80627ea2c17ece212315a7)
DeltaFile
+9-0stand/defs.mk
+1-2stand/libsa/Makefile
+2-1stand/efi/loader/Makefile
+1-1stand/uboot/Makefile
+1-1stand/loader.mk
+1-1stand/i386/loader/Makefile
+15-63 files not shown
+18-99 files

FreeBSD/src e2c31fb — sys/dev/ufshci ufshci_private.h

ufshci: remove the unused phase field

The hardware queue kept a phase field for MCQ mode. A UFS completion
queue has no phase bit, and MCQ completion handling will read the CQ
tail pointer register instead. Nothing reads the field.

Remove it.

Reviewed by:            imp
Differential Revision:  https://reviews.freebsd.org/D62313
Sponsored by:           Samsung Electronics
DeltaFile
+0-1sys/dev/ufshci/ufshci_private.h
+0-11 files

FreeBSD/src e1bc4ae — sys/dev/ufshci ufshci_req_queue.c

ufshci: take the recovery lock when an abort fails

The watchdog runs the recovery steps with the queue's recovery lock
held. A failed Abort Task ran the same steps from its completion
callback without the lock, so it could race the watchdog over the
queue's recovery state.

Take the recovery lock around the recovery steps in the abort
completion, and assert it in the recovery function.

Reviewed by:            imp
Differential Revision:  https://reviews.freebsd.org/D62312
Sponsored by:           Samsung Electronics
DeltaFile
+8-1sys/dev/ufshci/ufshci_req_queue.c
+8-11 files

FreeBSD/src 0aba8f0 — sys/dev/ufshci ufshci_pci.c

ufshci: use one interrupt vector on PCI

The PCI attach code came from nvme(4) and asks for one MSI-X or MSI
vector per queue. It installs an interrupt handler only when it ends
up with a single vector, though. With the default settings it asks
for two vectors, so a controller that grants two gets no handler at
all. The controller attaches, but its interrupts go unhandled and a
request completes only when the watchdog finds it past its timeout.

The driver has a single interrupt handler, which scans every queue.
Ask for one vector, trying MSI-X, then MSI, then INTx, and install
that handler in every case.

Reviewed by:            imp
Differential Revision:  https://reviews.freebsd.org/D62311
Sponsored by:           Samsung Electronics
DeltaFile
+10-28sys/dev/ufshci/ufshci_pci.c
+10-281 files

FreeBSD/src 1d8a003 — sys/dev/ufshci ufshci_req_queue.c ufshci_ctrlr.c

ufshci: give CAM every slot that I/O can use

Commit c41be266147f ("ufshci: keep a slot for admin requests") left
one slot out of the CAM openings besides the admin slot, because
letting CAM fill every I/O slot cut the throughput. The cause was the
completion path, which called back into CAM before it freed the slot.
The completion path now frees the slot first, so the spare slot only
sits idle.

Give CAM every slot that I/O can use again. On QEMU with 4k random
I/O from 4 jobs at depth 16, the throughput stayed the same and no
request came back with EBUSY. A request sent outside CAM, such as a
passthrough command, can still make CAM find the queue full. CAM
requeues its request then, so log a full queue only for the task
management queue, where it means that aborts piled up.

Reviewed by:            imp
Differential Revision:  https://reviews.freebsd.org/D62309
Sponsored by:           Samsung Electronics
DeltaFile
+4-8sys/dev/ufshci/ufshci_ctrlr.c
+8-1sys/dev/ufshci/ufshci_req_queue.c
+12-92 files

FreeBSD/src fe6aade — sys/dev/ufshci ufshci_req_queue.c

ufshci: free the slot before the completion callback

The completion path called the request's callback before it freed the
slot. CAM sends its next request from inside that callback, so that
request could find every slot taken and bounce back with EBUSY until
the slot was freed. The spare slot left out of the CAM openings hid
this. With CAM allowed to fill every I/O slot, the bouncing cut the
throughput to a fifth on QEMU.

Free the slot first, and call the callback after dropping the queue
lock. The callback uses only the copied completion and its own
argument.

Reviewed by:            imp
Differential Revision:  https://reviews.freebsd.org/D62308
Sponsored by:           Samsung Electronics
DeltaFile
+31-27sys/dev/ufshci/ufshci_req_queue.c
+31-271 files

FreeBSD/src fe81449 — sys/powerpc/powerpc altivec.c

powerpc/altivec: initialize vrsave to all regs active

libunwind uses vrsave to determine which registers to restore, but
vrsave is never actually updated in modern OSs including FreeBSD.  This
leads to libunwind not restoring any altivec registers, resulting in
strange behaviors.

With this change gdb can now print a backtrace without crashing.

Patch originally provided by pkubaj.

MFC after:      3 days
DeltaFile
+1-0sys/powerpc/powerpc/altivec.c
+1-01 files

FreeBSD/src e19035a — sys/dev/bxe bxe_stats.c

bxe: Always return uint64_t from bxe_hilo

The interface counters are always uint64_t, so truncating to a signed
long only results in weird sign-extension errors on 32-bit platforms.

Reported by:    llm-postcr
Fixes:          df3601781d3e ("- Use if_inc_counter() to increment...")
DeltaFile
+1-4sys/dev/bxe/bxe_stats.c
+1-41 files

FreeBSD/src c29f74d — share/man/man4 Makefile iicbus.4

pcf: Actually remove the pcf(4) manpage and stop installing it

Reported by:    llm-postcr
Fixes:          ae4f5920971a ("pcf: Remove the pcf(4) driver")
DeltaFile
+0-70share/man/man4/pcf.4
+1-3share/man/man4/iicbus.4
+0-1share/man/man4/Makefile
+1-743 files

FreeBSD/src 7ee6425 — crypto/objects obj_dat.h, test sslapitest.c safe_math_test.c

openssl: import 3.5.10

This change adds openssl 3.5.10 from upstream [1].

The 3.5.10 artifact was been verified via PGP key [2] and by SHA256
checksum [3].

3.5.10 is a security bugfix release which resolves several CVE issues, the
highest severity issue being a Medium.  Users are encouraged to upgrade
to this release.

More information about the release (from a high level) can be found in
the release notes [4].

Updated via `update_openssl.sh` [5] like: `update_openssl.sh 3.5.10`.

[1]: https://github.com/openssl/openssl/releases/download/openssl-3.5.10/openssl-3.5.10.tar.gz
[2]: https://github.com/openssl/openssl/releases/download/openssl-3.5.10/openssl-3.5.10.tar.gz.asc
[3]: https://github.com/openssl/openssl/releases/download/openssl-3.5.10/openssl-3.5.10.tar.gz.sha256

    [2 lines not shown]
DeltaFile
+2,523-2,523crypto/objects/obj_dat.h
+846-1test/radix/quic_tests.c
+649-3test/quicapitest.c
+583-3test/evp_extra_test.c
+402-46test/safe_math_test.c
+420-0test/sslapitest.c
+5,423-2,576165 files not shown
+9,613-3,351171 files

FreeBSD/src a4e4e99 — sys/kern imgact_binmisc.c, tests/sys/kern binmisc_helper.c binmisc_test.sh

imgact_binmisc: fix validation of new entries

The magic offset and size are both uint32_t, so their sum may wrap and
pass the IBE_MATCH_MAX check with an offset far outside of the image
header.  Any exec that's checked against such an entry will then read
well beyond the header.

The name and interpreter length checks also read the byte following the
string before checking its index, so either one may fill its field
without a terminating NUL as long as the next field starts with one.  A
full-length interpreter then overflows the normalization buffer in
imgact_binmisc_populate_interp() by a byte.  An unterminated name is
instead truncated, which lets the same name be added more than once
since the duplicate check compares against the truncated copy.

Avoid the wrap and require both strings to be terminated within their
fields, and add regression tests for each.  Note that these are only
reachable by root on the host.


    [2 lines not shown]
DeltaFile
+56-0tests/sys/kern/binmisc_test.sh
+48-1tests/sys/kern/binmisc_helper.c
+14-5sys/kern/imgact_binmisc.c
+118-63 files

FreeBSD/src af0cb75 — sys/kern imgact_binmisc.c, tests/sys/kern binmisc_test.sh

imgact_binmisc: fix matching of magic bytes >= 0x80 without a mask

The image header is a char *, so on platforms with a signed char each
header byte is sign-extended before it's compared against the unsigned
magic.  Any magic byte >= 0x80 then fails to match unless IBF_USE_MASK
is set, as the mask happens to strip the sign extension.

Compare the header as uint8_t instead, and add a regression test.

Reviewed by:    imp, kib, markj
Differential Revision:  https://reviews.freebsd.org/D62130
DeltaFile
+20-0tests/sys/kern/binmisc_test.sh
+2-2sys/kern/imgact_binmisc.c
+22-22 files