From 8dedfb5063991b4ed4272f3cb7f3850779cbcafd Mon Sep 17 00:00:00 2001 From: mvs Date: Thu, 4 Jan 2024 01:32:06 +0000 Subject: [PATCH] Revert previous. splx(9) can call kvp_get_ip_info() from any place with netlock held and cause recursive lock acquisition issue. --- sys/dev/pv/hypervic.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sys/dev/pv/hypervic.c b/sys/dev/pv/hypervic.c index e74ef507a2f..b3ce2d91bea 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, af; + int i, j, lo, hi, s, af; /* Convert from the UTF-16LE string format to binary */ for (i = 0, j = 0; j < ETHER_ADDR_LEN; i += 6) { @@ -870,14 +870,16 @@ kvp_get_ip_info(struct hv_kvp *kvp, const uint8_t *mac, uint8_t *family, return (-1); } - NET_LOCK_SHARED(); + KERNEL_LOCK(); + s = splnet(); TAILQ_FOREACH(ifp, &ifnetlist, if_list) { if (!memcmp(LLADDR(ifp->if_sadl), enaddr, ETHER_ADDR_LEN)) break; } if (ifp == NULL) { - NET_UNLOCK_SHARED(); + splx(s); + KERNEL_UNLOCK(); return (-1); } @@ -917,7 +919,8 @@ kvp_get_ip_info(struct hv_kvp *kvp, const uint8_t *mac, uint8_t *family, else if (ifa6ll != NULL) ifa = ifa6ll; else { - NET_UNLOCK_SHARED(); + splx(s); + KERNEL_UNLOCK(); return (-1); } } @@ -953,7 +956,8 @@ kvp_get_ip_info(struct hv_kvp *kvp, const uint8_t *mac, uint8_t *family, break; } - NET_UNLOCK_SHARED(); + splx(s); + KERNEL_UNLOCK(); return (0); } -- 2.20.1