summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2006-01-18 14:24:39 +0000
committerandre <andre@FreeBSD.org>2006-01-18 14:24:39 +0000
commita08da7cd98bf2aff1c327d1becbb7614c27a40b4 (patch)
tree4e69a0c80481917df0c10480c9cecc38671545fd
parent11141440e8f44bc40ad6efe297d1e4342166f159 (diff)
downloadFreeBSD-src-a08da7cd98bf2aff1c327d1becbb7614c27a40b4.zip
FreeBSD-src-a08da7cd98bf2aff1c327d1becbb7614c27a40b4.tar.gz
Return mbuf pointer or NULL from ip_fastforward() as the mbuf pointer
may have changed by m_pullup() during fastforward processing. While this is a bug it is actually never triggered in real world situations and it is not remotely exploitable. Found by: Coverity Prevent(tm) Coverity ID: CID780 Sponsored by: TCP/IP Optimization Fundraise 2005
-rw-r--r--sys/net/if_arcsubr.c4
-rw-r--r--sys/net/if_ef.c2
-rw-r--r--sys/net/if_ethersubr.c2
-rw-r--r--sys/net/if_fddisubr.c2
-rw-r--r--sys/net/if_fwsubr.c2
-rw-r--r--sys/net/if_iso88025subr.c2
-rw-r--r--sys/net/if_ppp.c2
-rw-r--r--sys/netinet/in_var.h2
-rw-r--r--sys/netinet/ip_fastfwd.c36
9 files changed, 27 insertions, 27 deletions
diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c
index 6cdb951..f3c00cd 100644
--- a/sys/net/if_arcsubr.c
+++ b/sys/net/if_arcsubr.c
@@ -559,14 +559,14 @@ arc_input(ifp, m)
#ifdef INET
case ARCTYPE_IP:
m_adj(m, ARC_HDRNEWLEN);
- if (ip_fastforward(m))
+ if ((m = ip_fastforward(m)) == NULL)
return;
isr = NETISR_IP;
break;
case ARCTYPE_IP_OLD:
m_adj(m, ARC_HDRLEN);
- if (ip_fastforward(m))
+ if ((m = ip_fastforward(m)) == NULL)
return;
isr = NETISR_IP;
break;
diff --git a/sys/net/if_ef.c b/sys/net/if_ef.c
index 04262c6..19c1687 100644
--- a/sys/net/if_ef.c
+++ b/sys/net/if_ef.c
@@ -247,7 +247,7 @@ ef_inputEII(struct mbuf *m, struct ether_header *eh, u_short ether_type)
#endif
#ifdef INET
case ETHERTYPE_IP:
- if (ip_fastforward(m))
+ if ((m = ip_fastforward(m)) == NULL)
return (0);
isr = NETISR_IP;
break;
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index d96b48bf..9a5ffc3 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -741,7 +741,7 @@ post_stats:
switch (ether_type) {
#ifdef INET
case ETHERTYPE_IP:
- if (ip_fastforward(m))
+ if ((m = ip_fastforward(m)) == NULL)
return;
isr = NETISR_IP;
break;
diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c
index d7c3e33..cc4b1fc 100644
--- a/sys/net/if_fddisubr.c
+++ b/sys/net/if_fddisubr.c
@@ -495,7 +495,7 @@ fddi_input(ifp, m)
switch (type) {
#ifdef INET
case ETHERTYPE_IP:
- if (ip_fastforward(m))
+ if ((m = ip_fastforward(m)) == NULL)
return;
isr = NETISR_IP;
break;
diff --git a/sys/net/if_fwsubr.c b/sys/net/if_fwsubr.c
index 4846b27..7cf1c22 100644
--- a/sys/net/if_fwsubr.c
+++ b/sys/net/if_fwsubr.c
@@ -601,7 +601,7 @@ firewire_input(struct ifnet *ifp, struct mbuf *m, uint16_t src)
switch (type) {
#ifdef INET
case ETHERTYPE_IP:
- if (ip_fastforward(m))
+ if ((m = ip_fastforward(m)) == NULL)
return;
isr = NETISR_IP;
break;
diff --git a/sys/net/if_iso88025subr.c b/sys/net/if_iso88025subr.c
index 5d5a3a2..14c6f98 100644
--- a/sys/net/if_iso88025subr.c
+++ b/sys/net/if_iso88025subr.c
@@ -583,7 +583,7 @@ iso88025_input(ifp, m)
#ifdef INET
case ETHERTYPE_IP:
th->iso88025_shost[0] &= ~(TR_RII);
- if (ip_fastforward(m))
+ if ((m = ip_fastforward(m)) == NULL)
return;
isr = NETISR_IP;
break;
diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c
index 7bf26f3..4d410d4 100644
--- a/sys/net/if_ppp.c
+++ b/sys/net/if_ppp.c
@@ -1570,7 +1570,7 @@ ppp_inproc(sc, m)
m->m_pkthdr.len -= PPP_HDRLEN;
m->m_data += PPP_HDRLEN;
m->m_len -= PPP_HDRLEN;
- if (ip_fastforward(m))
+ if ((m = ip_fastforward(m)) == NULL)
return;
isr = NETISR_IP;
break;
diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h
index 5792a0b..319b0dc 100644
--- a/sys/netinet/in_var.h
+++ b/sys/netinet/in_var.h
@@ -242,7 +242,7 @@ void in_rtqdrain(void);
void ip_input(struct mbuf *);
int in_ifadown(struct ifaddr *ifa, int);
void in_ifscrub(struct ifnet *, struct in_ifaddr *);
-int ip_fastforward(struct mbuf *);
+struct mbuf *ip_fastforward(struct mbuf *);
#endif /* _KERNEL */
diff --git a/sys/netinet/ip_fastfwd.c b/sys/netinet/ip_fastfwd.c
index 43419f3..6ad8e9d 100644
--- a/sys/netinet/ip_fastfwd.c
+++ b/sys/netinet/ip_fastfwd.c
@@ -151,7 +151,7 @@ ip_findroute(struct route *ro, struct in_addr dest, struct mbuf *m)
* otherwise 0 is returned and the packet should be delivered
* to ip_input for full processing.
*/
-int
+struct mbuf *
ip_fastforward(struct mbuf *m)
{
struct ip *ip;
@@ -171,7 +171,7 @@ ip_fastforward(struct mbuf *m)
* Are we active and forwarding packets?
*/
if (!ipfastforward_active || !ipforwarding)
- return 0;
+ return m;
M_ASSERTVALID(m);
M_ASSERTPKTHDR(m);
@@ -196,7 +196,7 @@ ip_fastforward(struct mbuf *m)
if (m->m_len < sizeof (struct ip) &&
(m = m_pullup(m, sizeof (struct ip))) == NULL) {
ipstat.ips_toosmall++;
- return 1; /* mbuf already free'd */
+ return NULL; /* mbuf already free'd */
}
ip = mtod(m, struct ip *);
@@ -218,9 +218,9 @@ ip_fastforward(struct mbuf *m)
goto drop;
}
if (hlen > m->m_len) {
- if ((m = m_pullup(m, hlen)) == 0) {
+ if ((m = m_pullup(m, hlen)) == NULL) {
ipstat.ips_badhlen++;
- return 1;
+ return NULL; /* mbuf already free'd */
}
ip = mtod(m, struct ip *);
}
@@ -281,7 +281,7 @@ ip_fastforward(struct mbuf *m)
* Is packet dropped by traffic conditioner?
*/
if (altq_input != NULL && (*altq_input)(m, AF_INET) == 0)
- return 1;
+ goto drop;
#endif
/*
@@ -293,11 +293,11 @@ ip_fastforward(struct mbuf *m)
*/
if (ip->ip_hl != (sizeof(struct ip) >> 2)) {
if (ip_doopts == 1)
- return 0;
+ return m;
else if (ip_doopts == 2) {
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_FILTER_PROHIB,
0, 0);
- return 1;
+ return NULL; /* mbuf already free'd */
}
/* else ignore IP options and continue */
}
@@ -320,13 +320,13 @@ ip_fastforward(struct mbuf *m)
IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) ||
ip->ip_src.s_addr == INADDR_ANY ||
ip->ip_dst.s_addr == INADDR_ANY )
- return 0;
+ return m;
/*
* Is it for a local address on this host?
*/
if (in_localip(ip->ip_dst))
- return 0;
+ return m;
ipstat.ips_total++;
@@ -350,7 +350,7 @@ ip_fastforward(struct mbuf *m)
if (pfil_run_hooks(&inet_pfil_hook, &m, m->m_pkthdr.rcvif, PFIL_IN, NULL) ||
m == NULL)
- return 1;
+ goto drop;
M_ASSERTVALID(m);
M_ASSERTPKTHDR(m);
@@ -393,7 +393,7 @@ passin:
#endif
if (ip->ip_ttl <= IPTTLDEC) {
icmp_error(m, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, 0, 0);
- return 1;
+ return NULL; /* mbuf already free'd */
}
/*
@@ -414,7 +414,7 @@ passin:
* Find route to destination.
*/
if ((dst = ip_findroute(&ro, dest, m)) == NULL)
- return 1; /* icmp unreach already sent */
+ return NULL; /* icmp unreach already sent */
ifp = ro.ro_rt->rt_ifp;
/*
@@ -434,7 +434,7 @@ passin:
goto passout;
if (pfil_run_hooks(&inet_pfil_hook, &m, ifp, PFIL_OUT, NULL) || m == NULL) {
- goto consumed;
+ goto drop;
}
M_ASSERTVALID(m);
@@ -469,7 +469,7 @@ forwardlocal:
m->m_flags |= M_FASTFWD_OURS;
if (ro.ro_rt)
RTFREE(ro.ro_rt);
- return 0;
+ return m;
}
/*
* Redo route lookup with new destination address
@@ -483,7 +483,7 @@ forwardlocal:
#endif /* IPFIREWALL_FORWARD */
RTFREE(ro.ro_rt);
if ((dst = ip_findroute(&ro, dest, m)) == NULL)
- return 1; /* icmp unreach already sent */
+ return NULL; /* icmp unreach already sent */
ifp = ro.ro_rt->rt_ifp;
}
@@ -597,11 +597,11 @@ passout:
}
consumed:
RTFREE(ro.ro_rt);
- return 1;
+ return NULL;
drop:
if (m)
m_freem(m);
if (ro.ro_rt)
RTFREE(ro.ro_rt);
- return 1;
+ return NULL;
}
OpenPOWER on IntegriCloud