FreeBSD/src 1f581d4 — sys/netinet ip_carp.c

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]
DeltaFile
+3-1sys/netinet/ip_carp.c
+3-11 files

FreeBSD/src 4dcabb0 — sys/netipsec ipsec_output.c, tests/sys/netipsec/tunnel Makefile pmtu.sh

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]
DeltaFile
+43-0tests/sys/netipsec/tunnel/pmtu.sh
+12-5sys/netipsec/ipsec_output.c
+1-0tests/sys/netipsec/tunnel/Makefile
+56-53 files

FreeBSD/src 6a839b4 — sys/netipsec ipsec_output.c, tests/sys/netipsec/tunnel bundle.sh

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]
DeltaFile
+293-15tests/sys/netipsec/tunnel/bundle.sh
+62-26sys/netipsec/ipsec_output.c
+355-412 files

FreeBSD/src 4f76f14 — contrib/llvm-project/clang/include/clang/Sema Sema.h, contrib/llvm-project/clang/lib/Sema SemaDecl.cpp SemaDeclAttr.cpp

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
DeltaFile
+29-6contrib/llvm-project/clang/lib/Sema/SemaDeclAttr.cpp
+13-0contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp
+3-0contrib/llvm-project/clang/include/clang/Sema/Sema.h
+45-63 files

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

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
DeltaFile
+2-1sys/powerpc/powerpc/trap.c
+2-11 files

FreeBSD/src 812dcfa — sys/powerpc/linux linux_proto.h syscalls.master

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
DeltaFile
+3-3sys/powerpc/linux/linux_systrace_args.c
+2-2sys/powerpc/linux/syscalls.master
+3-1sys/powerpc/linux/linux_machdep.c
+1-1sys/powerpc/linux/linux_proto.h
+9-74 files

FreeBSD/src 3e7ecbf — sys/powerpc/linux linux_sigframe.h linux_sysvec.c

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
DeltaFile
+111-105sys/powerpc/linux/linux_sysvec.c
+0-8sys/powerpc/linux/linux_sigframe.h
+111-1132 files

FreeBSD/src e23a5c1 — sys/powerpc/linux linux.h

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
DeltaFile
+8-8sys/powerpc/linux/linux.h
+8-81 files

FreeBSD/src ebb8c70 — sys/powerpc/linux linux_sysvec.c

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
DeltaFile
+6-1sys/powerpc/linux/linux_sysvec.c
+6-11 files

FreeBSD/src 01326b1 — sys/dev/usb/controller/dwc3 dwc3.c

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
DeltaFile
+14-4sys/dev/usb/controller/dwc3/dwc3.c
+14-41 files

FreeBSD/src 69511e1 — sys/dev/usb/controller/dwc3 dwc3.h dwc3.c

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
DeltaFile
+7-3sys/dev/usb/controller/dwc3/dwc3.c
+1-0sys/dev/usb/controller/dwc3/dwc3.h
+8-32 files

FreeBSD/src c858f92 — sys/powerpc/powerpc exec_machdep.c

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
DeltaFile
+4-1sys/powerpc/powerpc/exec_machdep.c
+4-11 files

FreeBSD/src 1695b29 — share/misc committers-ports.dot, usr.bin/calendar/calendars calendar.freebsd

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
DeltaFile
+5-0share/misc/committers-ports.dot
+1-0usr.bin/calendar/calendars/calendar.freebsd
+6-02 files

FreeBSD/src bbafd1a — sys/netpfil/ipfilter/netinet ip_fil_freebsd.c

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
DeltaFile
+1-0sys/netpfil/ipfilter/netinet/ip_fil_freebsd.c
+1-01 files

FreeBSD/src ff3877b — contrib/llvm-project/libunwind/include libunwind.h, contrib/llvm-project/libunwind/src UnwindRegistersRestore.S assembly.h

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
DeltaFile
+87-7contrib/llvm-project/libunwind/src/Registers.hpp
+52-0contrib/llvm-project/libunwind/src/libunwind.cpp
+45-0contrib/llvm-project/libunwind/src/UnwindRegistersSave.S
+9-0contrib/llvm-project/libunwind/src/assembly.h
+9-0contrib/llvm-project/libunwind/include/libunwind.h
+4-1contrib/llvm-project/libunwind/src/UnwindRegistersRestore.S
+206-82 files not shown
+209-118 files

FreeBSD/src 2c0d153 — contrib/llvm-project/libunwind/src assembly.h UnwindCursor.hpp

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]
DeltaFile
+7-92contrib/llvm-project/libunwind/src/Registers.hpp
+7-62contrib/llvm-project/libunwind/src/UnwindRegistersRestore.S
+5-57contrib/llvm-project/libunwind/src/UnwindRegistersSave.S
+0-52contrib/llvm-project/libunwind/src/libunwind.cpp
+0-27contrib/llvm-project/libunwind/src/UnwindCursor.hpp
+0-18contrib/llvm-project/libunwind/src/assembly.h
+19-3083 files not shown
+22-3209 files

FreeBSD/src 704c302 — contrib/atf NEWS COPYING, contrib/atf/atf-c macros.h macros_test.c

contrib/atf: update to 0.27.0

This release contains the upstreamed version of the wchar_t macros,
provided by des@ in https://reviews.freebsd.org/D61616.

