diff options
author | gordon <gordon@FreeBSD.org> | 2018-11-27 19:43:16 +0000 |
---|---|---|
committer | gordon <gordon@FreeBSD.org> | 2018-11-27 19:43:16 +0000 |
commit | bf767d041f0f530ffe95ee4870830193d344771b (patch) | |
tree | fb30b9f821fde3d05f4286e35e03cb993c40d3a2 | |
parent | e0e60f4844598ff1cb636aa9b15cfe442a411e3e (diff) | |
download | FreeBSD-src-bf767d041f0f530ffe95ee4870830193d344771b.zip FreeBSD-src-bf767d041f0f530ffe95ee4870830193d344771b.tar.gz |
Fix ICMP buffer underwrite. [EN-18:13.icmp]
Approved by: so
Security: FreeBSD-EN-18:13.icmp
Security: CVE-2018-17156
-rw-r--r-- | sys/netinet/ip_icmp.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index 56578f3..47725c7 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -310,7 +310,8 @@ stdreply: icmpelen = max(8, min(V_icmp_quotelen, ntohs(oip->ip_len) - #endif icmplen = min(icmplen, M_TRAILINGSPACE(m) - sizeof(struct ip) - ICMP_MINLEN); - m_align(m, ICMP_MINLEN + icmplen); + m_align(m, sizeof(struct ip) + ICMP_MINLEN + icmplen); + m->m_data += sizeof(struct ip); m->m_len = ICMP_MINLEN + icmplen; /* XXX MRT make the outgoing packet use the same FIB @@ -352,6 +353,8 @@ stdreply: icmpelen = max(8, min(V_icmp_quotelen, ntohs(oip->ip_len) - * reply should bypass as well. */ m->m_flags |= n->m_flags & M_SKIP_FIREWALL; + KASSERT(M_LEADINGSPACE(m) >= sizeof(struct ip), + ("insufficient space for ip header")); m->m_data -= sizeof(struct ip); m->m_len += sizeof(struct ip); m->m_pkthdr.len = m->m_len; |