FreeBSD/src eca7cba — sys/dev/virtio/p9fs virtio_p9fs.c

virtio_p9fs: Mark response buffers as initialized for KMSAN

MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
DeltaFile
+4-1sys/dev/virtio/p9fs/virtio_p9fs.c
+4-11 files

FreeBSD/src 73b3fb4 — sys/amd64/amd64 trap.c

amd64: Make the SYSENTER and INTn action same as for IDT case.

Fixes:  6e93f5e4d693 ("amd64: FRED support")
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
DeltaFile
+23-7sys/amd64/amd64/trap.c
+23-71 files

FreeBSD/src 8671e82 — sys/amd64/amd64 genassym.c exception.S

amd64: do not pass SYSENTER frame to FRED fast syscall handler

With FRED, SYSCALL is delivered as event type syscall (7) and vector 1.
SYSENTER is syscall with vector 2.  Handle SYSENTER in slow path,
otherwise 32bit code is able to execute 64bit syscalls.

Also check that SYSCALL comes from the 64bit mode. Intel already
specifies that SYSCALL causes #UD in compatibility mode, but there is no
AMD specification for SYSCALL under FRED yet, and SYSCALL is allowed
in compatibility mode on AMD with IDT event delivery.

Fixes:  6e93f5e4d693 ("amd64: FRED support")
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
DeltaFile
+4-4sys/amd64/amd64/exception.S
+6-0sys/amd64/amd64/genassym.c
+10-42 files

FreeBSD/src 473cd1b — sys/amd64/amd64 exception.S

amd64: fixes for register handling of syscall entry for FRED

- Save %r10 into tf_rcx.  This is the location for the 4th arg.
  libsys stubs do 'movq %rcx, %r10' so the fast syscall path works
  as is.  But Go binaries directly put arg 4 into %r10.
  Also save %r11 into tf_r11 for the duration of syscall handler.
- Somewhat improve binary compatibility with IDT SYSCALL fast return,
  by copying userspace return %rip into %rcx, and %rflags into %r11,
  emulating SYSCALL IDT delivery.

Fixes:  6e93f5e4d693 ("amd64: FRED support")
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
DeltaFile
+4-2sys/amd64/amd64/exception.S
+4-21 files

FreeBSD/src 5bc997b — sys/amd64/amd64 io.c, sys/amd64/linux linux_machdep.c

amd64: do not allow to set IOPL to 3 when FRED is used

SDM requires that IOPL is zero when returning to usermode with ERETU.

Do not set rflags.iopl for FreeBSD io(4) open.
This might be changed to disallow io(4) open for FRED at all with a
knob, if there is a real need.

Return ENOSYS from linux iopl(2), apparently Linux kernel can be
configured without iopl(2) support, so linux programs should be prepared
for this error.

Return EINVAL from vt(4)/syscons(4) ioctl(KDENABIO).

Fixes:  6e93f5e4d693 ("amd64: FRED support")
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
DeltaFile
+12-4sys/amd64/amd64/io.c
+3-0sys/dev/vt/vt_core.c
+3-0sys/dev/syscons/syscons.c
+3-0sys/amd64/linux32/linux32_machdep.c
+3-0sys/amd64/linux/linux_machdep.c
+24-45 files

FreeBSD/src e86a612 — sys/amd64/amd64 trap.c

trap_fred_handle_k_exc(): handle #AC in kernel

Fixes:  c6d7235ac15d ("amd64: handle #AC in kernel mode")
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
DeltaFile
+4-0sys/amd64/amd64/trap.c
+4-01 files

FreeBSD/src 787e2e4 — sys/amd64/amd64 initcpu.c

amd64_cpu_init_fred(): set stack level for NMI and not #NM

Fixes:  6e93f5e4d693 ("amd64: FRED support")
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
DeltaFile
+3-3sys/amd64/amd64/initcpu.c
+3-31 files

FreeBSD/src eb36c35 — tests/sys/sound sndstat.c mmap.c

sound tests: Check the return value of close(2)

While here, remove two munmap(2) calls on mappings the tests require to
have failed, since they are practically dead.

MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D60800
DeltaFile
+5-5tests/sys/sound/polling.c
+2-6tests/sys/sound/mmap.c
+2-2tests/sys/sound/sndstat.c
+9-133 files

FreeBSD/src 5760c22 — sys/dev/sound/pcm sound.h dsp.c

sound: Let pcm_unregister() tear down a partially initialized device

Since 3107b952f534 ("sound: Merge PCM_ALIVE() with PCM_REGISTERED()"),
pcm_unregister() is gated on PCM_REGISTERED(), so it cannot run unless
pcm_register() has already succeeded, which means drivers will leak
resources if a failure happened prior to this.

