FreeBSD/src 793da13 — sys/netpfil/ipfw ip_fw_nat.c

ipfw_nat: Allocate the link of an address or protocol redirect

add_redir_spool_cfg() sizes the array of alias links of a redirect by
pport_cnt, but ipfw(8) sets pport_cnt only for redirect_port.  An
address or protocol redirect gets a zero-size allocation, and its one
link is stored past the end of it.  malloc(9) hands out at least 16
bytes, so nothing else is overwritten, but KASAN catches the store
since 3cd5e9e4ee03 added the fwd:nexthop_nat_v4 test, which configures
a redirect_addr:

  panic: ASan: Invalid access, 8-byte write at ..., MallocRedZone(fb)
  add_redir_spool_cfg() at ip_fw_nat.c:223
  nat44_config() at ip_fw_nat.c:543
  nat44_cfg() at ip_fw_nat.c:603

Allocate at least one link.

Reported by:    kp
MFC after:      3 days
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+3-2sys/netpfil/ipfw/ip_fw_nat.c
+3-21 files

FreeBSD/src c591785 — lib/libc/tests/stdio swscanf_test.c

stdio: Fix typo in scanset test

Fixes:          71c723518d22 ("stdio: Fix negated wchar scansets")
DeltaFile
+1-1lib/libc/tests/stdio/swscanf_test.c
+1-11 files

FreeBSD/src 8bfeff9 — sys/powerpc/powernv opal_async.c

powerpc/powernv: byte swap the OPAL async completion token

OPAL messages are big endian, but opal_handle_async_completion() took
the token straight from params[0]. On little endian a token reads as a
huge number that the int then truncates to 0, so every completion was
recorded against token 0. A request that happened to get token 0
worked by luck. Any other one only finished if
OPAL_CHECK_ASYNC_COMPLETION saw the message before the kernel's message
poller took it, and otherwise opal_wait_completion() spun forever.

I hit this on a POWER9 PowerNV machine with a one byte read from an I2C
EEPROM, which never returned. Swap the token, and check that it's in
range before using it as an index.

Reviewed by:    jhibbits
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D62361
DeltaFile
+10-2sys/powerpc/powernv/opal_async.c
+10-21 files

FreeBSD/src aad2ea3 — sys/cddl/contrib/opensolaris/uts/powerpc/dtrace fasttrap_isa.c

dtrace/powerpc: decode blr and bctr in the pid provider

OPX() shifted the instruction by two bits instead of one, so the
extended opcode never matched and blr and bctr weren't recognised.
They were treated like any other instruction, which means a single
step that powerpc doesn't have. A return probe on a function that ends
in blr panics an INVARIANTS kernel, and without INVARIANTS the traced
process spins on the tracepoint.

Fix the shift. Two more things were hidden behind it and have to be
fixed with it: bclr was typed as a bctr, so it would have returned
through CTR, and OP_RB() had the wrong mask, so some real or
instructions would have been taken for no-ops.

Reviewed by:    jhibbits
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D62360
DeltaFile
+3-3sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c
+3-31 files

FreeBSD/src 320fdff — sys/powerpc/powerpc trap.c

powerpc: let DTrace decide whether a kernel trap instruction is its probe

trap() tells an fbt probe from a debugger breakpoint by reading the
instruction at the trap address and comparing it with the fbt one. When
a probe is disabled fbt puts the original instruction back, and other
CPUs can already be in the trap for it by then. Such a CPU finds the
original instruction, takes the trap for a breakpoint and drops into
KDB. I've had a guest stop like that twice, both times when dtrace(1)
exited with a probe on a busy function.

DTrace doesn't need the instruction to know its probe. fbt_invop()
looks the address up in its own table, and dtrace_invop_start() returns
-1 when nobody claims it. So ask it for every kernel trap instruction
and go on to KDB only when it says no, like amd64 does.

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

FreeBSD/src d0b3390 — sys/ofed/drivers/infiniband/ulp/nfsclrdma clnt_rdma.c

clnt_rdma.c: Add ENODEV to the reconnect retry errors

