FreeBSD/src 93f78e8 — sys/kern kern_prot.c

getpgid,getsid: Add capability mode checks

Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57385
DeltaFile
+4-0sys/kern/kern_prot.c
+4-01 files

FreeBSD/src 9b6ea59 — sys/kern kern_resource.c

rtprio*: Add capability mode checks

These syscalls are allowed in capability mode but accept an arbitrary
pid or lwpid.  Restrict them to the calling process in capability mode.

In capability mode rtprio_thread(2) only looks up threads of the
calling process, and returns ECAPMODE for any other lwpid, including
one that does not exist.

Sponsored by: Advanced Micro Devices, Inc.
Signed-off-by: Osvaldo Janeri Filho <ojanerif at amd.com>
Reviewed by:    olce
DeltaFile
+7-0sys/kern/kern_resource.c
+7-01 files

FreeBSD/src ad0569f — sys/amd64/vmm/io vioapic.c

vmm: Skip TMR rebuilds for edge-to-edge IOAPIC writes

IOAPIC redirection-table writes rendezvous all active vCPUs to
rebuild their vlapic trigger-mode registers when fields other than
mask or polarity change. Retargeting an edge-triggered pin incurs
this cost even though it does not contribute to the TMR.

vioapic_update_tmr() rebuilds the TMR from level-triggered entries
only. Skip the rendezvous when the modified entry is edge-triggered
both before and after the write. Check the old and new trigger modes
so that edge-to-level and level-to-edge transitions still rebuild
the TMR. Retain the existing all-vCPU rebuild path, mask/polarity
exclusions and remote-IRR handling.

Approved by:    markj, cperciva
Differential Revision:  https://reviews.freebsd.org/D60721
MFC to:         releng/15.2
Reported by:    Wanpeng Qian <wanpengqian at gmail.com>
Reviewed by:    Wanpeng Qian <wanpengqian at gmail.com>, markj

    [2 lines not shown]
DeltaFile
+6-4sys/amd64/vmm/io/vioapic.c
+6-41 files

FreeBSD/src 88d7efb — sys/amd64/vmm/intel vmx.c, sys/amd64/vmm/io vlapic_priv.h vlapic.c

vmm: Add a bulk TMR reset hook for Intel APICv

vioapic_update_tmr() resets all 256 vectors before rebuilding the
level-triggered vector set. With Intel virtual interrupt delivery,
each per-vector reset loads the VMCS, reads and writes an EOI-exit
bitmap, and clears the VMCS.

Add an optional bulk-reset hook so VMX can clear the four EOI-exit
bitmaps with one VMCS load/clear pair. Clear the software TMR banks
directly when using the hook, and retain the per-vector fallback
for backends without it.

Approved by:    markj, cperciva
Differential Revision:  https://reviews.freebsd.org/D60692
MFC to:         releng/15.2
Reviewed by:    markj

(cherry picked from commit ee9205f068c7675cf4d23e51cc98238d95ba1950)
DeltaFile
+21-0sys/amd64/vmm/intel/vmx.c
+11-1sys/amd64/vmm/io/vlapic.c
+1-0sys/amd64/vmm/io/vlapic_priv.h
+33-13 files

FreeBSD/src f741a23 — lib/libc/xdr xdr.c, sys/xdr xdr.c

xdr: Fix xdr_string

Forcing maxsize to RPC_MAXDATASIZE breaks code that deliberately uses
XDR with longer strings than permitted by SunRPC.

MFC after:      1 week
Fixes:          6448ec89e739 (" * limit size of buffers to RPC_MAXDATASIZE")
Fixes:          e17d7ab869bb ("xdr_string: don't leak strings with xdr_free")
Sponsored by:   Klara, Inc.
Sponsored by:   NetApp, Inc.
Reviewed by:    kevans, brooks
Differential Revision:  https://reviews.freebsd.org/D59994

(cherry picked from commit d2018cedb414ef17e77b7fc2fa19fd81328da46b)