Reintroduce PCM_ALIVE(), but test dev rather than the lock. pcm_init()
assigns dev before anything else, so it can tell us whether pcm_init()
has run or not. Make sure to clear it in pcm_unregister() so that a
second call to pcm_unregister() cannot double-free.

While here, publish to sndstat(4) only once pcm_register() has
succeeded.

Reported by:    jah
Fixes:          3107b952f534 ("sound: Merge PCM_ALIVE() with PCM_REGISTERED()")
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation

    [2 lines not shown]
DeltaFile
+6-4sys/dev/sound/pcm/sound.c
+8-1sys/dev/sound/pcm/dsp.c
+2-2sys/dev/sound/pcm/sound.h
+16-73 files

FreeBSD/src 039a8e1 — sys/dev/ocs_fc ocs_device.c ocs_mgmt.c

ocs_fc: Fix config space bounds, double PRLI response and a stack overflow

Fix three unrelated problems found by security review of the driver.

ECD helper ioctl:
- OCS_ECD_HELPER_CFG_READ* and OCS_ECD_HELPER_CFG_WRITE* passed a user
  supplied offset straight to pci_read_config() and pci_write_config().
  Reject accesses that extend past PCIE_REGMAX, so that a wide access
  starting in range cannot run past the end of config space.
- Use the real access width (1, 2 or 4 bytes) of the command for both
  the BAR and the config space checks, rather than assuming 4 bytes, so
  that narrow accesses at the very end of the BAR or config space are
  not rejected while wider ones remain bounded.

PRLI:
- When a PRLI carries an FC-4 type other than the one the driver
  supports, ocs_d_send_prli_rsp() sent an LS_RJT and started node
  shutdown, but then fell through and sent a second response on the same
  IO (another LS_RJT, or a PRLI LS_ACC when the initiator is accepted),

    [19 lines not shown]
DeltaFile
+41-1sys/dev/ocs_fc/ocs_ioctl.c
+5-3sys/dev/ocs_fc/ocs_mgmt.c
+2-0sys/dev/ocs_fc/ocs_device.c
+48-43 files

FreeBSD/src 2608129 — sys/dev/ocs_fc ocs_cam.c ocs_os.h

ocs_fc: Harden ioctl, XRI lookup and FCP command validation

Fix several issues found by security review of the driver.

ioctl:
- Require PRIV_DRIVER for all ocs ioctls and create the device node
  with mode 0600, group wheel.
- Return the error from ocs_process_sli_config() to the caller.
  Previously only ENXIO was propagated, so a failed validation or a
  failed copyin() still issued the mailbox command, in the latter case
  with a descriptor pointing at freed memory.
- Reject COMMON_WRITE_OBJECT when in_bytes exceeds
  desired_write_length, and cap WRITE_OBJECT, READ_OBJECT,
  READ_OBJECT_LIST and non-embedded mailbox buffers at
  OCS_MAX_DMA_ALLOC, returning EINVAL.
- Use a 64-bit size for the non-embedded mailbox buffer to avoid
  truncation of a user supplied length.
- Refuse to copy out more than the size of the DMA buffer allocated
  for the command.

    [19 lines not shown]
DeltaFile
+53-6sys/dev/ocs_fc/ocs_ioctl.c
+14-1sys/dev/ocs_fc/ocs_unsol.c
+7-4sys/dev/ocs_fc/ocs_os.h
+10-1sys/dev/ocs_fc/ocs_hw.c
+11-0sys/dev/ocs_fc/ocs_hw_queues.c
+2-0sys/dev/ocs_fc/ocs_cam.c
+97-126 files

FreeBSD/src 9154ea3 — release/tools oci-image-static.conf

OCI: Remove dead code

We don't need to pick a repository URL when all we're doing is enabling
one which was specified in /etc/pkg/.

Reviewed by:    dch, imp
Fixes:  c73ae6734899 ("release/tools: use same pkg settings ...")
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D60868

(cherry picked from commit 93c05b743ea865bb87653e9ee5fbaa837c00eee7)
DeltaFile
+0-8release/tools/oci-image-static.conf
+0-81 files

FreeBSD/src a2b34aa — sys/powerpc/powerpc swtch64.S swtch32.S

powerpc: Avoid deadlock when CPUs exchange threads

The PowerPC context switch waited for the incoming thread to leave
blocked_lock before releasing the outgoing thread.  If two CPUs selected
each other's running threads concurrently, both CPUs waited for the
other to perform the release and neither could progress.  This appeared
as intermittent boot hangs under QEMU MTTCG when taskqueue threads were
bound to opposite CPUs.