The Intel 810 replies with ENODEV when a NIC is turned
off.  Add ENODEV to the list of errors that cause a
retry of a connect.

MFC after:      1 month
Fixes:  80bee4d83637 ("nfsclrdma: Add code to support client side NFS over RDMA")
DeltaFile
+1-1sys/ofed/drivers/infiniband/ulp/nfsclrdma/clnt_rdma.c
+1-11 files

FreeBSD/src 860f88a — sys/netipsec ipsec_input.c

netipsec: Set the IPv6 payload length before the enc(4) input hook

ipsec6_common_input_cb() corrects ip6_plen for the removed IPsec header
only after it has run the IPSEC_ENC_BEFORE hook, so enc(4) hands the
packet to bpf and pfil with the payload length of the packet as it was
received.  Since cb43e97aea11 ("pf: add missing IPv6 length check") pf
drops such a packet as short, so with pf enabled on enc0 and the default
net.enc.in.ipsec_filter_mask every inbound IPv6 packet protected by IPsec
was dropped.  The IPv4 path already fixes ip_len before its hook.

Set the payload length before running the hook.

Fixes:          fcf596178b5f ("Merge projects/ipsec into head/.")
MFC after:      2 weeks
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+3-3sys/netipsec/ipsec_input.c
+3-31 files

FreeBSD/src 2f5bd65 — sys/compat/linuxkpi/common/include/linux pci_ids.h

LinuxKPI: add SPACEMIT PCI IDs

Those were found in an updated wireless driver.

MFC after:      3 days
Reviewed by:    emaste
Differential Revision: https://reviews.freebsd.org/D60632
DeltaFile
+2-0sys/compat/linuxkpi/common/include/linux/pci_ids.h
+2-01 files

FreeBSD/src b7fb50b — sys/compat/linuxkpi/common/src linux_80211.c

LinuxKPI: 802.11: point vif->bss_conf.bssid at vif->cfg.ap_addr

In lkpi_sta_scan_to_auth(), vif->bss_conf.bssid was assigned directly to
ni->ni_bssid inside the ephemeral struct ieee80211_node.  When
lkpi_sta_auth_to_scan() (or an error path in lkpi_sta_scan_to_auth())
reset vif->cfg.ap_addr and freed ni via ieee80211_free_node(ni),
vif->bss_conf.bssid was left dangling.

Subsequent driver accesses to link_conf->bssid / vif->bss_conf.bssid
while unassociated (for example ether_addr_copy(info.tsf_bssid,
link_conf->bssid) in iwl_mld_handle_scan_complete_notif()) then
dereferenced the freed ieee80211_node, triggering a deterministic 6-byte
UMAUseAfterFree panic under KASAN (and reading freed/reused UMA memory
without KASAN).

Point vif->bss_conf.bssid at vif->cfg.ap_addr in both
lkpi_ic_vap_create() and lkpi_sta_scan_to_auth().  vif->cfg.ap_addr is
embedded in struct ieee80211_vif with the same lifetime, is initialized
to ieee80211broadcastaddr at VAP creation, updated in

    [12 lines not shown]
DeltaFile
+7-5sys/compat/linuxkpi/common/src/linux_80211.c
+7-51 files

FreeBSD/src 5d61c47 — sys/compat/linuxkpi/common/include/linux bitops.h

LinuxKPI: adjust return value of __ffs64

ffsll() returns an int;  there is no need for __ffs64 to return an
unsigned long; reduce it to an unsigned int which callers may expect.
As the result is undefined for no bits set we do not have to worry about
the -1.

MFC after:      3 days
Reviewed by:    emaste
Differential Revision: https://reviews.freebsd.org/D60715
DeltaFile
+1-1sys/compat/linuxkpi/common/include/linux/bitops.h
+1-11 files

FreeBSD/src 859cc75 — sys/compat/linuxkpi/common/src linux_80211.c

LinuxKPI: 802.11: remove old key from driver on re-key

