netlink: fix accessing freed memory
authorBjoern A. Zeeb <bz@FreeBSD.org>
Sat, 30 Sep 2023 15:11:57 +0000 (15:11 +0000)
committerBjoern A. Zeeb <bz@FreeBSD.org>
Thu, 5 Oct 2023 14:27:10 +0000 (14:27 +0000)
commit7d48224073ce14f0dd3db2d4e96876ac928b52f2
treee6576978ce498f6eaff340c64eac1f735934b532
parent8b622172ba44f914092c1d44cecb2b101eb8e17b
netlink: fix accessing freed memory

The check for if_addrlen in dump_iface() is not sufficient to determine
if we still have a valid if_addr.  Rather than directly accessing if_addr
check the STAILQ (for the first entry).
This avoids panics when destroying cloned interfaces as experienced with
net80211 wlan ones.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: jhibbits (earlier version), kp
Differential Revision: https://reviews.freebsd.org/D42027
sys/netlink/route/iface.c