summaryrefslogtreecommitdiff
path: root/sys/dev/pv
diff options
context:
space:
mode:
authorVitaliy Makkoveev <mvs@cvs.openbsd.org>2023-09-23 13:01:13 +0000
committerVitaliy Makkoveev <mvs@cvs.openbsd.org>2023-09-23 13:01:13 +0000
commit9d24ff8fceb067a59218242ddfa6dcb14ac92347 (patch)
tree8c3869e59b52fd60fd07f896ed9252a26544b7df /sys/dev/pv
parent5de83624e117bbd4bd62f6d3df9b65e704aebebd (diff)
Use shared netlock to protect if_list and ifa_list walkthrough and ifnet
data access within kvp_get_ip_info(). ok bluhm
Diffstat (limited to 'sys/dev/pv')
-rw-r--r--sys/dev/pv/hypervic.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/sys/dev/pv/hypervic.c b/sys/dev/pv/hypervic.c
index b3ce2d91bea..e74ef507a2f 100644
--- a/sys/dev/pv/hypervic.c
+++ b/sys/dev/pv/hypervic.c
@@ -846,7 +846,7 @@ kvp_get_ip_info(struct hv_kvp *kvp, const uint8_t *mac, uint8_t *family,
struct sockaddr_in6 *sin6, sa6;
uint8_t enaddr[ETHER_ADDR_LEN];
uint8_t ipaddr[INET6_ADDRSTRLEN];
- int i, j, lo, hi, s, af;
+ int i, j, lo, hi, af;
/* Convert from the UTF-16LE string format to binary */
for (i = 0, j = 0; j < ETHER_ADDR_LEN; i += 6) {
@@ -870,16 +870,14 @@ kvp_get_ip_info(struct hv_kvp *kvp, const uint8_t *mac, uint8_t *family,
return (-1);
}
- KERNEL_LOCK();
- s = splnet();
+ NET_LOCK_SHARED();
TAILQ_FOREACH(ifp, &ifnetlist, if_list) {
if (!memcmp(LLADDR(ifp->if_sadl), enaddr, ETHER_ADDR_LEN))
break;
}
if (ifp == NULL) {
- splx(s);
- KERNEL_UNLOCK();
+ NET_UNLOCK_SHARED();
return (-1);
}
@@ -919,8 +917,7 @@ kvp_get_ip_info(struct hv_kvp *kvp, const uint8_t *mac, uint8_t *family,
else if (ifa6ll != NULL)
ifa = ifa6ll;
else {
- splx(s);
- KERNEL_UNLOCK();
+ NET_UNLOCK_SHARED();
return (-1);
}
}
@@ -956,8 +953,7 @@ kvp_get_ip_info(struct hv_kvp *kvp, const uint8_t *mac, uint8_t *family,
break;
}
- splx(s);
- KERNEL_UNLOCK();
+ NET_UNLOCK_SHARED();
return (0);
}