On a WPA group rekey, the LinuxKPI 802.11 compat layer installs the
new key but never tells the driver to remove the old one.
With hw_crypto enabled, at least iwlwifi keeps one firmware key slot
per installed key and only has 16, so after about 14 rekeys the table
is full. The next key install fails and the card carries on decrypting
with the old group key, so broadcast and multicast traffic stop arriving.

For now remove the key immediately as net80211 tries to install a new
key in the same slot.  In theory this should be a deferred operation,
so leave an IMPROVE().

PR:             301069
MFC after:      3 days
DeltaFile
+20-5sys/compat/linuxkpi/common/src/linux_80211.c
+20-51 files

FreeBSD/src 8797d71 — libexec/rc/rc.d linux

rc.d/linux: load linux64 on powerpc64

linux_enable=YES didn't load anything on powerpc64.

Reviewed by:    jhibbits
Differential Revision:  https://reviews.freebsd.org/D62281
DeltaFile
+1-1libexec/rc/rc.d/linux
+1-11 files

FreeBSD/src fd9d481 — sys/compat/linux linux_misc.c

linuxulator/powerpc: fill in the machine name in uname()

It was left empty, so config.guess and everything else looking at
uname -m could not tell what it was running on.

Reviewed by:    jhibbits
Differential Revision:  https://reviews.freebsd.org/D62280
DeltaFile
+6-0sys/compat/linux/linux_misc.c
+6-01 files

FreeBSD/src 2d1fc19 — sys/dev/mlx5/mlx5_en mlx5_en_main.c en.h

mlx5en: fix RX HW timestamp overflow with 1GHz clock

mlx5e_mbuf_tstmp() splits the HW clock delta into seconds and a
sub-second remainder before scaling it by the calibration interval.
With a 1GHz core clock and the default 30 seconds recalibration
interval, both the remainder multiplied by the interval in ns and the
carry over multiplied by cclk exceed 2^64.  RX timestamps end up off by
up to two seconds, which shows up as clock drift in NTP using HW RX
timestamps.

Take the whole calibration intervals out of the HW clock delta first,
so that the rest of the computation does not depend on how far the
timestamp is from the calibration point, e.g. after the system was
suspended.  Then split the rest at 2^20 clocks, about 1ms at 1GHz,
instead of at seconds, using shifts and masks.  The split no longer
depends on the clock frequency, so priv->cclk is removed.

Reviewed by:    kib, gallatin
Sponsored by:   Nvidia networking

    [2 lines not shown]
DeltaFile
+37-29sys/dev/mlx5/mlx5_en/mlx5_en_rx.c
+0-2sys/dev/mlx5/mlx5_en/mlx5_en_main.c
+1-1sys/dev/mlx5/mlx5_en/en.h
+38-323 files

FreeBSD/src cada535 — sys/kern imgact_elf.c

imgact_elf: accept PT_INTERP segments up to 4096 bytes