xdr: Limit xdr_wrapstring

The previous commit (re)introduced the possibility that a malicious or
corrupt message can cause the receiver to allocate a very large amount

    [9 lines not shown]
DeltaFile
+2-2sys/xdr/xdr.c
+2-2lib/libc/xdr/xdr.c
+4-42 files

FreeBSD/src 2d1cf40 — lib/libc/xdr xdr.c, sys/xdr xdr.c

xdr_string: don't leak strings with xdr_free

Historically (and in a small amount of older software such as OpenAFS),
developers would attempt to free XDR strings with

        xdr_free((xdrproc_t)xdr_string, &string)

This resulted in xdr_free calling xdr_string with only two intentional
arguments and whatever was left in the third argument register.  If the
register held a sufficently small number, xdr_string would return FALSE
and not free the string (no one checks the return values).

Software should instead free strings with:

        xdr_free((xdrproc_t)xdr_wrapstring, &string)

Because buggy software exists in the wild, act as though xdr_wrapstring
was used in the XDR_FREE case and plug these leaks.


    [7 lines not shown]
DeltaFile
+7-0sys/xdr/xdr.c
+7-0lib/libc/xdr/xdr.c
+14-02 files

FreeBSD/src 204ab27 — lib/libc/xdr xdr.c, sys/xdr xdr.c

xdr_string: don't leak strings with xdr_free

Historically (and in a small amount of older software such as OpenAFS),
developers would attempt to free XDR strings with

        xdr_free((xdrproc_t)xdr_string, &string)

This resulted in xdr_free calling xdr_string with only two intentional
arguments and whatever was left in the third argument register.  If the
register held a sufficently small number, xdr_string would return FALSE
and not free the string (no one checks the return values).

Software should instead free strings with:

        xdr_free((xdrproc_t)xdr_wrapstring, &string)

Because buggy software exists in the wild, act as though xdr_wrapstring
was used in the XDR_FREE case and plug these leaks.


    [7 lines not shown]
DeltaFile
+7-0sys/xdr/xdr.c
+7-0lib/libc/xdr/xdr.c
+14-02 files

FreeBSD/src 1a57c6b — lib/libc/xdr xdr.c, sys/xdr xdr.c

xdr: Fix xdr_string

Forcing maxsize to RPC_MAXDATASIZE breaks code that deliberately uses
XDR with longer strings than permitted by SunRPC.

MFC after:      1 week
Fixes:          6448ec89e739 (" * limit size of buffers to RPC_MAXDATASIZE")
Fixes:          e17d7ab869bb ("xdr_string: don't leak strings with xdr_free")
Sponsored by:   Klara, Inc.
Sponsored by:   NetApp, Inc.
Reviewed by:    kevans, brooks
Differential Revision:  https://reviews.freebsd.org/D59994

(cherry picked from commit d2018cedb414ef17e77b7fc2fa19fd81328da46b)

xdr: Limit xdr_wrapstring

The previous commit (re)introduced the possibility that a malicious or
corrupt message can cause the receiver to allocate a very large amount

    [9 lines not shown]
DeltaFile
+2-2sys/xdr/xdr.c
+2-2lib/libc/xdr/xdr.c
+4-42 files

FreeBSD/src e1b5e1f — usr.bin/login login.c, usr.bin/su su.c

su, login: fix heap over-read in environment export filter

ok_to_export() (su.c) and export() (login.c) read s[n] before
strncmp(s, *pp, n) confirms s is at least n bytes long, where n is
the length of the blocked variable name. A PAM environment entry
shorter than that name over-reads past its heap allocation.

Check strncmp() first; it stops at s's NUL terminator and never
reads past the boundary that guarded the s[n] access.

MFC after:      1 week
Sponsored by:   Advanced Micro Devices, Inc.
Signed-off-by:  Osvaldo Janeri Filho <ojanerif at amd.com>
Reviewed by:    des, markj
Differential Revision:  https://reviews.freebsd.org/D61420
DeltaFile
+1-1usr.bin/su/su.c
+1-1usr.bin/login/login.c
+2-22 files

