HardenedBSD/src 55f887eshare/man/man7 mitigations.7, sys/contrib/openzfs/include/os/freebsd/linux compiler.h

Merge remote-tracking branch 'origin/hardened/current/master' into hardened/current/cross-dso-cfi
DeltaFile
+139-0tests/include/endian_test.c
+136-0tests/include/sys_endian_test.c
+8-75sys/contrib/openzfs/include/os/freebsd/linux/compiler.h
+76-0tests/include/byteswap_test.c
+12-10share/man/man7/mitigations.7
+13-0tests/include/endian_sys_endian_test.c
+384-85114 files not shown
+595-255120 files

HardenedBSD/src 0626321share/man/man7 mitigations.7, sys/contrib/openzfs/include/os/freebsd/linux compiler.h

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+139-0tests/include/endian_test.c
+136-0tests/include/sys_endian_test.c
+8-75sys/contrib/openzfs/include/os/freebsd/linux/compiler.h
+76-0tests/include/byteswap_test.c
+12-10share/man/man7/mitigations.7
+13-0tests/include/endian_sys_endian_test.c
+384-85114 files not shown
+595-255120 files

HardenedBSD/src a24dacdshare/misc committers-src.dot

committers-src: Add myself

Approved by:    srcmgr
DeltaFile
+1-0share/misc/committers-src.dot
+1-01 files

HardenedBSD/src 09c999bsys/geom/part g_part.h g_part_gpt.c

gpart: More nuance for GPT support