8df2e5421468 ("powerpc: put the isync inside the TD_LOCK()...")
attempted to fix the same hang by moving isync into the polling loop.
That did not address the circular wait: isync cannot cause either CPU to
execute the release store after the loop.  It only added context
synchronization to failed iterations and changed timing. Move isync back
to the successful exit, which preserves acquire ordering for subsequent
context loads.

Match the ordering used by other architectures: publish the outgoing
thread's new lock before waiting for the incoming thread.  Apply the

    [22 lines not shown]
DeltaFile
+11-7sys/powerpc/powerpc/swtch64.S
+11-7sys/powerpc/powerpc/swtch32.S
+22-142 files

FreeBSD/src 0bc51f4 — sys/powerpc/powerpc swtch64.S swtch32.S

powerpc: Avoid deadlock when CPUs exchange threads

The PowerPC context switch waited for the incoming thread to leave
blocked_lock before releasing the outgoing thread.  If two CPUs selected
each other's running threads concurrently, both CPUs waited for the
other to perform the release and neither could progress.  This appeared
as intermittent boot hangs under QEMU MTTCG when taskqueue threads were
bound to opposite CPUs.

8df2e5421468 ("powerpc: put the isync inside the TD_LOCK()...")
attempted to fix the same hang by moving isync into the polling loop.
That did not address the circular wait: isync cannot cause either CPU to
execute the release store after the loop.  It only added context
synchronization to failed iterations and changed timing. Move isync back
to the successful exit, which preserves acquire ordering for subsequent
context loads.

Match the ordering used by other architectures: publish the outgoing
thread's new lock before waiting for the incoming thread.  Apply the

    [22 lines not shown]
DeltaFile
+11-7sys/powerpc/powerpc/swtch64.S
+11-7sys/powerpc/powerpc/swtch32.S
+22-142 files

FreeBSD/src 61c70dc — contrib/libarchive/libarchive archive_read_support_format_rar5.c archive_read.c, contrib/libarchive/libarchive/test test_read_format_7zip.c test_read_format_7zip_deflate_arm64_large.7z.uu

libarchive: merge from vendor branch

libarchive 3.8.10

ChangeLog:
https://github.com/libarchive/libarchive/compare/v3.8.9...v3.8.10

Obtained from:  libarchive
Vendor commit:  0c48412be2d94afe1859a807ea7896a18d8900bd
MFC after:      3 days
DeltaFile
+1,580-0contrib/libarchive/libarchive/test/test_read_format_7zip_deflate_arm64_large.7z.uu
+556-132contrib/libarchive/libarchive/archive_read_support_format_7zip.c
+521-3contrib/libarchive/libarchive/test/test_read_format_7zip.c
+186-324contrib/libarchive/libarchive/archive_read_support_filter_uu.c
+269-234contrib/libarchive/libarchive/archive_read.c
+339-150contrib/libarchive/libarchive/archive_read_support_format_rar5.c
+3,451-843284 files not shown
+14,057-2,764290 files

FreeBSD/src 5250c98 — usr.bin/man man.sh man.1

usr.bin/man: allow man(1) to search translated manpages in pure $man_lang subdirectory (+)

Currently our man(1) utility search manages only in $lang_country.$charset, $lang.$charset and,
as failover, in en.$charset which is historical behavior.
But nowadays most of ported software uses only $lang subdirectories for translated manpages
instead of use full locale notation, for example, share/ja/man1, share/de/man1, share/ru/man1.
In such cases, our man(1) utility cannot find any translated manpages and silently fallback to english version.

Add $man_lang in search path allows man(1) search and use translated manpages under historical and modern path traditions

MFC after:              1 day
MFC to:                 stable/15 stable/14
Reviewed by:            ziaee, fernape
Approved by:            fernape
Differential Revision:  https://reviews.freebsd.org/D55805
DeltaFile
+4-0usr.bin/man/man.1
+1-1usr.bin/man/man.sh
+5-12 files

FreeBSD/src 7b8151b — sys/netinet sctp_usrreq.c

sctp: improve handling of SO_SETFIB socket option

Since SCTP keeps fibnum in the SCTP protocol control block,
the code can't just defer the processing to the IPv4 or IPv6
layer. Therefore it needs to be implemented in the the SCTP
layer and it needs to call the socket layer function.

PR:             300091
Reviewed by:    tuexen
Fixes:          caccbaef8e26 ("socket: Move SO_SETFIB handling to protocol layers")
MFC after:      3 days
MFC to:         stable/14
MFC to:         stable/15
DeltaFile
+10-2sys/netinet/sctp_usrreq.c
+10-21 files

