>Synopsis: pairioctl() SIOCSIFPAIR uses the named peer's softc as a
struct pair_softc before checking that the peer is a pair(4)
interface, and calls pair_link_state() on it even when the
ioctl fails. "ifconfig pairN patch loN" dereferences lo(4)'s
NULL softc and panics; "patch vetherN" fails but sets vetherN's
link state down, taking its connected routes down.
>Category: kernel
>Severity: serious
>Priority: medium
>Class: sw-bug
>Release: OpenBSD 8.0-current (source as of 2026-11-03)
>Environment:
System : OpenBSD 8.0-current
Details : OpenBSD 8.0-current (GENERIC.MP)
Architecture: OpenBSD.amd64
Machine : amd64 (QEMU/KVM guest, 2 vcpu)
Source : sys/net/if_pair.c rev 1.18, openbsd/src as of
2026-11-03, git d5b06e73
>Description:
The SIOCSIFPAIR case of pairioctl() (sys/net/if_pair.c) looks up
the requested peer by index and reads its softc as a pair softc
first, and only afterwards checks that the peer is a pair(4):
newifp = if_get(ifr->ifr_index);
if (newifp != NULL) {
pairedsc = newifp->if_softc;
if (pairedsc->sc_pairedif != 0) { /* any interface */
error = EBUSY;
break;
}
/* Only allow pair(4) interfaces for the pair */
if ((ifc = if_clone_lookup(newifp->if_xname,
...
error = ENODEV;
break;
}
On both error paths newifp is still set, so the end of
pairioctl() runs pair_link_state() on the foreign interface,
which again reads newifp->if_softc as a pair softc and sets
that interface's link state:
if (newifp != NULL) {
pair_link_state(newifp);
if_put(newifp);
}
Consequences, depending on the interface named:
- lo(4) has no softc (if_loop.c sets ifp->if_softc = NULL), so
"ifconfig pairN patch loN" reads sc_pairedif through a NULL
pointer and the kernel panics (cr2 0x598 on amd64). The ioctl
runs under NET_LOCK, so with ddb.panic=0 the reboot then
deadlocks in if_downall() ("netlock rwlock ... enter write
deadlock") and the machine hangs until it is reset.
- For other interfaces, e.g. vether(4), sc_pairedif lies past
the end of the (smaller) softc, so the ioctl returns ENODEV
or, depending on that memory, EBUSY. In both cases
pair_link_state() then finds no paired interface and sets the
foreign interface's link state to DOWN: its connected and
broadcast routes lose RTF_UP and it stops passing traffic,
although the command failed.
A mistyped interface name in a pair(4) configuration is enough;
the loopback of any rdomain (loN) is always present.
uvm_fault(0xfffff101553b32f8, 0x598, 0, 1) -> e
fatal page fault in supervisor mode
trap type 6 code 0 rip ffffffff81a12fe4 cs 8 rflags 10286 cr2 598
panic: trap type 6, code=0, pc=ffffffff81a12fe4
panic() at panic+0x170
kerntrap() at kerntrap+0x15d
alltraps_kern_meltdown() at alltraps_kern_meltdown+0x7b
pairioctl() at pairioctl+0x164
ifioctl() at ifioctl+0xa4f
sys_ioctl() at sys_ioctl+0x30e
syscall() at syscall+0x60d
Xsyscall() at Xsyscall+0x128
panic: netlock rwlock 0xffffffff82b01228: enter write deadlock
rw_do_enter_write() at rw_do_enter_write+0x265
if_downall() at if_downall+0x29
boot() at boot+0xde
>How-To-Repeat:
As root (pair100, vether100 and rdomain 100 unused):
1. ifconfig pair100 create rdomain 100 up
2. ifconfig vether100 create rdomain 100
3. ifconfig vether100 inet 10.0.100.1/24 up
4. route -nT100 show -inet | grep '^10.0.100/24'
5. ifconfig pair100 patch vether100
6. route -nT100 show -inet | grep '^10.0.100/24'
7. ifconfig pair100 patch lo100
Step 4 shows the connected route with flags UCn. Step 5 fails
("SIOCSIFPAIR: Operation not supported by device", sometimes
"Device busy"), yet step 6 shows the route as Cn: vether100's
link state was set down. Step 7 panics the kernel.
>Fix:
Check that the peer is a pair(4) before touching its softc, and
drop the reference on that error path so the link-state update
at the end of pairioctl() does not run on the foreign interface.
Index: sys/net/if_pair.c
===================================================================
--- sys/net/if_pair.c
+++ sys/net/if_pair.c
@@ -231,18 +231,19 @@ pairioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
newifp = if_get(ifr->ifr_index);
if (newifp != NULL) {
- pairedsc = newifp->if_softc;
-
- if (pairedsc->sc_pairedif != 0) {
- error = EBUSY;
- break;
- }
-
/* Only allow pair(4) interfaces for the pair */
if ((ifc = if_clone_lookup(newifp->if_xname,
&unit)) == NULL || strcmp("pair",
ifc->ifc_name) != 0) {
+ if_put(newifp);
+ newifp = NULL;
error = ENODEV;
+ break;
+ }
+
+ pairedsc = newifp->if_softc;
+ if (pairedsc->sc_pairedif != 0) {
+ error = EBUSY;
break;
}
>Verification:
Diff applied as shown with patch -p0 to sys/net/if_pair.c r1.18
(openbsd/src as of 2026-11-03, git d5b06e73), no fuzz or offset;
kernel GENERIC.MP, amd64, built without warnings. Unpatched =
the same tree without the diff, same config. How-To-Repeat run
three times on each kernel, from a fresh boot each time:
unpatched: 3/3 panic in pairioctl() at step 7 (cr2 0x598), the
machine hung in the reboot path and was reset; in all
three runs step 5 failed (2x ENODEV, 1x EBUSY) and
step 6 showed 10.0.100/24 without RTF_UP.
patched: 3/3 steps 5 and 7 both fail with "Operation not
supported by device", the route keeps UCn, no panic.
Normal use, 4 runs on the patched kernel and 2 on the unpatched
one (the ping checks only in the last run on each; same results
apart from the bug): two pair(4) interfaces in
rdomains 101 and 102 are patched, both show "patch:" and link
active, ping passes between the rdomains; a third pair is refused
with EBUSY, self-patch with EINVAL, re-patching the same peer is
a no-op, "-patch" on either side unlinks both and stops traffic,
patching from the other side works, destroying one side unlinks
the other, a nonexistent peer name is refused.