FreeBSD/src 26b6624 — usr.sbin/fwget Makefile fwget.8, usr.sbin/fwget/acpi Makefile acpi_cirrus

fwget: Add ACPI device support

Some devices that need firmware have neither a PCI nor a USB id, like
the Cirrus Logic CS35L54 speaker amplifiers (ACPI CSC3554) of the HP
ZBook Ultra G1a.  Add an acpi subsystem that matches ACPI hardware ids
from devinfo(8) against per-vendor scripts, search it by default, and
map CSC3554 to its firmware package.

Reviewed by:    manu, christos, imp
Approved by:    manu, christos, imp
Pull Request:   https://ron-dev.freebsd.org/FreeBSD/src/pulls/126
DeltaFile
+30-0usr.sbin/fwget/acpi/acpi
+12-0usr.sbin/fwget/acpi/acpi_cirrus
+10-0usr.sbin/fwget/acpi/Makefile
+3-3usr.sbin/fwget/fwget.sh
+3-1usr.sbin/fwget/fwget.8
+1-1usr.sbin/fwget/Makefile
+59-56 files

FreeBSD/src f0a7386 — lib/libpfctl libpfctl.c

libpfctl: fix reading of struct pfr_tstats.pfrts_cnt

The kernel returns this as a uint64_t, but we only have an int.
Read this via a temporary value and downcast.

Reported by:    llm-postcr
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+17-1lib/libpfctl/libpfctl.c
+17-11 files

FreeBSD/src 7249630 — tests/sys/netpfil/pf snmp.sh, usr.sbin/bsnmpd/modules/snmp_pf pf_snmp.c

snmp_pf: fix pfTablesTblNumber

Actually set the number of tables we have.

MFC after:      1 week
Fixes:  9e8d2962aad3 ("pf: convert DIOCRGETTSTATS to netlink")
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+15-0tests/sys/netpfil/pf/snmp.sh
+2-2usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c
+17-22 files

FreeBSD/src 24f1891 — sys/netpfil/pf pf_ioctl.c

pf: do not copy tag/match_tag/qid/pqid from userspace

We assign those based on the tag/match_tag/... names. Assigning them
from userspace risks corruption if we free the rule on error and
tag_unref() them.

Reported by:    llm-postcr
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+0-4sys/netpfil/pf/pf_ioctl.c
+0-41 files

FreeBSD/src 9143d19 — tests/sys/netpfil/pf snmp.sh, usr.sbin/bsnmpd/modules/snmp_pf pf_snmp.c

snmp_pf: fix table indexes

Initialise 'i' so that the index we assign to tables is predictable.

Reported by:    maxim at FreeBSD.org
MFC after:      1 week
Fixes:  9e8d2962aad3 ("pf: convert DIOCRGETTSTATS to netlink")
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+2-2tests/sys/netpfil/pf/snmp.sh
+1-1usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c
+3-32 files

FreeBSD/src d32de73 — usr.sbin/bhyve/amd64 bhyverun_machdep.c

bhyve: List tpm.ctrl_path in the configuration schema

fbb1b886cbd0 added the tpm.ctrl_path option but not its schema entry,
so "bhyve -o help" does not list it, and tools that look for the option
there do not use it.

Reported by:    llm-postcr
Fixes:          fbb1b886cbd0 ("bhyve: Reinitialise swtpm's TPM at startup")
Sponsored by:   Defenso
Signed-off-by:  Quentin Thébault <quentin.thebault at defenso.fr>
Reviewed by:    kevans, novel
Differential Revision:  https://reviews.freebsd.org/D62285
DeltaFile
+1-0usr.sbin/bhyve/amd64/bhyverun_machdep.c
+1-01 files

FreeBSD/src c24ab9f — lib/libc/tests/stdio swscanf_test.c sscanf_test.c

stdio: Add test cases for scansets

Add test cases that exercise scanf() / wscanf() scansets, including
hyphenated ranges and the missing closing bracket bug we recently fixed.

MFC after:      1 week
Reviewed by:    kevans, emaste
Differential Revision:  https://reviews.freebsd.org/D62201
DeltaFile
+55-0lib/libc/tests/stdio/swscanf_test.c
+55-0lib/libc/tests/stdio/sscanf_test.c
+110-02 files