FreeBSD/src dcfc4d5 — tests/sys/net if_clone_test.sh, tests/sys/netgraph eiface_test.sh

tests/net: unskip tests waiting for bpf fixes

These tests pass for more than 200+ runs consecutively.

PR:             292993
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
DeltaFile
+0-2tests/sys/netgraph/eiface_test.sh
+0-2tests/sys/net/if_clone_test.sh
+0-42 files

FreeBSD/src 6af1856 — sys/dev/tpm tpm20.h tpm20.c

tpm: crb: Support the ACPI start method

Some AMD firmware TPMs report StartMethod 2 and had no driver. They never
acknowledge CTRL_REQ, so skip the idle and ready requests.

Do not harvest entropy from these TPMs on AMD: on a Ryzen 7 7735HS each
periodic TPM2_GetRandom froze every CPU, for up to 1.2 s (AMD PA-410).

Reviewed by:    kbowling
Approved by:    kbowling
Differential Revision:  https://ron-dev.freebsd.org/FreeBSD/src/pulls/103
DeltaFile
+92-3sys/dev/tpm/tpm_crb.c
+11-6sys/dev/tpm/tpm20.c
+1-0sys/dev/tpm/tpm20.h
+104-93 files

FreeBSD/src b75412f — sys/kern vfs_syscalls.c, sys/sys syscallsubr.h

kern_undelete: remove unused pathseg argument

I'd failed to pass it down to NDINIT, but nothing calls kern_uninit
with a path argument in sys space here or in CheriBSD so just drop it.

Effort:         CHERI upstreaming
Reported by:    llm-postcr
Sponsored by:   Innovate UK
Fixes:          7273d80ba18c ("vfs_syscalls.c: add kern_ and user_ implementations")
DeltaFile
+2-2sys/kern/vfs_syscalls.c
+1-2sys/sys/syscallsubr.h
+3-42 files

FreeBSD/src 53d8733 — sys/netipsec ipsec.c

ipsec: Do not reference the default policy for packets without a PCB

When no security policy matches a packet, ipsec[46]_getpolicy() returns
the default policy with a new reference, and the caller drops it right
after looking at the policy type.  Once any security policy is
configured, every forwarded packet goes through ip_forward() and
ipsec4_forward(), which checks the inbound and the outbound policy.
That is four atomic operations per packet on one reference count that
all CPUs write.

The default policy is allocated with its vnet and freed only when the
vnet goes away, and the sysctl limits it to NONE or DISCARD.  A packet
without a PCB has no policy cache to keep it in.  In that case, check
the policy type directly and take no reference, for NONE as well as for
DISCARD.  Packets with a PCB still take the reference, because the PCB
caches the policy.

No functional change intended.  DISCARD still drops the packet, and the
policy violation counters are incremented as before.

    [5 lines not shown]
DeltaFile
+30-6sys/netipsec/ipsec.c
+30-61 files

FreeBSD/src 0246afd — sys/conf files, sys/modules/zfs Makefile

zfs: add missing vdev_anyraid.c to module build after 013c77e66 merge
DeltaFile
+1-0sys/modules/zfs/Makefile
+1-0sys/conf/files
+2-02 files

FreeBSD/src d601628 — sys/kern kern_prot.c, sys/sys syscallsubr.h

freebsd14_[gs]groups: add kern_ and user_ implementations

Effort:         CHERI upstreaming
Sponsored by:   DARPA, AFRL
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+20-7sys/kern/kern_prot.c
+4-0sys/sys/syscallsubr.h
+24-72 files

FreeBSD/src 9f47314 — sys/kern kern_fork.c, sys/sys syscallsubr.h

pdrfork(2): add kern_pdrfork