MFC after:      1 week
Merge commit '9e2097a19a9dad81dcd8e7074283b8126464f310'
DeltaFile
+816-0contrib/atf/atf-sh/libatf-sh/common.subr
+189-8contrib/atf/atf-c/macros_test.c
+28-22contrib/atf/COPYING
+36-0contrib/atf/atf-c/macros.h
+33-0contrib/atf/NEWS
+24-0contrib/atf/atf-sh/libatf-sh/FreeBSD.subr
+1,126-308 files not shown
+1,185-5414 files

FreeBSD/src 6b2f09d — contrib/lutok FREEBSD-Xlist FREEBSD-upgrade.md

contrib/lutok: document suggested component upgrade process

This is similar to documentation added for contrib/atf in 91fcc2d8b18c.

MFC after:      1 week
DeltaFile
+93-0contrib/lutok/FREEBSD-upgrade.md
+12-0contrib/lutok/FREEBSD-Xlist
+105-02 files

FreeBSD/src f3d3ae5 — sys/kern kern_exit.c

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
DeltaFile
+3-3sys/kern/kern_exit.c
+3-31 files

FreeBSD/src 4b7dbdb — contrib/lutok config.h, lib/liblutok Makefile

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")
DeltaFile
+3-3contrib/lutok/config.h
+3-2lib/liblutok/tests/Makefile
+1-1usr.bin/kyua/Makefile
+1-1lib/liblutok/Makefile
+8-74 files

FreeBSD/src 5e4c320 — contrib/lutok/api-docs/html a00044.html a00065.html

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'
DeltaFile
+0-1,693contrib/lutok/api-docs/html/a00923.html
+1,163-0contrib/lutok/api-docs/html/navtree.js
+0-532contrib/lutok/api-docs/html/a00895.html
+403-0contrib/lutok/api-docs/html/a00043.html
+0-395contrib/lutok/api-docs/html/a00065.html
+388-0contrib/lutok/api-docs/html/a00044.html
+1,954-2,620165 files not shown
+5,781-9,635171 files

FreeBSD/src dc8b0ba — etc/mtree BSD.tests.dist, lib/liblutok Makefile

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
DeltaFile
+37-0lib/liblutok/tests/Makefile
+5-0lib/liblutok/Makefile
+2-0etc/mtree/BSD.tests.dist
+44-03 files

FreeBSD/src 4cd407f — sys/net iflib.c

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
DeltaFile
+6-3sys/net/iflib.c
+6-31 files

FreeBSD/src e983e6d — sys/net iflib.c

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
DeltaFile
+6-2sys/net/iflib.c
+6-21 files

FreeBSD/src dac7d81 — admin config.guess config.sub, api-docs/html a00043.html a00895.html

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]
DeltaFile
+1,490-927admin/config.sub
+0-1,693api-docs/html/a00923.html
+947-604admin/config.guess
+1,163-0api-docs/html/navtree.js
+0-532api-docs/html/a00895.html
+403-0api-docs/html/a00043.html
+4,003-3,756179 files not shown
+8,728-11,558185 files

FreeBSD/src 9e2097a — . configure Makefile.in, admin config.guess config.sub

atf: import atf-0.27.0

This change adds atf atf-0.27.0 from upstream [1].

The atf-0.27.0 artifact was been verified by SHA256 checksum [2].

This is a minor bugfix release with the added feature for wchar_t equality
testing with atf-c(3) and `atf-check` negate support.  Both items were
contributed by des@.

More information about the release (from a high level) can be found in
the release notes [3].

Updated with [4] like: `update_atf.sh 0.27.0 atf-0.27.0`.

[1]: https://github.com/freebsd/atf/releases/download/atf-0.27.0/atf-0.27.0.tar.gz
[2]: https://github.com/freebsd/atf/releases/download/atf-0.27.0/atf-0.27.0.tar.gz.sha256
[3]: https://github.com/freebsd/atf/blob/atf-0.27.0/NEWS.md
[4]: https://codeberg.org/ngie/freebsd-powertools:shell/update_atf.sh@92e09e5b
DeltaFile
+1,490-927admin/config.sub
+947-604admin/config.guess
+816-0atf-sh/libatf-sh/common.subr
+386-333Makefile.in
+189-8atf-c/macros_test.c
+92-42configure
+3,920-1,91423 files not shown
+4,229-1,99429 files

FreeBSD/src 382da2d — sys/compat/linuxkpi/common/src linux_80211.h linux_80211.c

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
DeltaFile
+7-0sys/compat/linuxkpi/common/src/linux_80211.c
+1-0sys/compat/linuxkpi/common/src/linux_80211.h
+8-02 files

FreeBSD/src 8802a76 — sys/netpfil/ipfw ip_fw2.c

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]
DeltaFile
+7-3sys/netpfil/ipfw/ip_fw2.c
+7-31 files

FreeBSD/src cfe07ee — sys/netpfil/ipfw ip_fw_nat.c, sys/netpfil/ipfw/nat64 ip_fw_nat64.c

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]
DeltaFile
+6-2sys/netpfil/ipfw/ip_fw_nat.c
+3-2sys/netpfil/ipfw/nptv6/ip_fw_nptv6.c
+3-2sys/netpfil/ipfw/nat64/ip_fw_nat64.c
+12-63 files

FreeBSD/src 878fab6 — sys/netpfil/ipfw ip_fw2.c

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
DeltaFile
+3-2sys/netpfil/ipfw/ip_fw2.c
+3-21 files