FreeBSD/src c5e0899 — lib/libc/stdio vfwscanf.c vfscanf.c

stdio: Handle unterminated scansets

In both vfscanf() and vfwscanf(), if the end of the format string was
reached before the closing bracket of a scanset, we treated the NUL as
the closing bracket and continued to read beyond the end of the format
string.  Add an error check to catch this case.

MFC after:      1 week
Reported by:    Nick L. Leppelmeier <nicklpmr at gmail.com>
Reviewed by:    kevans, emaste
Differential Revision:  https://reviews.freebsd.org/D62199
DeltaFile
+4-2lib/libc/stdio/vfscanf.c
+2-0lib/libc/stdio/vfwscanf.c
+6-22 files

FreeBSD/src 50eb68e — lib/libc/stdio vfwscanf.c

stdio: Implement ranges for wchar scansets

The C and POSIX standards allow but do not require hyphenated ranges to
be supported in scanf() / wscanf() scansets.  We implemented them for
scanf() but not for wscanf().  Do so using similar logic as for scanf().
This is hard to do efficiently for wide characters, which can in theory
span the full 32-bit range (and even the actual range of about 1 million
Unicode codepoints is difficult to handle), so we don't try to be
efficient, but just focus on producing the same results for wscanf() as
for scanf().

MFC after:      1 week
Reviewed by:    kevans, emaste
Differential Revision:  https://reviews.freebsd.org/D62200
DeltaFile
+40-6lib/libc/stdio/vfwscanf.c
+40-61 files

FreeBSD/src 5a22911 — stand/common load_elf.c, stand/efi/include efilib.h

loader.efi: Measure boot policy and loaded contents with a TPM

Use the EFI TCG2 protocol, or the legacy TCG protocol on TPM 1.2
firmware, to extend the loader PCRs and record EV_IPL events in the
firmware event log.

Extend PCR 8 with the final kernel environment and the type, name, and
arguments of each loaded boot input.  Prefix both record types with
versioned, NUL-terminated domain strings.  These make the records
self-identifying and define an explicit measured policy encoding.  Store
the complete measured pre-images in the event data so attestation and
diagnostic tools can audit the values without an out of band copy.

Extend PCR 9 with the initialized contents of kernels, modules, and raw
boot inputs, but record only descriptive labels rather than copying file
contents into the event log.

The Lua module table has no defined traversal order.  Retain content
ranges as loader-private metadata, then sort the final file list before

    [32 lines not shown]
DeltaFile
+463-0stand/efi/libefi/tpm.c
+38-1stand/man/loader.efi.8
+14-0stand/efi/libefi/tpm-compat/Uefi.h
+12-0stand/common/load_elf.c
+4-0stand/efi/include/efilib.h
+3-0stand/efi/loader/bootinfo.c
+534-17 files not shown
+548-113 files

FreeBSD/src a5cc06a — sys/contrib/edk2/Include/Protocol LoadFile2.h TcgService.h

edk2: Import Loadfile2.h and TcgService.h from edk2-stable202502

Verbatim import of these files, with unix line endings.

Sponsored by:           Netflix

(cherry picked from commit e960cb4c033c8f65af1e8b09310c1bd5414f21ac)
DeltaFile
+195-0sys/contrib/edk2/Include/Protocol/TcgService.h
+78-0sys/contrib/edk2/Include/Protocol/LoadFile2.h
+273-02 files

FreeBSD/src b086f23 — sys/contrib/edk2/Include/IndustryStandard UefiTcgPlatform.h Tpm20.h, sys/contrib/edk2/Include/Protocol Tcg2Protocol.h

tpm20: Bring in the edk2 includes for TPM 2.0 support

Bring these in from edk2-stable202502. They will be used in a
forthcoming TPM 2.0 support code.

Sponsored by:           Netflix

(cherry picked from commit 1aa241b4ee657b8a62a0d86b91f82cf792f08dca)
DeltaFile
+2,165-0sys/contrib/edk2/Include/IndustryStandard/Tpm12.h
+1,813-0sys/contrib/edk2/Include/IndustryStandard/Tpm20.h
+722-0sys/contrib/edk2/Include/IndustryStandard/UefiTcgPlatform.h
+335-0sys/contrib/edk2/Include/Protocol/Tcg2Protocol.h
+5,035-04 files

