>Synopsis: nd6_rtrequest() looks up the solicited-node multicast record
of a proxy NDP entry without holding if_maddrlock; deleting
any proxy entry (ndp -d, removing the address it hangs off,
destroying the interface) panics in rw_assert_anylock()
>Category: kernel
>Severity: serious
>Class: sw-bug
>Release: OpenBSD 8.0-current (src as of 2026-11-03)
>Environment:
System : OpenBSD 8.0-current, GENERIC.MP as shipped (DIAGNOSTIC,
POOL_DEBUG); also GENERIC.MP + option WITNESS
Architecture: OpenBSD.amd64
Machine : amd64 (QEMU/KVM guest), 2 CPUs
Source : sys/netinet6/nd6.c rev 1.305, sys/netinet6/in6.c
rev 1.280, sys/kern/kern_rwlock.c rev 1.58 (line
numbers below are from these)
>Description:
A proxy NDP entry ("ndp -s addr lladdr proxy", RTF_ANNOUNCE) makes
the interface join the solicited-node multicast group of the
proxied address. nd6_rtrequest() does that for RTM_ADD with
in6_addmulti() (nd6.c:879-881), which takes ifp->if_maddrlock
itself (in6.c:1035).
For RTM_DELETE it leaves the group again (nd6.c:905-922):
KERNEL_LOCK();
in6m = in6_lookupmulti(&llsol, ifp); /* :918 */
if (in6m)
in6_delmulti(in6m);
KERNEL_UNLOCK();
in6_lookupmulti() walks ifp->if_maddrlist and starts with
rw_assert_anylock(&ifp->if_maddrlock); /* in6.c:1008 */
but nothing here holds that lock, so the assertion fires every
time (kern_rwlock.c:575):
panic: maddr rwlock 0xffff800000405860: lock not held
Starting stack trace...
panic() at panic+0x170
With WITNESS the message is
panic: lock (rwlock) maddr not locked
Starting stack trace...
panic() at panic+0x170
witness_assert() at ...
(on both kernels the trace stops there). All other callers of
in6_lookupmulti() (in6_addmulti(), in6_hasmulti(), mld6_input())
hold if_maddrlock. The panic is taken with the NET_LOCK held, so
with ddb.panic=0 the reboot hangs and the machine has to be reset.
Every way of removing a proxy entry on a multicast-capable
interface ends up in this code and panics:
- ndp -d addr
- deleting the inet6 address the entry uses as its ifa
(SIOCDIFADDR_IN6: in6_purgeaddr() -> rt_ifa_purge(),
in6.c:935)
- slaacd(8) removing such an address when its valid lifetime
runs out (the same ioctl)
- destroying the interface
Adding proxy entries works; the box goes down when one is
removed. ndp -s/-d need root.
>How-To-Repeat:
As root (vether100 must not exist yet; any rdomain works the same,
rdomain 100 just keeps the test away from the main routing table):
1. ifconfig vether100 create rdomain 100
2. ifconfig vether100 inet6 2001:db8:1::1/64 up
3. ndp -V 100 -s 2001:db8:1::5 02:00:00:00:00:05 proxy
4. ndp -V 100 -d 2001:db8:1::5
5. ifconfig vether100 destroy
On the unpatched kernel step 4 panics with "maddr rwlock ...: lock
not held" (WITNESS: "lock (rwlock) maddr not locked"). On the
patched kernel step 4 prints "2001:db8:1::5 (2001:db8:1::5)
deleted" and step 5 cleans up.
>Fix:
Hold if_maddrlock (as a reader, like in6_hasmulti()) around the
lookup. It has to be released before in6_delmulti(), which takes
it for writing. The record cannot go away in between: the
reference that in6_addmulti() took for this proxy entry at RTM_ADD
is only dropped by the in6_delmulti() call that follows, and
RTM_DELETE runs only once per entry (the rt_llinfo check under
nd6_mtx at the top of the case).
Index: sys/netinet6/nd6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/nd6.c,v
diff -u -p -r1.305 nd6.c
--- sys/netinet6/nd6.c 27 Nov 2025 21:54:28 -0000 1.305
+++ sys/netinet6/nd6.c 6 Nov 2026 03:30:00 -0000
@@ -915,7 +915,9 @@ nd6_rtrequest(struct ifnet *ifp, int req
llsol.s6_addr8[12] = 0xff;
KERNEL_LOCK();
+ rw_enter_read(&ifp->if_maddrlock);
in6m = in6_lookupmulti(&llsol, ifp);
+ rw_exit_read(&ifp->if_maddrlock);
if (in6m)
in6_delmulti(in6m);
KERNEL_UNLOCK();
>Verification:
amd64 KVM guest, 2 CPUs. Pristine -current src (2026-11-03,
nd6.c 1.305). Kernels: GENERIC.MP as shipped and GENERIC.MP +
WITNESS, each without the diff and with exactly the diff above
applied with patch -p0 to a fresh export of the same tree (it
applies without fuzz or offset; the patched tree differs from the
pristine one only in nd6.c, and in GENERIC.MP for the WITNESS
kernels; the builds have no warnings).
Each run removes one proxy NDP entry on a vether(4) or pair(4)
in its own rdomain, with a fresh boot after every panic:
unpatched GENERIC.MP
ndp -d: panic 3 of 3
delete the inet6 address: panic 1 of 1
destroy the interface: panic 1 of 1
slaacd lifetime expiry: panic 1 of 1
How-To-Repeat steps 1-5: panic 3 of 3
unpatched GENERIC.MP + WITNESS
How-To-Repeat steps 1-5: panic 1 of 1
("lock (rwlock) maddr not locked")
patched GENERIC.MP
ndp -d 3 of 3, address delete 1 of 1, destroy 1 of
1, slaacd lifetime expiry 1 of 1, How-To-Repeat 2 of
2: no panic, entry removed
patched GENERIC.MP + WITNESS
the same five cases, 1 of 1 each: no panic, no
witness or lock order messages
The slaacd case: a pair(4) with "inet6 autoconf" receiving router
advertisements (valid lifetime 20 s) from rad(8) in another
rdomain, a proxy entry in the advertised prefix (its ifa is the
autoconf address), then rad stopped. slaacd removed the address
after about 20 s and the proxy entry went with it; on the
unpatched kernel the panic came at that moment, while nothing
else was being configured.
The How-To-Repeat commands exactly as shown above panicked on the
unpatched kernel (3 of 3) and finished cleanly on the patched
kernel (2 of 2).
Normal use on the patched kernel (both builds): inet and inet6
aliases added and removed; static and published ARP entries and
static NDP entries added and deleted; a proxy entry joins its
solicited-node group (in_multi count +1 in vmstat -m), a second
proxy entry with the same group shares it, deleting the first
keeps the group, deleting the second leaves it (count back to
the start value); a proxy entry removed together with its
address and added again; an interface with a proxy entry moved to
another rdomain and back; an interface destroyed with a proxy
entry present; slaacd configuring an address from rad(8),
ping6 over it, a proxy entry in that prefix, slaacd removing the
address and the entry on lifetime expiry: 30 of 30 checks passed
on each kernel, no panic or witness message.