Effort:         CHERI upstreaming
Sponsored by:   DARPA, AFRL
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+20-15sys/kern/kern_fork.c
+1-0sys/sys/syscallsubr.h
+21-152 files

FreeBSD/src b1482e0 — sys/kern sysv_shm.c, sys/sys syscallsubr.h

SysV SHM: make kern_shmat static

This is the opposite of most kern_ cases, but SysV IP is designed to be
loaded as a module and freebsd32 support lives inside the main
implementation file.  Arguably it should be in a seperate module with a
dependency, but that's a refactor for another day.

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

FreeBSD/src 30d7590 — sys/kern kern_exit.c, sys/sys syscallsubr.h

pdwait(2): add user_pdwait

Effort:         CHERI upstreaming
Sponsored by:   DARPA, AFRL
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+21-11sys/kern/kern_exit.c
+2-0sys/sys/syscallsubr.h
+23-112 files

FreeBSD/src 965170d — sys/sys syscallsubr.h, sys/vm swap_pager.c

swap{on,off}(2): add/expose kern_ implementations

Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+9-2sys/vm/swap_pager.c
+3-0sys/sys/syscallsubr.h
+12-22 files

FreeBSD/src 2b85ea0 — sys/cddl/compat/opensolaris/kern opensolaris.c

zfs: fix build after recent import

Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+0-2sys/cddl/compat/opensolaris/kern/opensolaris.c
+0-21 files

FreeBSD/src 29b2402 — sys/contrib/openzfs/cmd/zfs zfs_main.c, sys/contrib/openzfs/cmd/zpool zpool_main.c

zfs: merge openzfs/zfs at 013c77e66

Notable upstream pull request merges:
 #17567 816804dfd Add support for anyraid vdevsG
 #18826 -multiple FDT: don't extend dedup across RAIDZ expansion
 #18861 1ff8fc14a Fix out-of-bound access when resizing in receive_spill
 #19026 518021947 Add alloc factor logic
 #19091 e056f4df3 don't send spill or oversized blocks as WRITE_EMBEDDED
 #19125 6d5d3f635 Wait for the txg-time database write before setting
                  spa_final_txg
 #19170 b060bcb1d zio: drop a queued scan read only when its block is freed
 #19171 3db7dde41 dsl_scan: resume a scan which suspends at the origin
                  snapshot
 #19178 497f28f07 vdev_raidz: keep unverified dRAID rebuild repairs
                  speculative
 #19188 5f1957a15 spa: number new txgs above every uberblock on disk
 #19190 495d09b51 Export zpool_valid_proplist from libzfs
 #19191 ed07ad74e zdb: Lower eviction timeouts on prefetched data
 #19192 86b3fb1f4 Build the pool stats config without the namespace lock

    [161 lines not shown]
DeltaFile
+1,043-1,051sys/contrib/openzfs/cmd/zpool/zpool_main.c
+1,948-66sys/contrib/openzfs/lib/libnvpair/libnvpair.abi
+1,773-0sys/contrib/openzfs/module/zfs/vdev_anyraid.c
+650-647sys/contrib/openzfs/cmd/zfs/zfs_main.c
+559-650sys/contrib/openzfs/lib/libzfs/libzfs.abi
+501-397sys/contrib/openzfs/lib/libzfs/libzfs_pool.c
+6,474-2,811706 files not shown
+37,206-14,722712 files

FreeBSD/src 1ebf46e — sys/kern kern_module.c

modstat: don't copyout while holding a lock

If a user arranges for a page fault to never be filled (e.g., via a
FUSE file system), this can hold the shared lock forever.

To make this all work, refactor kern_modstat and freebsd32_modstat to
malloc a temporary buffer and fill it before copying it out rather
than doing a bunch of copies.

Add COMPAT_* ifdefs around compat code.  The module_stat_v1 code is
really for a.out binaries in practice and thus a bit questionable.