FreeBSD/src a1fbb46 — sys/dev/sound/pci/hda hdac.h hdaa_patches.c

snd_hda: Enable the headset microphone on Framework ALC295 laptops

The ALC295's jack is configured in headphone-only mode by default. Set
it to CTIA headset mode so that the headset microphone can work,
otherwise the pin configuration patches alone are not enough.

One caveat, as a result of jack presence detection not working properly,
is that a user has to switch between internal and headset microphones
using mixer(8). The "monitor" knob corresponds to the internal mic, and
"mic" to the headset one.

This patch currently covers the Framework 11th Gen (0x0001), AMD Ryzen
7040 13in (0x0006), and AMD Ryzen AI 300 (0x000b).

Linux commit 5a36767 used as a reference.

See also:       https://github.com/torvalds/linux/commit/5a36767a41650518f35ea0bae9a2d6e775f1aed1
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D60527
DeltaFile
+48-1sys/dev/sound/pci/hda/hdaa_patches.c
+1-0sys/dev/sound/pci/hda/hdac.h
+49-12 files

FreeBSD/src 7589cfe — share/man/man4 iflib.4, share/man/man9 iflibdi.9

iflib: Expose locked datapath quiescence for driver resets

Provide iflib_quiesce() for driver-managed resets which must stop the
framework datapath before dismantling device resources.  Require the
context lock, preserve administrative flags, and reject detach, power
transitions, and recursive lifecycle calls without requesting a restart.

Make the stop path wait for queue tasks, callouts, and inline hardware
users before invoking IFDI_STOP and releasing packet mappings.  Mask
interrupts again after draining task tails which may have reenabled them.

Drain mp_ring under its existing consumer ownership.  When the ring is
empty, reserve all producer space so late transmitters take the existing
ring-full path and return ENETDOWN.  Reopen the ring after successful
initialization.  Keep completion polling inside consumer ownership.

Simple TX uses its existing producer count, mutex, and deferred-free
slot.  Check ALTQ admission under the send queue lock so stop can purge
pending packets before a restart.

    [10 lines not shown]
DeltaFile
+128-89sys/net/iflib.c
+70-3sys/net/mp_ring.c
+47-1share/man/man9/iflibdi.9
+7-2sys/net/ifq.h
+3-3share/man/man4/iflib.4
+3-0sys/net/iflib.h
+258-982 files not shown
+261-998 files

FreeBSD/src 2ad0885 — tests/sys/fs/ufs sync_test.c

tests/sys/fs/ufs/sync_test.c: hide the alignment warning

Reported and tested by: dhw
Fixes:  afe1dec7425c ("tests: add UFS synchronous write durability tests")
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit af08f29e5fc05d1e67370b36800b20ac95937a51)
DeltaFile
+2-2tests/sys/fs/ufs/sync_test.c
+2-21 files

FreeBSD/src 7a11a86 — contrib/pkgconf meson.build configure.ac, contrib/pkgconf/libpkgconf libpkgconf.h

Merge pkgconf 3.0.10 into main

This change just fixes a version number in the build system.

Reviewed by:    emaste
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D61935
DeltaFile
+3-3lib/libpkgconf/libpkgconf/config.h
+6-0contrib/pkgconf/NEWS
+2-2contrib/pkgconf/libpkgconf/libpkgconf.h
+1-1contrib/pkgconf/meson.build
+1-1contrib/pkgconf/configure.ac
+1-1contrib/pkgconf/Makefile.lite
+14-86 files

FreeBSD/src 2ab5877 — sys/powerpc/powerpc ptrace_machdep.c

powerpc: use the register validity flags in the vector ptrace requests

PT_SETVRREGS and PT_SETVSRREGS set PCB_VEC and PCB_VSX, which say the
thread owns the unit, instead of PCB_VECREGS and PCB_FPREGS, which say
the saved registers are valid. Ownership should only come from the
unavailable trap or cpu_switchin(), and the trap asserts it isn't set
yet, so setting the VSX registers of a traced child that hasn't used
the FPU panics an INVARIANTS kernel on the child's first VSX
instruction. Tracing your own child is enough, no privilege needed.

The getters had the matching problem: they returned the saved
registers only while the thread owned the unit, so a thread stopped
with valid but unloaded registers showed the debugger zeroes.

