From: mvs Date: Sat, 23 Sep 2023 13:01:12 +0000 (+0000) Subject: Use shared netlock to protect if_list and ifa_list walkthrough and ifnet X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=60c1ec169dccce9f00d0cafd69babf49eafb0733;p=openbsd Use shared netlock to protect if_list and ifa_list walkthrough and ifnet data access within kvp_get_ip_info(). ok bluhm --- 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); }