FreeBSD/src 67d06cf — share/examples/sound oss.h

sound examples: trigger dsp devices via syncgroup

Triggering is only needed if device is in mmap mode, and in mmap example
the device is triggered as part of syncgroup. For non-mmap mode,
triggering is not needed at all. Triggering mmap'ed device too early
would start the IPTR/OPTR counters and that would cause those pointers
to be out of sync, so let syncgroup do the triggering once the device is
fully configured and ready for capture and playback.

MFC after:      1 week
Reviewed by:    christos
Differential Revision:  https://reviews.freebsd.org/D60839

(cherry picked from commit d3aa926bffd20e4ef0e12e3ee9af1707ad234cda)
DeltaFile
+15-26share/examples/sound/oss.h
+15-261 files

FreeBSD/src 9a4bb77 — sys/dev/amdsmu amdsmu.c amdsmu.h

amdsmu: Use devclass name instead of module name

The diagnostics array contained expected modules to be loaded but the
checking logic checked for if a devclass of that name existed instead.

Have the diagnostics array contain the devclass instead as well as the
module to load for the hint string.

Furthermore, check tha the number of devices is greater than 0 so that
leftover devclasses from unloaded modules don't skip the hint.

Reported by:    emaste
Reviewed by:    emaste
Fixes:  758578370f6b ("amdsmu: Hints on what to do if IP block blocking S0i3")
Sponsored by:   The FreeBSD Foundation
Pull Request:   https://ron-dev.freebsd.org/FreeBSD/src/pulls/70
DeltaFile
+11-9sys/dev/amdsmu/amdsmu.h
+8-5sys/dev/amdsmu/amdsmu.c
+19-142 files

FreeBSD/src 509d65f — sys/riscv/riscv locore.S

riscv: Map the DTB when it is outside the kernel's 1GB region

When the kernel is started directly by SBI firmware, locore.S maps only
the 1GB region that contains the kernel, and initriscv() reads the DTB
through that mapping at the physical address passed in a1.  If the
firmware put the DTB in another 1GB region, as QEMU does with more than
1GB of RAM, fake_preload_metadata() faults before the console is up and
the kernel hangs.

Also map the 1GB region that contains the DTB.

This fixes direct kernel booting without FreeBSD loader(8).

PR:             299088
Reviewed by:    mhorne
Fixes:          bfb857546984 ("riscv: Construct an identity map in locore.S")
MFC after:      1 week
Signed-off-by:  Rick Richard <rick at sloservers.com>
DeltaFile
+15-3sys/riscv/riscv/locore.S
+15-31 files

FreeBSD/src a5f6137 — sys/kern vfs_inotify.c

inotify: Open target the directory when adding a watch

When an application uses inotify to watch a directory,
vn_inotify_add_watch() reads the directory entries and does a name
lookup so as to induce the filesystem to create namecache entries.
Some filesystems expect the directory to be opened before VOP_READDIR
can be called, so do that.

PR:             299239
Reviewed by:    kib
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D60782

(cherry picked from commit de80428118101624aaeaae02d59665d1027ff10e)
DeltaFile
+9-0sys/kern/vfs_inotify.c
+9-01 files

FreeBSD/src 72ec5a2 — sys/sys msan.h

kmsan: Add a required forward type declaration

MFC after:      1 week

(cherry picked from commit ad37abf653f77c59ce6c296eda9976c74c905d2e)
DeltaFile
+1-0sys/sys/msan.h
+1-01 files

FreeBSD/src d5d386d — usr.sbin/bhyve gdb.c

bhyve: fix integer overflow in qXfer packet parser

doff + dlen overflows unsigned int when both values are close to UINT_MAX,
causing the wrong branch to execute and passing an unbounded length to
append_binary_data().  Rewrite the comparison to avoid the addition.

Reviewed by:    markj
Fixes:          f81cdf24ba54 ("bhyve: Add support for XML register definitions")
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D60847

(cherry picked from commit 5ce0ab7355264d38fcde4684f0a64347ec0f5234)
DeltaFile
+1-1usr.sbin/bhyve/gdb.c
+1-11 files

FreeBSD/src 0bad002 — sys/netinet in.c, sys/netinet6 in6.c

netinet: Deprecate OSIOCAIFADDR and OSIOCAIFADDR_IN6

Requested by:   glebius
Reviewed by:    pouria, glebius
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D60247

(cherry picked from commit 4bb60157646df86c77cea130c66f63f119947709)
DeltaFile
+2-0sys/netinet/in.c
+1-0sys/netinet6/in6.c
+3-02 files