A careful reading of the GPT standard shows that one may have fewer than
128 entries in your GPT table. While the standard requires that we
reserve enough space (32 512-byte-LBAs or 4 4096-byte-LBAs), it also
explicitly allows one to specify fewer actual partitions (since that
controls what is in the CRC). It requires that the first LBA to be 32
(512 sectors) or 6 (4k sectors) or larger. That requirement is not
enforced (it's not listed as one of validation criteria for the GPT).
We should likely do so in the future.

To that end, allow a default number of entries to use (defent) on
creation to be different (larger) than the minimum number of legal
entries. For gpt, these numbers work out to 128 and 1 respectively.  For
all the others, make minent == defent so this is a nop for those
partitioning schemes.

Sponsored by:           Netflix
Reviewed by:            zlei, emaste
Differential Revision:  https://reviews.freebsd.org/D42246
DeltaFile
+3-2sys/geom/part/g_part.h
+2-1sys/geom/part/g_part_gpt.c
+1-1sys/geom/part/g_part.c
+1-0sys/geom/part/g_part_ebr.c
+1-0sys/geom/part/g_part_mbr.c
+1-0sys/geom/part/g_part_apm.c
+9-42 files not shown
+11-48 files

HardenedBSD/src ac77b26tests/include endian_test.c sys_endian_test.c

tests: Test endian.h, byteswap.h, sys/endian.h and both endian.h and byteswap.h together

What's required and not required to be defined is complicated. Write
tests to enshrine it:
        endian.h and sys/endian.h:
                [bl]e{16,32,64}toh
                hto[bl]e{16,32,64}
        byteswap.h:
                {__,}bswap_{16,32,64}
        sys/endian.h:
                {__,}bswap{16,32,64}
                _BYTE_ORDER
                _BIG_ENDIAN
                _LITTLE_ENDIAN
                _PDP_ENDIAN
        endian.h:
                __BYTE_ORDER
                __BIG_ENDIAN
                __LITTLE_ENDIAN

    [11 lines not shown]
DeltaFile
+139-0tests/include/endian_test.c
+136-0tests/include/sys_endian_test.c
+76-0tests/include/byteswap_test.c
+13-0tests/include/endian_sys_endian_test.c
+12-0tests/include/sys_endian_endian_test.c
+9-0tests/include/byteswap_endian_test.c
+385-01 files not shown
+391-07 files

HardenedBSD/src 9dbff03sys/dev/nvme nvme_sysctl.c nvme_ctrlr.c

nvme: Inject artificial failure on reset

Add a sysctl to artificially fail the reset to test the failure to reset
hardware code path. While there are many ways that reset can fail, this
provides an adequate way that similates enough of the failures well
enough to shake out this failure path.

Sponsored by:           Netflix
Differential Revision:  https://reviews.freebsd.org/D28584
DeltaFile
+4-0sys/dev/nvme/nvme_sysctl.c
+1-1sys/dev/nvme/nvme_ctrlr.c
+1-0sys/dev/nvme/nvme_private.h
+6-13 files

HardenedBSD/src 82c96fesys/dev/nvme nvme_sysctl.c

nvme: Export recovery state

Export recovery state as a sysctl. This helps, sometimes, diagnose
what's going on.

Sponsored by:           Netflix
DeltaFile
+4-0sys/dev/nvme/nvme_sysctl.c
+4-01 files

HardenedBSD/src 1667245share/man/man9 cdefs.9, sys/compat/linuxkpi/common/include/linux compiler.h

cdefs: Add __deprecated

Add __deprecated decorator. This is for a deprecated interface. copystr
is tagged with this today in copy(9), but don't actually provide it or
use it. copystr is a #define so adding it will have to wait.

LinuxKPI was defining this away completely in compiler.h. Since this is
shared between Linux KPI consumers and OpenZFS, if it's already defined,
use the FreeBSD sys/cdefs.h version, otherwise define it away. For
OpenZFS this will retain it, while for Linux KPI it will tend to drop it
(I think always, but I didn't look at everything).

Sponsored by:           Netflix
Reviewed by:            jhb, emaste
Differential Revision:  https://reviews.freebsd.org/D46137
DeltaFile
+5-1share/man/man9/cdefs.9
+2-0sys/compat/linuxkpi/common/include/linux/compiler.h
+1-0sys/sys/cdefs.h
+8-13 files

HardenedBSD/src b487b1fsys/contrib/openzfs/include/os/freebsd/linux compiler.h, sys/contrib/openzfs/include/os/freebsd/spl/sys ccompat.h debug.h

openzfs/freebsd: Use compiler.h from FreeBSD's base's linuxkpi

The FreeBSD linux/compiler.h in OpenZFS was copied from a very old
version of FreeBSD's linuxkpi's linux/compiler.h. There's no need for
this duplication. Use FreeBSD's linuxkpi version instead, and provide
zfs_fallthrough to augment it (it's all that's needed). Use #pragma once
to avoid naming issues for guard variables. Since this is a complete
rewrite, use my copyright here (the original code in FreeBSD still
credits everybody).

Remove extra copies of macros that were defined elsewhere, but are now
properly defined in LinuxKPI so are redundant.

This is currently pull request #16650 upstream. Committing now to get
wider testing (make universe works, but historically doesn't catch all
errors).

Sponsored by:           Netflix
Reviewed by:            brooks
Differential Revision:  https://reviews.freebsd.org/D47131
DeltaFile
+8-75sys/contrib/openzfs/include/os/freebsd/linux/compiler.h
+0-9sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompat.h
+0-4sys/contrib/openzfs/include/os/freebsd/spl/sys/debug.h
+8-883 files

HardenedBSD/src b34a4edusr.sbin/bhyve pci_virtio_console.c

bhyve: avoid buffer overflow in pci_vtcon_control_send

This is a follow-up to the fix for HYP-19, addressing another condition
where an overflow might still occur. (Spotted by jhb@, thanks!)

Reported by:    Synacktiv
Reviewed by:    markj
Security:       HYP-19
Sponsored by:   Alpha-Omega Project
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D46882
DeltaFile
+5-2usr.sbin/bhyve/pci_virtio_console.c
+5-21 files

HardenedBSD/src 23cb03dlib/libsys thr_kill.2

thr_kill(2): fix title

Mandoc emits a STYLE warning due to the lowercase letters.
DeltaFile
+1-1lib/libsys/thr_kill.2
+1-11 files

HardenedBSD/src a51584alib/libdevctl devctl.3, share/man/man4 watchdog.4 ng_iface.4

manuals: Fix some "missing section argument"

These were reported by `mandoc -T lint ...` as warnings.

Signed-off-by:  Graham Percival <gperciva at tarsnap.com>
Reviewed by:    mhorne, Alexander Ziaee <concussious.bugzilla at runbox.com>
Sponsored by:   Tarsnap Backup Inc.
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1467
DeltaFile
+4-4share/man/man4/watchdog.4
+2-2share/man/man4/ng_iface.4
+1-1share/man/man4/qat.4
+1-1share/man/man9/contigmalloc.9
+1-1share/man/man9/osd.9
+1-1lib/libdevctl/devctl.3
+10-105 files not shown
+15-1511 files

HardenedBSD/src 229381dshare/man/man4 pfsync.4 hidraw.4, share/man/man9 cdefs.9

manuals: Misc syntax fixes

These were reported by `mandoc -T lint ...` as errors.

The rendered output (in ascii and html) is not affected by this commit.

Signed-off-by:  Graham Percival <gperciva at tarsnap.com>
Reviewed by:    mhorne
MFC after:      3 days
Sponsored by:   Tarsnap Backup Inc.
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1459
DeltaFile
+2-2usr.sbin/bhyve/bhyve_config.5
+0-2share/man/man4/pfsync.4
+1-1share/man/man4/hidraw.4
+1-0share/man/man9/cdefs.9
+1-0stand/lua/menu.lua.8
+5-55 files

HardenedBSD/src 6e1fc01lib/libpam/modules/pam_exec pam_exec.8, lib/libsys socket.2

manuals: Fix "unusual .Xr" warnings with a script

These were reported by `mandoc -T lint ...` as warnings:
- unusual Xr order
- unusual Xr punctuation

Fixes made by script in https://github.com/Tarsnap/freebsd-doc-scripts

Signed-off-by:  Graham Percival <gperciva at tarsnap.com>
Reviewed by:    mhorne, Alexander Ziaee <concussious.bugzilla at runbox.com>
Sponsored by:   Tarsnap Backup Inc.
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1464
DeltaFile
+4-4share/man/man9/cr_bsd_visible.9
+4-4share/man/man9/VOP_SETLABEL.9
+4-4share/man/man9/p_candebug.9
+3-3lib/libpam/modules/pam_exec/pam_exec.8
+3-3share/man/man9/cr_cansee.9
+3-3lib/libsys/socket.2
+21-2173 files not shown
+126-12779 files

HardenedBSD/src c329403share/man/man7 mitigations.7

mitigations.7: minor cleanup (linter errors)

Reviewed by:    emaste
MFC after:      3 days
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1428
DeltaFile
+7-5share/man/man7/mitigations.7
+7-51 files

HardenedBSD/src 22fb46ashare/man/man7 mitigations.7

mitigations.7: markup functions with Fn macro

+ include this page in `apropos Fn=memcpy`

Reviewed by:    emaste
MFC after:      3 days
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1428
DeltaFile
+5-5share/man/man7/mitigations.7
+5-51 files

HardenedBSD/src 5c59e40usr.sbin/wpa/wpa_supplicant wpa_supplicant.8

wpa_supplicant: xref relevant wpa_passphrase(8)

Reviewed by:    mhorne
MFC after:      3 days
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1461
DeltaFile
+2-1usr.sbin/wpa/wpa_supplicant/wpa_supplicant.8
+2-11 files

HardenedBSD/src c52ee72sys/contrib/ena-com ena_com.c, sys/dev/acpi_support acpi_sbl_wmi.c

Merge remote-tracking branch 'origin/hardened/current/master' into hardened/current/cross-dso-cfi
DeltaFile
+222-42sys/dev/ena/ena.c
+188-69sys/contrib/ena-com/ena_com.c
+193-0sys/dev/acpi_support/acpi_sbl_wmi.c
+0-149tests/sys/netpfil/pf/divapp.c
+149-0tests/sys/netpfil/common/divapp.c
+143-0sys/dev/psci/smccc_trng.c
+895-26053 files not shown
+1,716-54259 files

HardenedBSD/src 5cdca4dsys/contrib/ena-com ena_com.c, sys/dev/acpi_support acpi_sbl_wmi.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+222-42sys/dev/ena/ena.c
+188-69sys/contrib/ena-com/ena_com.c
+193-0sys/dev/acpi_support/acpi_sbl_wmi.c
+149-0tests/sys/netpfil/common/divapp.c
+0-149tests/sys/netpfil/pf/divapp.c
+143-0sys/dev/psci/smccc_trng.c
+895-26053 files not shown
+1,716-54259 files

HardenedBSD/src d41c0adsys/kern uipc_shm.c kern_proc.c, sys/vm vm_object.h vm_object.c

Merge branch 'freebsd/14-stable/main' into hardened/14-stable/master
DeltaFile
+44-11sys/kern/uipc_shm.c
+41-5sys/kern/kern_proc.c
+23-18sys/vm/vm_object.h
+33-4sys/vm/vm_object.c
+31-1sys/kern/sysv_shm.c
+11-1sys/kern/sysv_ipc.c
+183-4017 files not shown
+235-5023 files

HardenedBSD/src ce4cc74sys/dev/ena ena.h

ena: Update driver version to v2.8.0

Features:
* Add support for device request reset message over AENQ
* Support LLQ entry size recommendation from device
* Support max large LLQ depth from the device
* Expand PHC infrastructures
* Configuration notification support

Bug Fixes:
* Fix leaking ifmedia resources on detach
* Fix netmap socket chain unmapping issue
* Properly reinit netmap structs upon sysctl changes
* Correctly count missing TX completions

Minor Changes:
* Add reset reason for corrupted TX/RX completion descriptors
* Add reset reason for missing admin interrupts
* Improve reset reason statistics

    [5 lines not shown]
DeltaFile
+1-1sys/dev/ena/ena.h
+1-11 files

HardenedBSD/src f9c9c01sys/dev/ena ena.c

ena: Reinit netmap adapter struct upon sysctl changes

When attaching ENA driver, ena_netmap_attach() is invoked which, in turn
calls netmap_attach which, initializes a struct netmap_adapter,
allocating the struct's netmap_ring and the struct selinfo.

When we change the interface number of queues we need to reinit the
netmap adapter struct as well, so we need to detach it in order to free
the memory allocated by netmap_attach and allocate new memory based on
the new parameters like number of rings, ring size etc...

Without detaching and attaching the netmap interface, if we're to change
the number of queues from 8 to 2 for example and try to enable netmap,
the kernel will panic since the original netmap struct within the
kernel's possession still thinks that the driver has 8 queues which will
eventually cause a non-allocated virtual address access fault.

Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.
DeltaFile
+50-1sys/dev/ena/ena.c
+50-11 files

HardenedBSD/src 449496esys/dev/ena ena.c

ena: Fix leaking ifmedia resources on detach

ifmedia_add() allocates an ifmedia_entry during ena_attach.
Current code doesn't release this memory during ena_detach()

This commit calls ifmedia_removeall() to properly free the
allocated memory during ena_detach().

Also, in case ena_attach fails, we need to detach ifmedia
which was allocated within ena_setup_ifnet().

This bug was first described in:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278100

Reviewed by: zlei
Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.
DeltaFile
+3-0sys/dev/ena/ena.c
+3-01 files

HardenedBSD/src 7058794sys/dev/ena ena.c ena_sysctl.c

ena: Add support for device request reset message over AENQ

This commit adds a handler for the new aenq message
ENA_ADMIN_DEVICE_REQUEST_RESET,
which in turn causes the driver to trigger reset of a new type:
ENA_REGS_RESET_DEVICE_REQUEST. Also adds counting of such occurrences in
a new statistic for it.

Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.
DeltaFile
+12-1sys/dev/ena/ena.c
+2-0sys/dev/ena/ena_sysctl.c
+2-0sys/dev/ena/ena.h
+16-13 files

HardenedBSD/src 90953d2sys/dev/ena ena_sysctl.c

ena: Make global counters style unified

This commit changes the code so all global counters will have the
same line break.

Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.
DeltaFile
+4-5sys/dev/ena/ena_sysctl.c
+4-51 files

HardenedBSD/src d041955sys/dev/ena ena.c

ena: Support max large LLQ depth from the device

Large LLQ depth size is currently calculated by dividing the maximum
possible size of LLQ by 2.
In newer paltforms, starting from r8g the size of BAR2,
which contains LLQ, will be increased, and the maximum depth of
wide LLQ will be set according to a value set by the device, instead of
hardcoded division by 2.

The new value will be stored by the device in max_wide_llq_depth field
for drivers that expose ENA_ADMIN_LLQ_FEATURE_VERSION_1 or higher to
the device.

There is an assumption that max_llq_depth >= max_wide_llq_depth, since
they both use the same bar, and if it is possible to have a wide LLQ
of size max_wide_llq_depth, it is possible to have a normal LLQ of the
same size, since it will occupy half of the space.

Also moved the large LLQ case calculation of max_tx_queue_size

    [5 lines not shown]
DeltaFile
+21-15sys/dev/ena/ena.c
+21-151 files

HardenedBSD/src ce20b51sys/dev/ena ena_netmap.c

ena: Handle wrap around for prefetch in netmap

Netmap index wraps around based on the number of netmap kernel ring
slots.
Currently the driver prefetches the next slot using nm_i + 1 which may
be wrong since it does not handle wrap around.
This patch fixes that by using the kernel API for fetching the next
netmap index.

Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.
DeltaFile
+3-3sys/dev/ena/ena_netmap.c
+3-31 files

HardenedBSD/src f236e54sys/dev/ena ena_netmap.c

ena: Properly unmap last socket chain in netmap

In case ena_com_prepare_tx() fails within the netmap tx flow,
the driver will unmap the last socket chain.
Currently, the driver unmaps the wrong socket within
ena_netmap_unmap_last_socket_chain().

Illustration of the flow:

1- ena_netmap_tx_frames()
2- ena_netmap_tx_frame()
3- ena_netmap_tx_map_slots()
3.1- Map slot
3.2- Advance to the next socket
4- ena_com_prepare_tx()
4.1- ena_com_prepare_tx() fails
5- ena_netmap_unmap_last_socket_chain()

In step 5, where the driver unmaps the socket, the netmap

    [8 lines not shown]
DeltaFile
+1-1sys/dev/ena/ena_netmap.c
+1-11 files

HardenedBSD/src 2f17afdsys/dev/ena ena_netmap.c

ena: Clear NS_MOREFRAG flag for last netmap slot

When processing packets within the rx-flow
ena_netmap_rx_load_desc doesn't know the number of descriptors, so it
sets NS_MOREFRAG to all the slots to indicate that there are more
fragments for this packet.
The code calls ena_netmap_rx_load_desc() for every descriptor in
this packet to map the relevant buffer into the netmap shared memory.
After ena_netmap_rx_load_desc() calls, we need to unset the NS_MOREFRAG
for the last fragment to indicate that this is the last fragment,
so we explicitly turn off NS_MOREFRAG flag.
Current code overrides all other flags and sets NS_BUF_CHANGED.
This patch unsets the relevant flag only.

Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.
DeltaFile
+1-1sys/dev/ena/ena_netmap.c
+1-11 files

HardenedBSD/src da73e3asys/dev/ena ena_datapath.c

ena: Trigger reset when mbuf is NULL error happens

The mbuf is NULL issue happens when the device sends the driver
a completion with a wrong request id.
Trigger a reset whenever this happens.

Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.
DeltaFile
+6-2sys/dev/ena/ena_datapath.c
+6-21 files