>Submitter-Id: net
>Originator: Scott Blomenkamp <[email protected]>
>Organization: (none)
>Synopsis: xnf(4) panics in xnf_encap when its Xen network backend falls
255 transmit buffers behind
>Severity: serious
>Priority: medium
>Category: kernel
>Class: sw-bug
>Release: 8.0
>Environment:
System : OpenBSD 8.0 GENERIC #82 (stock kernel, unmodified install)
Architecture: OpenBSD.amd64
Machine : amd64, Xen 4.20 HVM guest (xl toolstack, Debian dom0),
1 vCPU, network backend in a separate driver domain
>Description:
When a Xen guest's network backend stops answering transmit
requests for a moment, the guest panics:
panic: kernel diagnostic assertion "sc->sc_tx_avail > used"
failed: file "/usr/src/sys/dev/pv/if_xnf.c", line 642
__assert() at __assert+0x29
xnf_start() at xnf_start+0x18a
ifq_serialize() at ifq_serialize+0xe4
taskq_thread() at taskq_thread+0x129
xnf_start() stops only when the ring has fewer free slots than
sc_tx_frags or when sc_tx_avail is 0. xnf_encap() then asserts
sc_tx_avail > used. With sc_tx_avail == 1 and a packet needing
one buffer, the start check passes and the assertion fails (an
off-by-one). With scatter-gather (sc_tx_frags 18) the start check
can let through a packet needing up to 18 buffers when only one is
free.
sc_tx_avail is given back only as the backend answers, so any
backend that falls 255 buffers behind panics the guest: one that
is slow, paused, or hostile. In Qubes OS the backend runs in
sys-net, a VM that is assumed to be compromisable, and
`qvm-pause sys-net` alone should reproduce this.
>How-To-Repeat:
1. Run the network backend for the OpenBSD guest in a driver
domain (xl: vif = [ "backend=<netvm>" ]), so the backend can be
paused without pausing dom0.
2. In the guest: ping -f <netvm address>
3. In dom0: xl pause <netvm>
The guest panics within a few seconds: with no replies, ping -f
sends about 100 packets a second, and xnf has 256 transmit
buffers. dmesg and the ddb output (trace, show panic) are
attached.
>Fix:
None attached. Locally, stopping in xnf_start() when
sc_tx_avail < sc_tx_frags, and relaxing the assertion to >=,
made the guest stall until the backend caught up instead of
panicking. Repeated 64 MiB transfers in both directions, also at
the same time, then passed.
Disclosure: I found and analysed this with the help of an AI
assistant (Anthropic's Claude), in a lab on Xen 4.20. The panic,
trace and reproduction above are from real runs with the stock 8.0
kernel. No AI-written code is attached.
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.
Copyright (c) 1995-2026 OpenBSD. All rights reserved. https://www.OpenBSD.org
OpenBSD 8.0 (GENERIC) #82: Tue Oct 6 22:58:03 MDT 2026
[email protected]:/usr/src/sys/arch/amd64/compile/GENERIC
real mem = 1048571904 (999MB)
avail mem = 995540992 (949MB)
random: good seed from bootblocks
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xfc100000 (12 entries)
bios0: vendor Xen version "4.20.5-pre" date 11/03/2026
bios0: Xen HVM domU
acpi0 at bios0: ACPI 4.0
acpi0: sleep states S3 S4 S5
acpi0: tables DSDT FACP APIC HPET WAET SSDT SSDT
acpi0: wakeup devices
acpitimer0 at acpi0: 3579545 Hz, 32 bits
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
ioapic0 at mainbus0: apid 1 pa 0xfec00000, version 11, 48 pins, remapped
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz, 1992.13 MHz, 06-8e-0a
cpu0: cpuid 1
edx=1fcbfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT>
ecx=f7fa3203<SSE3,PCLMUL,SSSE3,FMA3,CX16,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV>
cpu0: cpuid 7.0
ebx=9c27ab<FSGSBASE,TSC_ADJUST,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,RDSEED,ADX,SMAP,CLFLUSHOPT>
edx=bc000400<MD_CLEAR,IBRS,IBPB,STIBP,L1DF,SSBD>
cpu0: cpuid d.1 eax=f<XSAVEOPT,XSAVEC,XGETBV1,XSAVES>
cpu0: cpuid 80000001 edx=2c100800<NXE,PAGE1GB,RDTSCP,LONG>
ecx=121<LAHF,ABM,3DNOWP>
cpu0: cpuid 80000007 edx=100<ITSC>
cpu0: msr 10a=c000004<RSBA,GDS_NO,RFDS_NO>
cpu0: MELTDOWN
cpu0: 32KB 64b/line 8-way D-cache, 32KB 64b/line 8-way I-cache, 256KB 64b/line
4-way L2 cache, 8MB 64b/line 16-way L3 cache
cpu0: smt 0, core 0, package 0, type P
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 100MHz
cpu at mainbus0: not configured
acpihpet0 at acpi0: 62500000 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpipci0 at acpi0 PCI0
acpicmos0 at acpi0
"PNP0F13" at acpi0 not configured
"PNP0303" at acpi0 not configured
com0 at acpi0 UAR1 addr 0x3f8/0x8 irq 4: ns16550a, 16 byte fifo
com0: console
acpicpu0 at acpi0: C1(@1 halt!)
cpu0: using VERW MDS workaround (except on vmm entry)
pvbus0 at mainbus0: Xen 4.20
xen0 at pvbus0: features 0x1d2305, 64 grant table frames, event channel 1
xbf0 at xen0 backend 0 channel 6: disk
scsibus1 at xbf0: 1 targets
sd0 at scsibus1 targ 0 lun 0: <Xen, phy xvda 51712, 0000>
sd0: 16384MB, 512 bytes/sector, 33554432 sectors
xnf0 at xen0 backend 105 channel 7: address 00:16:3e:0b:5d:83
"vkbd" at xen0: device/vkbd/0 not configured
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel 82441FX" rev 0x02
pcib0 at pci0 dev 1 function 0 "Intel 82371SB ISA" rev 0x00
pciide0 at pci0 dev 1 function 1 "Intel 82371SB IDE" rev 0x00: DMA, channel 0
wired to compatibility, channel 1 wired to compatibility
pciide0: channel 0 disabled (no drives)
pciide0: channel 1 disabled (no drives)
piixpm0 at pci0 dev 1 function 3 "Intel 82371AB Power" rev 0x03: SMBus disabled
xspd0 at pci0 dev 2 function 0 "XenSource Platform Device" rev 0x01
vga1 at pci0 dev 3 function 0 "Cirrus Logic CL-GD5446" rev 0x00
wsdisplay at vga1 not configured
isa0 at pcib0
isadma0 at isa0
fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
pckbc0 at isa0 port 0x60/5 irq 1 irq 12
pckbd0 at pckbc0 (kbd slot)
wskbd0 at pckbd0 mux 1
pms0 at pckbc0 (aux slot)
wsmouse0 at pms0 mux 0
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
xnf0: restrict all mbufs to low memory
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
scsibus3 at softraid0: 256 targets
root on sd0a (e498849ba6cf584e.a) swap on sd0b dump on sd0b
WARNING: /mnt was not properly unmounted
PING 10.201.0.1 (10.201.0.1): 56 data bytes
[ping -f progress dots, about 9,000 characters, removed]
panic: kernel diagnostic assertion "sc->sc_tx_avail > used" failed: file "/usr/
src/sys/dev/pv/if_xnf.c", line 642
Stopped at db_enter+0x14: popq %rbp
TID PID UID PRFLAGS PFLAGS CPU COMMAND
*396266 19448 0 0x14000 0x200 0 softnet0
db_enter() at db_enter+0x14
panic(ffffffff8268fe49) at panic+0xc9
__assert(ffffffff826cba6c,ffffffff82695aa2,282,ffffffff82605aa0) at __assert+0x
29
xnf_txeof(ffff800000155000) at xnf_txeof
xnf_start(ffff8000001553f0) at xnf_start+0x18a
ifq_serialize(ffff8000001553f0,ffff8000001554d8) at ifq_serialize+0xe4
taskq_thread(ffff80000002c000) at taskq_thread+0x129
end trace frame: 0x0, count: 8
https://www.openbsd.org/ddb.html describes the minimum info required in bug
reports. Insufficient info makes it difficult to find and fix bugs.
ddb> trace
db_enter() at db_enter+0x14
panic(ffffffff8268fe49) at panic+0xc9
__assert(ffffffff826cba6c,ffffffff82695aa2,282,ffffffff82605aa0) at __assert+0x
29
xnf_txeof(ffff800000155000) at xnf_txeof
xnf_start(ffff8000001553f0) at xnf_start+0x18a
ifq_serialize(ffff8000001553f0,ffff8000001554d8) at ifq_serialize+0xe4
taskq_thread(ffff80000002c000) at taskq_thread+0x129
end trace frame: 0x0, count: -7
ddb> show panic
*cpu0: kernel diagnostic assertion "sc->sc_tx_avail > used" failed: file "/usr/
src/sys/dev/pv/if_xnf.c", line 642