carp: Leave the multicast groups without the softc lock
carp_detach() calls carp_multicast_cleanup() with the softc mutex held.
in_leavegroup() and in6_leavegroup() take in_multi_sx and in6_multi_sx,
so removing the last CARP address of a family from an interface gives:
lock order reversal: (sleepable after non-sleepable)
1st carp_softc (carp_softc, sleep mutex) @ sys/netinet/ip_carp.c:2329
2nd in_multi_sx (in_multi_sx, sx) @ sys/netinet/in_mcast.c:1280
and the same with in6_multi_sx for IPv6.
The memberships belong to the carp_if and are protected by carp_sx,
which carp_detach() holds throughout; carp_attach() already joins the
groups without the softc lock. Leave them once the softc is unlocked
or destroyed, before the carp_if may be freed. The groups of a family
are left only when no CARP address of that family remains on the
interface, and only softcs with an address of a family send
advertisements through its multicast options, so no sender uses them
[7 lines not shown]
netipsec: Do not send a Packet Too Big below the IPv6 minimum MTU
ipsec6_check_pmtu() answers a forwarded packet that does not fit once
encapsulated with an ICMPv6 Packet Too Big for the path MTU less the
estimated IPsec overhead. When the path MTU to the tunnel endpoint is
below IPV6_MMTU plus that overhead, 1417 bytes for an ESP tunnel over
IPv6, the message asks for less than IPV6_MMTU. Senders ignore it
(RFC 8201; icmp6_mtudisc_update() here does too), keep sending packets
of up to 1280 bytes, and the check drops every one of them.
Do what RFC 2473 section 7.1 asks of a tunnel entry point instead: pass
a packet of up to IPV6_MMTU bytes on, so that the outer packet is
fragmented, and report IPV6_MMTU for larger ones. This also replaces
the silent drop of every packet when the path MTU does not even cover
the overhead. With an IPv4 outer header and net.inet.ipsec.dfbit set
to 1, ip_output() still drops such a packet, as the outer header has DF
set.
Add a test with a path MTU of 1300 between the gateways.
[6 lines not shown]
netipsec: Find the outer destination of a bundle for the PMTU check
ipsec{4,6}_check_pmtu() look up the SA of the last request of a policy
to learn the outer destination, and from it the path MTU. The lookup
fills in the empty addresses of a transport request from the packet as
it is before any transform. When the transport request follows a
tunnel request, as in "esp/tunnel/A-B/require ah/transport//require",
the transform applies it after the tunnel request, to the outer header,
and its SA is installed for A and B. The check then finds no SA with
every SA in place. At level require it sends an SADB_ACQUIRE for the
inner addresses and drops the packet. strongSwan installs this shape
for IPComp in tunnel mode,
"ipcomp/tunnel/A-B/unique esp/transport//unique", so with such a policy
no forwarded IPv6 packet got through, and no IPv4 packet that the check
covers (net.inet.ipsec.dfbit 1, or above 1 for a packet with DF set).
At level use the check sends the same SADB_ACQUIRE and, since
655407eeea5b, skips the comparison with the path MTU. A packet that is
too big once encapsulated is then dropped by ip_output() if the outer
IPv4 header has DF set, or else fragmented, and its sender never learns
[28 lines not shown]
Merge commit 6573dd3f1ae9 from llvm-project (by ShengYi Hung):
[Clang][Sema] Accept weak reference after declaration (#228809)
GCC accepts a weak reference even after there is a declaration. In here,
we use Check*Decl to do the required check and merge the NewDecl to
declaration chain.
Assisted-by: Claude # Tests ReleaseNote
Fixes: #56760
PR: 205934
MFC after: 1 week
powerpc64: do not call pmap_nofault() for kernel addresses
trap_pfault() calls pmap_nofault() with the current process's pmap for
every radix page fault, before it has worked out which map the address
belongs to. For a fault on a kernel address that walks the user page
table: pmap_pml1e_index() masks off the quadrant bits, so 0xc008... is
looked up as the user address 0x0008....
Usually nothing is mapped there and vm_fault() handles the fault as
before. But if the process happens to have a mapping at that address,
its PTE gets the reference or change bit and its page is dirtied for an
access it never made. These faults are common: the first write to a
pipe buffer after the read that faulted it in is one.
Skip the call for kernel addresses. vm_fault() handles them the same
way it does now.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D62038
linuxulator/powerpc: fix the argument order of clone()
PowerPC passes tls before child_tidptr. New threads got a pointer to their
TID as thread pointer.
While here make linux_set_upcall() return 0 to the child instead of
copying r1 to r0.
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D62272
linuxulator/powerpc: fix signal delivery
Handlers were always treated as ELFv1 function descriptors and read
directly from userland. ELFv2 handlers are plain addresses and want their
own address in r12.
Also don't overwrite the red zone, honour sigaltstack(), write the back
chain and stop copying a FreeBSD ucontext that nobody reads.
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D62271
linuxulator/powerpc: fix the layout of struct stat and statfs64
st_dev and st_rdev are longs on powerpc64, but l_dev_t is 32-bit.
Everything after st_gid was off by 4 bytes and glibc read st_blksize as
the file size. statfs64 has the same problem with its word-sized fields.
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D62270
linuxulator/powerpc: return positive errno values
sc reports an error with CR0[SO] set and a positive errno in r3. We passed
the negative one like the other architectures do, so libc took every
error for a success. A failed open() became file descriptor 2.
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D62269
usb: dwc3: treat a dual-role port whose default role is host as a host port
Some device trees (such as Apple Silicon Macs) describe USB-C DWC3
controllers with dr_mode = "otg" and role-switch-default-mode = "host".
Accept that combination during probe so host mode works with unmodified
device trees instead of refusing to attach.
Differential Revision: https://reviews.freebsd.org/D62185
usb: dwc3: derive 32-bit vs 64-bit DMA from DWC3_GHWPARAMS0 AWIDTH
dwc3.c previously passed a hardcoded IS_DMA_32B (1) to xhci_init(),
which pins sc_dma_bits to 32 (and hw.usb.xhci.dma32 can only force
32-bit DMA on, never off).
On platforms with no physical memory below 4GB (such as Apple Silicon,
where DRAM starts at 0x800000000 on t8103), a 32-bit busdma tag cannot
allocate coherent memory or bounce pages and xhci_init() fails.
Read the synthesized address bus width (AWIDTH, bits [31:24]) from
DWC3_GHWPARAMS0 and enable 64-bit DMA only when AWIDTH == 64 on a
64-bit host, leaving 32-bit synthesized DWC3 cores on 32-bit DMA.
xhci_init() still checks XHCI_HCS0_AC64 and hw.usb.xhci.dma32.
Differetial Revision: https://reviews.freebsd.org/D62184
powerpc: zero the FPU save area in set_fpregs() when it was not valid
set_fpregs() marks the saved FPU registers valid and fills in the FP
registers and the FPSCR, which are only half of each of VSR0-31. The
other halves are left alone, and on a thread that hasn't used the FPU
since exec they still hold whatever the previous program left there:
exec only resets pcb_flags, and enable_fpu() zeroes the save area only
when PCB_FPREGS is clear.
So a PT_SETFPREGS on such a thread, even one that just writes back what
PT_GETFPREGS returned, hands the new program VSX register contents of
the program that ran before the exec.
Zero the save area first when it wasn't valid, like enable_fpu() does.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D62037
committers-ports: Add mzar and update committer information
Add mzar@ to the ports committers list with philip@,
farrokhi@, and olivier@ as mentors.
Update the Mentor and Mentee Information according
to step 5 of the Committer's Guide.
Update the calendar according to step 10 of the
Committer's Guide.
Approved by: philip, farrokhi, olivier (mentors)
Differential Revision: https://reviews.freebsd.org/D62146
ipfilter: Clear the IP header pointer if m_pullup() fails
Otherwise fin->fin_ip is left pointing into freed memory, and
ipf_pr_ipv4hdr() may end up accessing it. In particular,
ipf_pr_ipv4hdr() checks fin->fin_ip == NULL to decide whether to
short-circuit, in contrast with ipf_pr_ipv6hdr(), which bails if
fin->fin_m == NULL.
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D62172
Merge commit 29474e1a3a72 from llvm-project (by Minsoo Choo):
[libunwind] Support extended amd64 segment registers on FreeBSD (#237265)
Raise the amd64 DWARF register limit to 59 and add RFLAGS, all six
segment selectors, FS.base, and GS.base to the register model. Capture
the extended state and restore it when resuming, using setcontext on
FreeBSD to restore selectors and bases together. Pack the state into the
existing context buffers without changing their public sizes or the
Windows XMM offsets.
Add tests for register access, signal-frame CFI recovery, register
bounds, and resume behavior.
Assisted-by: GPT
MFC after: 1 week
Revert "Merge commit fd4113508a64 from llvm-project (by Minsoo Choo):"
This reverts commit 28ec7cb8712fde61107126c8ff174578d0ccdf79:
[libunwind] Support extended amd64 segment registers (#229176)
Raise the amd64 DWARF register limit to 59 and add RFLAGS, all six
segment selectors, FS.base, and GS.base to the register model. Capture
the extended state and restore it when resuming, using sigreturn() on
FreeBSD to restore selectors and bases together. Pack the state into the
existing context buffers without changing their public sizes or the
Windows XMM offsets.
Add tests for register access, signal-frame CFI recovery, register
bounds, and resume behavior.
Assisted-by: GPT
It was reverted upstream, after noting that it should apply specifically
[3 lines not shown]
kern/kern_exit.c: fix decision to give back to real parent in proc_reap()
p_oppid records the reaper by pid only, and nothing updates p_oppid when
the reaper changes. When p_oppid no longer matches, proc_realparent()
falls back to p_reaper. In proc_reap(), the test p_oppid !=
p_pptr->p_pid is then still true, so proc_reap() "gives back" the child
to proc_realparent(). That resolves to the new reaper, which is already
p_pptr. proc_reparent() returns early, the reaper gets a spurious
SIGCHLD, and proc_reap() returns without reaping.
Another problem with p_oppid check is that a parked zombie is leaked
permanently under the new reaper if the reaper changes before the
debugger waits, because p_oppid keeps the old reaper's pid.
In proc_reap(), base the give-back decision on the resolved parent
instead of the pid comparison.
Reported by: llm-postcr
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
contrib/lutok: update generated headers/build glue
lutok and kyua have both been updated for the new tests and the adjusted
header layout.
MFC after: 1 week
MFC with: 5e4c3200cdc7 ("contrib/lutok: update to 0.7.1")
contrib/lutok: update to 0.7.1
This is a bugfix release. Users are encouraged to take this version.
MFC after: 1 week
Merge commit 'dac7d818e3cef52d724592c6b349dbd8ad9a049a'
contrib/lutok: compile/run tests from the project
This change adds the necessary glue to build and run the tests
distributed with each release, sans the examples tests. liblutok is
an "internal" library, so the headers and library aren't distributed
with installworld, et al, and thus the examples tests--which require the
headers/library to build tests on the fly--fail when the tests are run,
due to this difference with the upstream project.
MFC after: 1 week
iflib: remove the legacy interrupt before freeing the queues
iflib_device_deregister() and the iflib_device_register() failure path
freed the queue structures and ran IFDI_DETACH before tearing down an
INTx or MSI handler. A shared INTx line can run the driver filter and
iflib_fast_intr_rxtx() at any time, so another device's interrupt in
that window used freed queues and driver state. Tear the handler down
before anything is freed.
Reported by: llm-postcr
Reviewed by: gallatin
Differential Revision: https://reviews.freebsd.org/D62040
iflib: clear an interrupt after freeing it
em(4) and several other drivers free their MSI-X vectors when
IFDI_MSIX_INTR_ASSIGN fails, then free them again from IFDI_DETACH,
which iflib's attach failure path runs next. The second
iflib_irq_free() tears down a stale tag and releases a stale resource.
Clear both so it is a no-op.
Reviewed by: gallatin
Differential Revision: https://reviews.freebsd.org/D62039
lutok: import lutok-0.7.1
This change adds lutok lutok-0.7.1 from upstream [1].
The lutok-0.7.1 artifact was been verified by SHA256 checksum [2].
This is a bugfix release.
The core issues addressed in this release relate to memory handling in edge
cases and a handful of build-related bugfixes found when enabling ASAN in CI.
A huge shoutout goes to @holmuk for the findings and fixes made in the library.
Users are encouraged to upgrade to this release.
More information about the release (from a high level) can be found in
the release notes [3].
Updated with [4] like: `update_lutok.sh 0.7.1 lutok-0.7.1`.
[5 lines not shown]
linuxkpi: set M_AMPDU for NICs that require host reordering
Set the M_AMPDU flag on RX packets for NICs that require host
reordering.
The reporter (Denis) sees a traffic increase from ~ 100Mbit/sec
to ~365Mbit/sec and a decrease in dropped frames due to RX
sequence / RX CCMP PN reordering.
PR: 300862
Obtained from: Denis Lemire <denis at lemire.name>
MFC after: 1 month
ipfw: Destroy global state after the vnets on unload
A module's MOD_UNLOAD handler runs before any of its SYSUNINITs. Since
ipfw_destroy() moved into MOD_UNLOAD, vnet_ipfw_uninit() runs after it
and takes locks that ipfw_destroy() has already destroyed: the sockopt
handler lock, and vnet_mtx in a vnet that tracks interfaces. kldunload
ipfw panics with INVARIANTS:
panic: mtx_lock() of destroyed mutex @ sys/netpfil/ipfw/ip_fw_sockopt.c:3038
ipfw_del_sopt_handler() <- ipfw_destroy_tables() <- vnet_ipfw_uninit()
<- vnet_deregister_sysuninit() <- linker_file_sysuninit()
<- linker_file_unload()
Call ipfw_destroy() from a SYSUNINIT at SI_ORDER_FIRST instead, which
runs after the SI_ORDER_SECOND vnet teardown, as before 9bcc1e97dda8
and as pf does for pf_unload().
Reviewed by: glebius
Fixes: 9bcc1e97dda8 ("ipfw: cleanup SYSINIT(9)s")
[2 lines not shown]
ipfw: Run the vnet hooks of ipfw_nat, nat64 and nptv6 after ipfw's
9bcc1e97dda8 put the SYSINITs of ipfw_nat, ipfw_nat64 and ipfw_nptv6
at SI_ORDER_SECOND, the order of ipfw's own vnet hooks; before, they
ran after them.
In ipfw_nat, the module-wide hooks and the vnet hooks now share that
order too, which leaves their relative order to the sort. As built,
kldunload ipfw_nat runs ipfw_nat_destroy() first: it clears
ipfw_nat_ptr and lookup_nat_ptr while every vnet still has
V_ipfw_nat_ready set, and a packet that hits a nat rule in between
calls a NULL pointer:
(null)() at 0 <- ipfw_check_packet <- pfil_mbuf_in <- ip_input
Loading can open the same window the other way around.
The vnet hooks of all three modules also tie with ipfw's, and run after
them on vnet creation and before them on destruction only because ipfw
[10 lines not shown]
ipfw: Drain the state expiry task before taking the upper half lock
vnet_ipfw_uninit() takes the upper half lock and then drains the task
that expires dynamic states. Since 331333ba0186 that task, dyn_tick(),
takes the same lock, so when it fires while a vnet is being destroyed
the two wait for each other and jail -r hangs:
jail: taskqueue_drain_timeout <- vnet_ipfw_uninit <- vnet_destroy
swi6: _sx_xlock <- dyn_tick <- taskqueue_run_locked
Drain the task first. The pfil hooks and the sockopt handler are
detached by then, and dyn_tick() takes the lock itself.
Reviewed by: glebius
Fixes: 331333ba0186 ("ipfw: hold sleepable "upper half...")
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D62245