The Yocto/Poky relocatable SDK NUL-pads the interpreter path in
PT_INTERP out to 4096 bytes (within Linux's POSIX PATH_MAX) so that
'relocate_sdk.py' can rewrite the path in place.  The kernel rejected
any PT_INTERP with p_filesz > BSD's MAXPATHLEN (1024) with
"Invalid PT_INTERP" and ENOEXEC, so none of the SDK's binaries could
be run under the Linuxulator.

- The PT_INTERP segment may now be up to 'PT_INTERP_SEG_MAXSZ'
  bytes, which may be greater than 'MAXPATHLEN'.
- The interpreter path within the segment must still be shorter
  than 'MAXPATHLEN' -- when violated results in 'ENAMETOOLONG'
  when the interpreter is looked up.

Reviewed by:    kib
Differential Revision: https://reviews.freebsd.org/D62075
(cherry picked from commit 7ee8d41ebb2ffb13e50ea59fd5bc43155123f323)
DeltaFile
+10-2sys/kern/imgact_elf.c
+10-21 files

FreeBSD/src 79d5c5b — sys/powerpc/linux linux_locore.asm linux_sysvec.c

linuxulator/powerpc: report the CPU family in AT_PLATFORM

Linux passes the CPU family here, e.g. power9. glibc uses it for
__builtin_cpu_is().

Reviewed by:    jhibbits
Differential Revision:  https://reviews.freebsd.org/D62279
DeltaFile
+31-0sys/powerpc/linux/linux_sysvec.c
+2-5sys/powerpc/linux/linux_locore.asm
+33-52 files

FreeBSD/src 7f74e2d — sys/modules/linux64 Makefile, sys/powerpc/linux linux_support.S linux_machdep.c

linuxulator/powerpc: implement the FUTEX_WAKE_OP helpers

These were stubs returning ENOTSUP. Qt uses FUTEX_WAKE_OP, so Qt programs
hung as soon as they started a thread.

Reviewed by:    jhibbits
Differential Revision:  https://reviews.freebsd.org/D62278
DeltaFile
+84-0sys/powerpc/linux/linux_machdep.c
+0-70sys/powerpc/linux/linux_support.S
+3-1sys/modules/linux64/Makefile
+87-713 files

FreeBSD/src 2cf4a4d — sys/compat/linux linux_ioctl.c linux_ioctl.h, sys/powerpc/linux linux_termbits.h linux_machdep.c

linuxulator/powerpc: fix terminal ioctls

linux_ioctl() only looks at the low 16 bits of the command, so the PowerPC
handler was never called and isatty() failed. Return ENOIOCTL for commands
we don't know, so that other handlers get a chance.

struct termios has c_cc before c_line and carries the speeds on PowerPC,
and CSIZE is encoded like on BSD. Fix the codes for 57600 and 115200 baud
while here.

Reviewed by:    jhibbits
Differential Revision:  https://reviews.freebsd.org/D62277
DeltaFile
+17-0sys/compat/linux/linux_ioctl.h
+3-5sys/powerpc/linux/linux_machdep.c
+6-2sys/powerpc/linux/linux.h
+6-2sys/compat/linux/linux_ioctl.c
+2-2sys/powerpc/linux/linux_termbits.h
+34-115 files

FreeBSD/src 08e7d27 — sys/dev/usb usbdevs, sys/dev/usb/quirk usb_quirk.c

Add USB quirk for WCH-Link adapter

WCH-Link is a debug adapter from QinHeng Electronics that features a
(proprietary) debug bridge for their RISC-V MCUs, as well as a serial
gateway, implemented as a CDC device.  The CDC's call management
descriptor declares the data interface to be 1, but it is actually
interface 2. UQ_IGNORE_CDC_CM has already been implemented before to
handle this kind of firmware bug, so just add this quirk for WCH-Link.

Reported by:    Holm Tiffe

(cherry picked from commit 1660d69068a0650fcda2ce7497dfa20e33f0b58d)
DeltaFile
+1-0sys/dev/usb/usbdevs
+1-0sys/dev/usb/quirk/usb_quirk.c
+2-02 files

FreeBSD/src 5cc3934 — sys/powerpc/linux linux.h

linuxulator/powerpc: use the PowerPC socket option numbers

Six socket options are numbered differently on PowerPC. linux_socket.h
already has an #ifndef for that, but nothing defined them.

Reviewed by:    jhibbits
Differential Revision:  https://reviews.freebsd.org/D62276
DeltaFile
+11-0sys/powerpc/linux/linux.h
+11-01 files

FreeBSD/src 380912c — sys/compat/linux linux_socket.c linux_socket.h, sys/powerpc/linux linux_sysent.c linux_proto.h

linuxulator/powerpc: enable socketcall

PowerPC had no separate socket syscalls before Linux 4.3, so binaries
built for older kernels use socketcall() for everything.

Reviewed by:    jhibbits
Differential Revision:  https://reviews.freebsd.org/D62275
DeltaFile
+26-0sys/powerpc/linux/linux_systrace_args.c
+6-1sys/powerpc/linux/syscalls.master
+5-1sys/compat/linux/linux_socket.h
+6-0sys/powerpc/linux/linux_proto.h
+3-1sys/compat/linux/linux_socket.c
+1-1sys/powerpc/linux/linux_sysent.c
+47-42 files not shown
+49-58 files

FreeBSD/src 0c84e0f — sys/powerpc/linux linux_sysent.c linux_syscalls.c

linuxulator/powerpc: implement send, recv and ipc

glibc uses send(), recv() and the ipc() multiplexer on PowerPC. Without
them DNS lookups and SysV shared memory don't work.

Reviewed by:    jhibbits
Differential Revision:  https://reviews.freebsd.org/D62274
DeltaFile
+173-0sys/powerpc/linux/linux_machdep.c
+110-0sys/powerpc/linux/linux_systrace_args.c
+26-3sys/powerpc/linux/syscalls.master
+26-0sys/powerpc/linux/linux_proto.h
+3-3sys/powerpc/linux/linux_sysent.c
+3-3sys/powerpc/linux/linux_syscalls.c
+341-91 files not shown
+344-97 files

FreeBSD/src d6fd892 — sys/amd64/acpica acpi_machdep.c, sys/arm64/acpica acpi_machdep.c

acpi: acpivar.h: Include ACPICA's acpi.h, remove the latter in consumers

<dev/acpica/acpivar.h> uses types from
<contrib/dev/acpica/include/acpi.h>, so have it include it directly.

This allows removing that include, and in passing some superfluous
includes from sys/contrib/dev/acpica/include, from all source files
including <dev/acpica/acpivar.h>.

Reviewed by:    imp, jaeyoon
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D62103
DeltaFile
+7-2sys/dev/acpica/acpivar.h
+2-4sys/dev/acpica/acpi.c
+0-5sys/dev/acpica/acpi_apei.c
+1-4sys/dev/pci/pci_host_generic_acpi.c
+1-4sys/arm64/acpica/acpi_machdep.c
+1-4sys/amd64/acpica/acpi_machdep.c
+12-23156 files not shown
+14-352162 files

FreeBSD/src fa29f0c — sys/powerpc/linux linux_machdep.c linux_sysent.c

linuxulator/powerpc: move syscalls out of the 32-bit only slots

On powerpc64 select() is syscall 142, getrlimit() is 190 and umount2() is
52. We had them at 82, 76 and 22, which are 32-bit only. Linux programs
couldn't unmount anything.

mmap2 is 32-bit only as well. Use linux_mmap2() for mmap like amd64 and
arm64 do and remove our copy of it.

Reviewed by:    jhibbits
Differential Revision:  https://reviews.freebsd.org/D62273
DeltaFile
+80-122sys/powerpc/linux/linux_systrace_args.c
+25-34sys/powerpc/linux/syscalls.master
+23-33sys/powerpc/linux/linux_proto.h
+8-8sys/powerpc/linux/linux_sysent.c
+8-8sys/powerpc/linux/linux_syscalls.c
+0-10sys/powerpc/linux/linux_machdep.c
+144-2151 files not shown
+148-2207 files

FreeBSD/src 365638b — libexec/rtld-elf/powerpc64 rtld_machdep.h reloc.c

rtld: preserve the FP and vector registers in __tls_get_addr() on powerpc64

LLVM assumes that __tls_get_addr() clobbers only r0, r4-r12, LR, CTR,
CR0, CR1 and CR5-CR7 (the GETtlsADDR pseudo in PPCInstr64Bit.td), as
glibc's implementation guarantees, and keeps live values in the other
registers across the call.  Our slow path, which runs on the first
access to the TLS block of a dlopen()ed object, copies the TLS
initialization image with the generic memcpy() and memset(), which
clang vectorizes: for a 130-byte block they clobber vs0, vs1, v0, v2,
v3 and v5 on powerpc64le and v2, v4 and v5 in a POWER9 powerpc64 build.

Qt's QBindingStorage constructor zeroes vs0, calls __tls_get_addr() and
then stores vs0 into the object, so the first QObject created by a
process that dlopen()ed libQt6Core gets 0xffffffff in its binding
storage pointer and crashes on destruction; this is why devel/pyside6
cannot generate QtGui.pyi on powerpc64le.

Keep the fast path as it is and run the slow path through a trampoline
that saves and restores the volatile floating-point and vector

    [13 lines not shown]
DeltaFile
+72-0libexec/rtld-elf/powerpc64/rtld_start.S
+31-2libexec/rtld-elf/powerpc64/reloc.c
+7-0libexec/rtld-elf/powerpc64/rtld_machdep.h
+110-23 files

FreeBSD/src 5920a1c — sys/dev/usb usbdevs, sys/dev/usb/quirk usb_quirk.c

Add USB quirk for WCH-Link adapter

WCH-Link is a debug adapter from QinHeng Electronics that features a
(proprietary) debug bridge for their RISC-V MCUs, as well as a serial
gateway, implemented as a CDC device.  The CDC's call management
descriptor declares the data interface to be 1, but it is actually
interface 2. UQ_IGNORE_CDC_CM has already been implemented before to
handle this kind of firmware bug, so just add this quirk for WCH-Link.

Reported by:    Holm Tiffe

(cherry picked from commit 1660d69068a0650fcda2ce7497dfa20e33f0b58d)
DeltaFile
+1-0sys/dev/usb/usbdevs
+1-0sys/dev/usb/quirk/usb_quirk.c
+2-02 files

FreeBSD/src 9bf3482 — stand/efi/loader main.c, stand/libsa stand.h features.c

stand: Support jumping to UEFI setup

Add support to reboot to UEFI setup. This basically add indication to
OsIndications then reboot. OsIndicationsSupported is checked before
making any decision.

Reviewed by:    imp
Differential Revision: https://reviews.freebsd.org/D61996
DeltaFile
+64-0stand/efi/loader/main.c
+25-1stand/man/loader.efi.8
+19-0stand/lua/menu.lua
+1-0stand/libsa/stand.h
+1-0stand/libsa/features.c
+110-15 files

FreeBSD/src 652a8a7 — release Makefile.vm

EC2: Use stream-optimized VMDK format

Once enabled on all of the branches, this will reduce bandwidth
consumption from uploading weekly snapshot builds from ~500 GB to
~100 GB, as well as significantly speeding up the process.

MFC after:      2 months
Sponsored by:   Amazon

(cherry picked from commit 34f2f57b836d9cec02130419f5272495860d4ddf)
DeltaFile
+1-1release/Makefile.vm
+1-11 files

FreeBSD/src 47f4884 — sys/netipsec ipsec.c udpencap.c

netipsec: Do not zero the IPv6 UDP checksum after NAT-T decapsulation

When transport mode ESP arrives in UDP and the IKE daemon gave no
original addresses (NAT-OA) for the SA, the default
net.inet.ipsec.natt_cksum_policy has udp_ipsec_adjust_cksum() ignore the
checksum of the inner header: a TCP segment is marked as verified and
the checksum of a UDP datagram is set to zero.  This is option c of RFC
3948, section 3.1.2, which was written with IPv4 in mind.  UDP over IPv6
has no "no checksum" value, so udp6_input() dropped every such datagram.
With strongSwan, which installs no NAT-OA for these SAs, TCP and ICMPv6
worked over an IPv6 transport mode SA with UDP encapsulation and UDP
did not.

Mark the datagram as verified instead, as is done for TCP.  Linux does
the same for both address families.  A datagram that the sender gave a
zero checksum is still dropped.

Fixes:          80044c785cb0 ("Add UDP encapsulation of ESP in IPv6")
MFC after:      2 weeks
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+9-4sys/netipsec/udpencap.c
+3-2sys/netipsec/ipsec.c
+12-62 files

FreeBSD/src 3847674 — sys/powerpc/powerpc trap.c

powerpc: Avoid panicking on alignment errors

PowerPC ISA specifies that an alignment fault can occur when any load or
store accesses cache-inhibited or write-through memory.  Since
copyin/copyout don't know what type of memory they will access we can't
always trust that memory is well behaved, or that it's properly aligned.
Avoid a panic by giving the fault handler a chance to deal with it and
propagate the fault back up.
DeltaFile
+1-0sys/powerpc/powerpc/trap.c
+1-01 files