The thread is stopped, so the PCB is what counts. Set and test the
validity flags instead.

Reviewed by:    jhibbits
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D62035
DeltaFile
+10-8sys/powerpc/powerpc/ptrace_machdep.c
+10-81 files

FreeBSD/src 99f361f — sys/dev/mpi3mr mpi3mr.c

mpi3mr: Fix HostTag conversion in timestamp sync

In mpi3mr_timestamp_sync(), HostTag is a 16-bit field (U16) in
Mpi3IoUnitControlRequest_t. It was incorrectly initialized using
htole64(MPI3MR_HOSTTAG_INITCMDS) instead of htole16().

On little-endian architectures (amd64, arm64), htole64(1) leaves the
value as 1, which fits into a 16-bit integer without value truncation.
However, on big-endian architectures (such as powerpc64), htole64(1)
byte-swaps the 64-bit value to 0x0100000000000000 (72057594037927936).
Assigning this to a U16 causes truncation to 0 and triggers a fatal
compiler build failure under -Werror=constant-conversion:

implicit conversion from 'unsigned long' to 'U16' (aka 'unsigned short')
changes value from 72057594037927936 to 0 [-Wconstant-conversion]

Fix this by using htole16(), consistent with all other HostTag
initializations in the driver.


    [2 lines not shown]
DeltaFile
+1-1sys/dev/mpi3mr/mpi3mr.c
+1-11 files

FreeBSD/src c19cd5b — sys/dev/mpi3mr mpi3mr.h mpi3mr_cam.c

mpi3mr: Validate event bounds and tighten error handling

Validate firmware event payload lengths in top-half and bottom-half
event handlers for device status change, prepare-for-reset, energy pack
change, cable management, and device info change events to prevent
buffer over-reads on truncated or malformed firmware packets. Propagate
validation status from the device status top-half handler to prevent
scheduling bottom-half worker processing for invalid packets.

In addition, unlock the admin request spinlock when rejecting
submissions on unrecoverable controllers to avoid deadlocks. Synchronize
event queue teardown with the dedicated firmware event lock rather than
the main driver mutex to match worker queue locking, and add null checks
for memory allocations in CAM attach and bitmap scanning routines.

Reviewed by:    ssaxena
Differential Revision: https://reviews.freebsd.org/D60344
DeltaFile
+44-6sys/dev/mpi3mr/mpi3mr.c
+14-6sys/dev/mpi3mr/mpi3mr_cam.c
+2-0sys/dev/mpi3mr/mpi3mr.h
+60-123 files

FreeBSD/src a328ff2 — sys/dev/mpi3mr mpi3mr_cam.c

mpi3mr: Validate event payload sizes before deferred event processing

When processing asynchronous firmware events deferred to bottom-half
workers, the driver previously cast and dereferenced event payload
buffers directly into target structures - specifically device status
change and device configuration page structures - without verifying
whether the received payload was large enough to contain the expected
structure.

If a truncated, corrupted, or zero-length event was queued by top-half
processing, accessing these fields caused out-of-bounds memory reads
beyond the allocated event payload buffer. In addition, persistent
target identifiers in device addition events were extracted without
converting from little-endian format to host endianness.

Validate that event payload sizes are at least as large as the target
event structures before dereferencing fields, and ensure persistent
device identifiers are properly converted from little-endian to host
byte order.

    [3 lines not shown]
DeltaFile
+20-1sys/dev/mpi3mr/mpi3mr_cam.c
+20-11 files

FreeBSD/src 779ddcd — sys/dev/mpi3mr mpi3mr_cam.c

mpi3mr: Enforce runtime bounds on SGL segments and CDB lengths

Several runtime boundary checks in the I/O submission path previously
relied only on debug assertions or lacked complete validation:

1. When preparing scatter-gather lists for DMA, segment count validation
   relied only on a debug assertion that is omitted in production
   builds. If a command exceeded the controller's maximum supported
   segment count, the driver proceeded to build the scatter-gather list
   past allocated descriptor memory.
2. In the filter for unsupported SATA commands, the target structure's
   type-specific union was dereferenced without first checking the
   device form factor, risking type confusion on NVMe or Virtual Disk
   targets. In addition, CDB bytes were read only from the inline array,
   ignoring pointer-based commands.
