From 77ee4c0e008f6bc2e0521ae72838e9701dded197 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Mon, 20 Apr 2009 23:23:31 +0000 Subject: [PATCH] Acquire address list lock before walking an interface's address list to identify possible jail addresses on it for IPv4 and IPv6. MFC after: 2 weeks --- sys/net/rtsock.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 6b7c29b47e74..dd19dfc94b8f 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -356,6 +356,7 @@ rtm_get_jailed(struct rt_addrinfo *info, struct ifnet *ifp, * Try to find an address on the given outgoing interface * that belongs to the jail. */ + IF_ADDR_LOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { struct sockaddr *sa; sa = ifa->ifa_addr; @@ -367,6 +368,7 @@ rtm_get_jailed(struct rt_addrinfo *info, struct ifnet *ifp, break; } } + IF_ADDR_UNLOCK(ifp); if (!found) { /* * As a last resort return the 'default' jail address. @@ -394,6 +396,7 @@ rtm_get_jailed(struct rt_addrinfo *info, struct ifnet *ifp, * Try to find an address on the given outgoing interface * that belongs to the jail. */ + IF_ADDR_LOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { struct sockaddr *sa; sa = ifa->ifa_addr; @@ -406,6 +409,7 @@ rtm_get_jailed(struct rt_addrinfo *info, struct ifnet *ifp, break; } } + IF_ADDR_UNLOCK(ifp); if (!found) { /* * As a last resort return the 'default' jail address.