summaryrefslogtreecommitdiff
path: root/sys/netinet/ip_input.c
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2015-08-19 15:30:26 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2015-08-19 15:30:26 +0000
commit802513d6961ca9ab119636c166b408a59dd437d6 (patch)
tree5c6e4e3cc74afcb2a377be8a7f811da9ae97f4d5 /sys/netinet/ip_input.c
parentd81a84cb9fe1888c60aeb7aa191b9bfa6966bce4 (diff)
An interface address without interface pointer could cause an
uvm_fault in in_ouraddr(). Do not use a stale local address from the routing table. OK mpi@
Diffstat (limited to 'sys/netinet/ip_input.c')
-rw-r--r--sys/netinet/ip_input.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index c9019f38d6a..a7f0f8ff6d8 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_input.c,v 1.252 2015/07/16 21:14:21 mpi Exp $ */
+/* $OpenBSD: ip_input.c,v 1.253 2015/08/19 15:30:25 bluhm Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@@ -669,7 +669,9 @@ in_ouraddr(struct mbuf *m, struct ifnet *ifp, struct in_addr ina)
sin.sin_addr = ina;
rt = rtalloc(sintosa(&sin), 0, m->m_pkthdr.ph_rtableid);
if (rt != NULL) {
- if (rt->rt_flags & (RTF_LOCAL|RTF_BROADCAST))
+ /* only use non-stale local address, check before route free */
+ if ((rt->rt_flags & (RTF_LOCAL|RTF_BROADCAST)) &&
+ rt->rt_ifa != NULL && rt->rt_ifa->ifa_ifp != NULL)
ia = ifatoia(rt->rt_ifa);
rtfree(rt);
}