Reviewed by:    markj
Reported by:    llm-postcr
Sponsored by:   Innovate UK
Fixes:          7f8c2056db1e ("modstat: avoid copying from freed memory")
Differential Revision:  https://reviews.freebsd.org/D61432
DeltaFile
+153-108sys/kern/kern_module.c
+153-1081 files

FreeBSD/src f20c712 — sys/kern vfs_extattr.c, sys/sys syscallsubr.h

extattr*(2): add kern_ and user_ implementaions

Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+69-45sys/kern/vfs_extattr.c
+20-0sys/sys/syscallsubr.h
+89-452 files

FreeBSD/src 622365c — sys/kern kern_ntptime.c, sys/sys syscallsubr.h

ntp_gettime(2): add kern_ntp_gettime

Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+7-1sys/kern/kern_ntptime.c
+2-0sys/sys/syscallsubr.h
+9-12 files

FreeBSD/src 7273d80 — sys/kern vfs_syscalls.c, sys/sys syscallsubr.h

vfs_syscalls.c: add kern_ and user_ implementations

Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+123-57sys/kern/vfs_syscalls.c
+30-3sys/sys/syscallsubr.h
+153-602 files

FreeBSD/src 7ca5de2 — sys/kern vfs_cache.c, sys/sys syscallsubr.h

__getcwd(2), __getrealpath(2); add kern_ implementations

This corrects a accidentialy introduced definition of kern___getcwd.

Effort:         CHERI upstreaming
Fixes:          d718de812fe1 ("Introduce kern_mmap_req().")
Sponsored by:   DARPA, AFRL, Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+8-4sys/kern/vfs_cache.c
+3-2sys/sys/syscallsubr.h
+11-62 files

FreeBSD/src 87d8a91 — sys/kern vfs_mount.c, sys/sys syscallsubr.h

nmount(2): add kern_nmount

Effort:         CHERI UK
Sponsored by:   Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+12-6sys/kern/vfs_mount.c
+2-0sys/sys/syscallsubr.h
+14-62 files

FreeBSD/src c1dbf3f — sys/dev/clk/allwinner ccu_h6.c

aw_ccu: h6: Use the 1x PLL_PERIPH as parents of the MMC clocks

The MMC clocks of the H6 have the doubled outputs of the PLL_PERIPH0
and PLL_PERIPH1 as inputs of their mux, followed by a fixed post divider
of 2 that the driver does not know about.  The rate it computed was
twice the real one: on a Pine H64 the SD card requested at 50MHz and the
eMMC at 52MHz ran at half of that, and transfers at about half the speed
they should reach.  U-Boot does the same compensation, as it pretends
the parent is the 1x PLL.

Name the 1x PLLs as parents, like the H3 driver does.  The position in
the mux is the same.

Tested on: H6
DeltaFile
+6-1sys/dev/clk/allwinner/ccu_h6.c
+6-11 files

FreeBSD/src aa70464 — sys/arm/allwinner/h6 h6_r_padconf.c

allwinner: h6: Put the PM pins in bank M

The PM0 to PM4 entries of the pad table of the R_PIO controller had port
0 and pin 0, copied from the PL ones, so no pin could be found for a
<&r_pio 1 N> specifier.  On the Pine H64 model B the reset GPIO of the
SDIO WiFi power sequence is PM3, and the kernel panicked in
mmc_pwrseq_attach() with "invalid pin" as the pin number was never set.

Use port 1 and the real pin numbers, like the PL entries do with port 0.

Tested on: H6
DeltaFile
+5-5sys/arm/allwinner/h6/h6_r_padconf.c
+5-51 files

FreeBSD/src 256d628 — sys/arm/allwinner aw_gpio.c

aw_gpio: Fail when a pin cannot be mapped

aw_gpio_map_gpios() returned success without setting the pin when no
entry of the pad table matched the bank and pin of the specifier, so
the caller went on with whatever was in its variable.  Return EINVAL.

Tested on: H6
DeltaFile
+3-3sys/arm/allwinner/aw_gpio.c
+3-31 files