>Synopsis: mpw_clone_create() sets sc_ifa.ifa_addr = sdltosa(ifp->if_sadl)
before ether_ifattach() has allocated if_sadl, so ifa_addr is
left NULL. Removing a configured MPLS label (via destroy or
-mplslabel) calls rt_ifa_del(), which dereferences ifa->ifa_addr
in rtable_clearsource() and page-faults. mpe(4)/mpip(4) set
ifa_addr after if_alloc_sadl() and are not affected.
>Category: kernel
>Severity: serious
>Priority: medium
>Class: sw-bug
>Release: OpenBSD 8.0-current (snapshot, GENERIC.MP #125, 2026-11-02)
>Environment:
System : OpenBSD 8.0
Details : OpenBSD 8.0-current (GENERIC.MP) #125: Mon Nov 2
04:56:12 CST 2026
[email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
Architecture: OpenBSD.amd64
Machine : amd64 (QEMU/KVM guest, 2 vcpu)
if_mpw.c at $OpenBSD: if_mpw.c,v 1.71 2026/02/05 03:26:00 dlg Exp $.
>Description:
mpw(4) is an Ethernet pseudo-interface: mpw_clone_create() calls
ether_ifattach(), which (via if_alloc_sadl()) allocates ifp->if_sadl.
But the embedded MPLS interface address is initialised earlier in the
same function, before ether_ifattach():
sc->sc_ifa.ifa_ifp = ifp;
sc->sc_ifa.ifa_addr = sdltosa(ifp->if_sadl); /* if_sadl == NULL here */
...
ether_fakeaddr(ifp);
...
ether_ifattach(ifp); /* if_sadl allocated now */
The softc is M_ZERO-allocated, so at the assignment ifp->if_sadl is still
NULL and sc_ifa.ifa_addr is set to NULL permanently.
mpe(4) and mpip(4) perform the identical setup but in the correct order --
if_attach(); if_alloc_sadl(); then sc_ifa.ifa_addr = sdltosa(ifp->if_sadl)
-- so their ifa_addr is valid. That is why they are unaffected.
Setting a label ("ifconfig mpwN mplslabel <n>" -> mpw_set_route() ->
rt_ifa_add()) does not fault. Removing it does. Both removal paths call
rt_ifa_del(&sc->sc_ifa, ...) (sys/net/route.c), which unconditionally does:
rtable_clearsource(rdomain, ifa->ifa_addr); /* route.c:1340 */
and rtable_clearsource() immediately dereferences the source sockaddr:
addr = rtable_getsource(rtableid, src->sa_family); /* rtable.c:422 */
With ifa_addr == NULL this is a NULL dereference. Captured in ddb on a
GENERIC.MP (DIAGNOSTIC) kernel, "ifconfig mpw100 mplslabel 100; ifconfig
mpw100 destroy":
uvm_fault(..., 0x1, 0, 1) -> e
kernel: page fault trap, code=0
Stopped at rtable_clearsource+0x22: movzbl 0x1(%rsi),%esi
rtable_clearsource(0,0) at rtable_clearsource+0x22
rt_ifa_del(...) at rt_ifa_del+0x25e
mpw_clone_destroy(...) at mpw_clone_destroy+0x73
if_clone_destroy(...) at if_clone_destroy+0x13f
ifioctl(...) at ifioctl+0x1f5
sys_ioctl(...) at sys_ioctl+0x30
syscall(...) at syscall+0x60d
Xsyscall() at Xsyscall+0x128
(%rsi is the NULL src; offset 0x1 is sockaddr.sa_family.) The
-mplslabel path (SIOCDELLABEL -> mpw_del_label() -> rt_ifa_del()) faults
the same way.
The operations are available to root via ioctl(SIOCSETLABEL /
SIOCDELLABEL / SIOCIFDESTROY); no special hardware is involved.
>How-To-Repeat:
As root, either of:
ifconfig mpw100 create
ifconfig mpw100 mplslabel 100
ifconfig mpw100 destroy # page fault, rtable_clearsource+0x22
ifconfig mpw101 create
ifconfig mpw101 mplslabel 101
ifconfig mpw101 -mplslabel # same fault via mpw_del_label()
Setting the label and leaving it in place does not crash.
>Fix:
Assign sc_ifa.ifa_addr after ether_ifattach() has allocated if_sadl,
matching mpe(4)/mpip(4).
Index: sys/net/if_mpw.c
===================================================================
--- sys/net/if_mpw.c
+++ sys/net/if_mpw.c
@@ -99,7 +99,6 @@ mpw_clone_create(struct if_clone *ifc, i
refcnt_init_trace(&sc->sc_ifa.ifa_refcnt, DT_REFCNT_IDX_IFADDR);
sc->sc_ifa.ifa_ifp = ifp;
- sc->sc_ifa.ifa_addr = sdltosa(ifp->if_sadl);
sc->sc_smpls.smpls_len = sizeof(sc->sc_smpls);
sc->sc_smpls.smpls_family = AF_MPLS;
@@ -116,6 +115,8 @@ mpw_clone_create(struct if_clone *ifc, i
sc->sc_dead = 0;
ether_ifattach(ifp);
+ /* if_sadl now exists; point the MPLS ifa at it (see mpe(4)/mpip(4)) */
+ sc->sc_ifa.ifa_addr = sdltosa(ifp->if_sadl);
ifp->if_input = mpw_input;
#if NBPFILTER > 0
>Verification:
Built GENERIC.MP from -current with the diff applied and booted it
(OpenBSD 8.0-current GENERIC.MP #2, 2026-11-04) on an isolated amd64
KVM guest. On the stock #125 kernel both How-To-Repeat sequences
page-fault at rtable_clearsource+0x22; on the patched kernel every label
operation -- set, change, -mplslabel, and destroy-with-label -- completes
cleanly with no panic:
# ifconfig mpw100 create; ifconfig mpw100 mplslabel 100; \
ifconfig mpw100 destroy (rc 0, no fault)
# ifconfig mpw101 create; ifconfig mpw101 mplslabel 101; \
ifconfig mpw101 -mplslabel; ifconfig mpw101 destroy (rc 0)
The fix is also functionally correct: with a valid ifa_addr the local
MPLS route is now installed with the interface's link-layer gateway
instead of a NULL one, e.g.
In label Out label Op Gateway Flags ... Interface
100 - POP fe:e1:ba:d3:f0:37 UTl ... mpw100