aboutsummaryrefslogtreecommitdiff
path: root/sys/net/if_stf.c
diff options
context:
space:
mode:
authorEugene Grosbein <eugen@FreeBSD.org>2018-10-27 04:45:28 +0000
committerEugene Grosbein <eugen@FreeBSD.org>2018-10-27 04:45:28 +0000
commit232485a17e38c9cb8d2cd3c0f317c607e8f13925 (patch)
tree12c2e9e1ebd0e582e7d94151011ba1ce987bead6 /sys/net/if_stf.c
parente1f1ddeb35427fc0b9fa902de514c7aa23b57d56 (diff)
downloadsrc-232485a17e38c9cb8d2cd3c0f317c607e8f13925.tar.gz
src-232485a17e38c9cb8d2cd3c0f317c607e8f13925.zip
Prevent stf(4) from panicing due to unprotected access to INADDR_HASH.
PR: 220078 MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D12457 Tested-by: Cassiano Peixoto and others
Notes
Notes: svn path=/head/; revision=339806
Diffstat (limited to 'sys/net/if_stf.c')
-rw-r--r--sys/net/if_stf.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c
index f073e20858cd..b0f1ab3cd79e 100644
--- a/sys/net/if_stf.c
+++ b/sys/net/if_stf.c
@@ -367,6 +367,7 @@ stf_encapcheck(const struct mbuf *m, int off, int proto, void *arg)
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 @@ stf_getsrcifa6(struct ifnet *ifp, struct in6_addr *addr, struct in6_addr *mask)
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;