FreeBSD/src 68f8842 — sys/amd64/vmm x86.c

amd64/vmm: Don't advertise support for performance counters

vmm doesn't implement them, and after commit 2272fac218a8
("hwpmc: Add support for AMD-only IRPERF in hwpmc PERF class"), FreeBSD
guests fail to boot since they access the unimplemented IRPERF MSR.

MFC after:      1 week

(cherry picked from commit c83e075d72f62c91cb27dd644a62d6a6f5bd56ba)
DeltaFile
+1-2sys/amd64/vmm/x86.c
+1-21 files

FreeBSD/src 8738545 — sys/netinet tcp_subr.c

tcp: Preserve borrowed ICMPv6 error mbufs

The TCP-over-UDP ICMP callback receives ip6c_m as a borrowed chain owned
by icmp6_notify_error.  It used m_pulldown() to obtain a contiguous UDP
header even though that API frees the complete chain when the requested
range is unavailable.  The callback could then return without
propagating the lost ownership, leaving raw ICMP delivery to read and
free a stale head.

Validate that the complete UDP header was quoted, copy it through the
chain with m_copydata(), and temporarily advance the parser offset
instead of consuming bytes from the caller-owned packet.

A remote sender can reach the old path when TCP UDP tunneling is enabled
by quoting the configured local UDP source port in an ICMPv6 error and
including only four through seven UDP-header bytes.

Signed-off-by: Andrew Griffiths <andrew at calif.io>


    [5 lines not shown]
DeltaFile
+9-13sys/netinet/tcp_subr.c
+9-131 files

FreeBSD/src 508c057 — sys/net if.c

net: Fix handling of sockaddrs in the SIOC{ADD,DEL}MULTI handlers

The SIOCADDMULTI and SIOCDELMULTI handlers add or delete a link-layer
multicast address from an interface's multicast filter list.  The
link-layer address is passed using the ifr_addr field of the request
structure.

struct ifreq's ifr_addr field is a struct sockaddr, which is a fair bit
smaller than struct sockaddr_dl (though big enough to hold an ethernet
address).  Existing callers set the sockaddr length to
sizeof(struct sockaddr_dl), which is too large, and causes OOB accesses
when if_findmulti() is used to compare the address with others, or when
if_addmulti() makes a copy.

Fix this without breaking compatibility: copy the user-supplied address
into a sockaddr_dl on the stack, and use the latter for the respective
operation.

Also validate the sockaddr_dl internal length fields, suggested by zlei.

    [9 lines not shown]
DeltaFile
+25-4sys/net/if.c
+25-41 files

FreeBSD/src 5b3cfac — sys/kern sysv_shm.c

sysvshm: Fix locking in shm_prison_set()

We were not acquiring the global sysvshm lock when handling cleanup of
sysvshm segments.  Acquire the lock in shm_prison_cleanup() instead, to
be consistent with the sysv semaphore code.

Reviewed by:    jamie
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D60030

(cherry picked from commit 546d15061962a8c45c779210969015e30124fe8d)
DeltaFile
+2-2sys/kern/sysv_shm.c
+2-21 files

FreeBSD/src d0e92d8 — sys/netpfil/ipfilter/netinet ip_lookup.c

ipfilter: fix inverted range check on the lookup iterator unit

ipf_lookup_iterate() validates iter.ili_unit with

  if (iter.ili_unit < IPL_LOGALL && iter.ili_unit > IPL_LOGMAX)

or alternatively,

  if (iter.ili_unit < -1 && iter.ili_unit > 7)

ipf_lookup_add(), ipf_lookup_delete(), ipf_lookup_stats()
ipf_lookup_flush() validate with a ||

Submitted by calif.io for the OpenAI Patch The Planet program

Signed-off-by: Andrew Griffiths <andrew at calif.io>

Reviewed by:    markj
MFC after:      1 week

    [3 lines not shown]
DeltaFile
+1-1sys/netpfil/ipfilter/netinet/ip_lookup.c
+1-11 files

FreeBSD/src c495bc1 — sys/kern kern_jail.c

jail: Fix a race in prison_deref()

If we're killing a jail which has some user refs pending, then we would
first drop our ref and then kill all processes in the prison.  However,
it's possible for the prison to be freed before we finish that
operation, generally if the processes exit on their own before
prison_proc_iterate() returns.

Thus, defer the release of the prison refcount until after we've killed
all procs.

Reviewed by:    jamie
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D59984

(cherry picked from commit 79af745f4c29ab3df037fcf0a4b4fb1ea393825f)
DeltaFile
+6-2sys/kern/kern_jail.c
+6-21 files