Date: Sat, 27 Oct 2018 04:45:42 +0000 From: Phabricator <phabric-noreply@FreeBSD.org> To: freebsd-net@freebsd.org Subject: [Differential] D12457: Complete INADDR_HASH lock protection Message-ID: <4f51479c7a4f05dd4f7efdbe9f1db544@localhost.localdomain> In-Reply-To: <differential-rev-PHID-DREV-em3ftishzefmzreicm43-req@FreeBSD.org> References: <differential-rev-PHID-DREV-em3ftishzefmzreicm43-req@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rS339806: Prevent stf(4) from panicing due to unprotected access to INADDR_HASH. (authored by eugen, committed by ). CHANGED PRIOR TO COMMIT https://reviews.freebsd.org/D12457?vs=33312&id=49678#toc REPOSITORY rS FreeBSD src repository CHANGES SINCE LAST UPDATE https://reviews.freebsd.org/D12457?vs=33312&id=49678 CHANGES SINCE LAST ACTION https://reviews.freebsd.org/D12457/new/ REVISION DETAIL https://reviews.freebsd.org/D12457 AFFECTED FILES head/sys/net/if_stf.c CHANGE DETAILS diff --git a/head/sys/net/if_stf.c b/head/sys/net/if_stf.c --- a/head/sys/net/if_stf.c +++ b/head/sys/net/if_stf.c @@ -367,6 +367,7 @@ static int stf_getsrcifa6(struct ifnet *ifp, struct in6_addr *addr, struct in6_addr *mask) { + struct rm_priotracker in_ifa_tracker; struct ifaddr *ia; struct in_ifaddr *ia4; struct in6_ifaddr *ia6; @@ -382,9 +383,11 @@ continue; bcopy(GET_V4(&sin6->sin6_addr), &in, sizeof(in)); + IN_IFADDR_RLOCK(&in_ifa_tracker); LIST_FOREACH(ia4, INADDR_HASH(in.s_addr), ia_hash) if (ia4->ia_addr.sin_addr.s_addr == in.s_addr) break; + IN_IFADDR_RUNLOCK(&in_ifa_tracker); if (ia4 == NULL) continue; EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: eugen_grosbein.net, ae, avg, mav, rwatson Cc: bz, imp, freebsd-net-list [-- Attachment #2 --] diff --git a/head/sys/net/if_stf.c b/head/sys/net/if_stf.c --- a/head/sys/net/if_stf.c +++ b/head/sys/net/if_stf.c @@ -367,6 +367,7 @@ static int stf_getsrcifa6(struct ifnet *ifp, struct in6_addr *addr, struct in6_addr *mask) { + struct rm_priotracker in_ifa_tracker; struct ifaddr *ia; struct in_ifaddr *ia4; struct in6_ifaddr *ia6; @@ -382,9 +383,11 @@ continue; bcopy(GET_V4(&sin6->sin6_addr), &in, sizeof(in)); + IN_IFADDR_RLOCK(&in_ifa_tracker); LIST_FOREACH(ia4, INADDR_HASH(in.s_addr), ia_hash) if (ia4->ia_addr.sin_addr.s_addr == in.s_addr) break; + IN_IFADDR_RUNLOCK(&in_ifa_tracker); if (ia4 == NULL) continue;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4f51479c7a4f05dd4f7efdbe9f1db544>