3. In the SCSI command submission path, incoming command lengths were
   not checked against the 32-byte capacity of the hardware request
   frame, risking frame overflow.


    [7 lines not shown]
DeltaFile
+62-31sys/dev/mpi3mr/mpi3mr_cam.c
+62-311 files

FreeBSD/src cd19fab — sys/dev/mpi3mr mpi3mr.h

mpi3mr: Update driver version to 8.20.0.4.0

Update the driver version to 8.20.0.4.0.

Reviewed by:    imp
Differential Revision: https://reviews.freebsd.org/D60346
DeltaFile
+2-2sys/dev/mpi3mr/mpi3mr.h
+2-21 files

FreeBSD/src adcc757 — sys/dev/mpi3mr mpi3mr.h mpi3mr.c

mpi3mr: Use sx lock for IOCTL serialization

Holding a non-sleepable mutex across IOCTL processing violates
locking invariants, as copying data to and from user space can
page fault and firmware completion waits sleep via pause().

Replace the mutex with a sleepable sx (shared/exclusive) lock to
serialize driver and MPT IOCTL execution across sleepable boundaries.
Initialize the sx lock during controller setup and release it during
driver teardown.

Reviewed by:    ssaxena
Differential Revision: https://reviews.freebsd.org/D60345
DeltaFile
+2-4sys/dev/mpi3mr/mpi3mr_app.c
+3-0sys/dev/mpi3mr/mpi3mr.c
+2-0sys/dev/mpi3mr/mpi3mr.h
+7-43 files

FreeBSD/src b8756ce — sys/dev/mpi3mr mpi3mr_pci.c mpi3mr.c

mpi3mr: Fix management command timeouts and teardown ordering during detach

During driver unload under active I/O, the driver resets the controller
via Message Unit Reset (MUR). Firmware sends completion events during
the reset, but the driver was discarding them because the shutdown flag
was set. Dropping these completions caused pending management IOCTLs to
time out, leaving the controller in a faulted state that prevented clean
re-initialization on subsequent driver reloads.

In addition, userland character device nodes were detached after the
hardware reset, allowing new IOCTLs to arrive while hardware cleanup was
underway.

Fix these issues by:

1. Removing the shutdown check in event processing so in-flight
   completions finish normally instead of timing out.
2. Detaching userland device nodes before tearing down hardware
   resources to prevent new IOCTLs from arriving during unload.

    [3 lines not shown]
DeltaFile
+0-4sys/dev/mpi3mr/mpi3mr.c
+1-1sys/dev/mpi3mr/mpi3mr_pci.c
+1-52 files

FreeBSD/src be6b2bc — sys/dev/mpi3mr mpi3mr.c

mpi3mr: Validate request queue ID and consumer index bounds in completions

When processing command completions, the driver receives completion
descriptors containing the request queue ID and the updated request
queue consumer index. Previously, the driver trusted these values
without bounds checking.

If an invalid queue ID was reported for an operational completion, using
it to index the operational queue array caused an out-of-bounds access.
In addition, if a consumer index exceeded the queue capacity (in either
an admin or operational completion), the driver stored an out-of-bounds
index into its internal tracking.

Validate that the operational request queue ID is within the range of
allocated queues before indexing, and verify that the consumer index is
within queue depth for both admin and operational queues before updating
tracking.

Reviewed by:    imp
Differential Revision: https://reviews.freebsd.org/D60339
DeltaFile
+8-3sys/dev/mpi3mr/mpi3mr.c
+8-31 files

FreeBSD/src bf72e6f — sys/dev/mpi3mr mpi3mr.c

mpi3mr: Validate entry counts against payload length in topology events

When the controller notifies the driver of SAS or PCIe topology changes,
the firmware event notification includes a payload length and an entry
count indicating the number of PHY or port descriptors attached to the
event. Previously, the top-half event handlers iterated over the entry
count without verifying whether the payload buffer was actually large
enough to contain all reported entries. A malformed event with an entry
count exceeding the buffer length would result in reading memory beyond
the event descriptor.

Validate that the reported event length covers the base topology header
and compute the maximum number of entries that fit within the payload.
If the entry count exceeds the available buffer, reject the event and
skip scheduling deferred bottom-half processing.

Reviewed by:    ssaxena
Differential Revision: https://reviews.freebsd.org/D60336
DeltaFile
+40-7sys/dev/mpi3mr/mpi3mr.c
+40-71 files

FreeBSD/src 14d27f3 — sys/dev/mpi3mr mpi3mr_app.c mpi3mr.c

mpi3mr: Bound event payload and log data copies to allocated buffer sizes

When processing asynchronous event notifications from controller
firmware, the driver trusted the firmware-reported event data length
without verifying whether it fit within the physical reply buffer frame.
If an event reported a length exceeding the reply frame size, copying
the payload into bottom-half event queues or saving diagnostic log data
caused memory reads beyond the reply buffer boundaries.

In addition, when saving log data into the driver's circular logging
buffer, the copy size was bounded against the total slot size rather
than the payload capacity, failing to account for the entry header and
causing writes to overflow into adjacent buffer slots.

Clamp all event data copy lengths to the maximum capacity of the reply
buffer frame, and account for entry header overhead when saving log data
to prevent buffer overflows.

Reviewed by:    ssaxena
Differential Revision: https://reviews.freebsd.org/D60337
DeltaFile
+13-2sys/dev/mpi3mr/mpi3mr.c
+2-1sys/dev/mpi3mr/mpi3mr_app.c
+15-32 files

FreeBSD/src ec4c8ae — sys/dev/mpi3mr mpi3mr.c

mpi3mr: Enforce frame alignment and bounds checks on reply and sense buffers

When the controller posts command completions or sense data, firmware
provides physical DMA addresses that the driver translates into virtual
addresses within its pre-allocated reply and sense buffer pools.

Previously, these address translation helpers lacked complete
validation:

1. The reply buffer lookup checked only the starting physical address
   without verifying that the full frame size fit within the pool,
   and did not check whether the address aligned to the fixed reply
   frame stride.
2. The sense buffer lookup performed no bounds checking whatsoever,
   blindly computing an offset from the pool base.

If firmware reported a corrupted address or an unaligned offset,
the driver computed an invalid virtual pointer, leading to memory
access outside the allocated buffer pools.

    [8 lines not shown]
DeltaFile
+17-8sys/dev/mpi3mr/mpi3mr.c
+17-81 files

FreeBSD/src 564d209 — sys/dev/mpi3mr mpi3mr.h mpi3mr_cam.c

mpi3mr: Re-resolve target handle during error recovery and flush

When an I/O request encounters a timeout or requires error recovery
(such as aborts or target resets), the recovery routines previously
dereferenced the cached target structure pointer stored in the command.
If the target device was detached or removed from the system while the
timed-out request was pending, the target structure had already been
freed, causing error recovery and I/O flush routines to dereference
freed memory.

Store the target device's hardware handle in the command structure at
submission time, and re-resolve the target by handle from the active
device list during error recovery, task management, and I/O flushing. If
the target no longer exists in the active list, recovery routines skip
the command safely without dereferencing freed pointers.

Reviewed by:    ssaxena
Differential Revision: https://reviews.freebsd.org/D60340
DeltaFile
+24-1sys/dev/mpi3mr/mpi3mr.c
+8-8sys/dev/mpi3mr/mpi3mr_cam.c
+1-0sys/dev/mpi3mr/mpi3mr.h
+33-93 files

FreeBSD/src f864363 — sys/dev/mpi3mr mpi3mr_app.c

mpi3mr: Validate user buffer length against SGE overhead in RAID management

For RAID management passthrough commands, the driver embeds the
scatter-gather list directly inside the kernel DMA buffer immediately
following the user data payload. Previously, the driver did not verify
that the kernel buffer had sufficient room to hold both the user data
and the required scatter-gather element.

If a userland request supplied a buffer length that left less space than
a single scatter-gather element, unsigned subtraction underflowed the
available descriptor calculation. This bypassed subsequent bounds checks
and resulted in memory corruption when constructing the scatter-gather
list past the end of the allocated buffer.

Validate that the user buffer length leaves sufficient space for the
scatter-gather element overhead, safely rejecting oversized requests
before constructing the scatter-gather list.

Reviewed by:    imp
Differential Revision: https://reviews.freebsd.org/D60334
DeltaFile
+8-0sys/dev/mpi3mr/mpi3mr_app.c
+8-01 files