svn commit: r340267 - stable/12/sys/netinet
Glen Barber
gjb at FreeBSD.org
Thu Nov 8 21:58:24 UTC 2018
Author: gjb
Date: Thu Nov 8 21:58:23 2018
New Revision: 340267
URL: https://svnweb.freebsd.org/changeset/base/340267
Log:
MFC r340260 (emaste):
Avoid buffer underwrite in icmp_error
icmp_error allocates either an mbuf (with pkthdr) or a cluster depending
on the size of data to be quoted in the ICMP reply, but the calculation
failed to account for the additional padding that m_align may apply.
Include the ip header in the size passed to m_align. On 64-bit archs
this will have the net effect of moving everything 4 bytes later in the
mbuf or cluster. This will result in slightly pessimal alignment for
the ICMP data copy.
Also add an assertion that we do not move m_data before the beginning of
the mbuf or cluster.
Approved by: re (kib)
Security: CVE-2018-17156
Sponsored by: The FreeBSD Foundation
Modified:
stable/12/sys/netinet/ip_icmp.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/netinet/ip_icmp.c
==============================================================================
--- stable/12/sys/netinet/ip_icmp.c Thu Nov 8 21:56:06 2018 (r340266)
+++ stable/12/sys/netinet/ip_icmp.c Thu Nov 8 21:58:23 2018 (r340267)
@@ -313,7 +313,8 @@ stdreply: icmpelen = max(8, min(V_icmp_quotelen, ntohs
#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
@@ -355,6 +356,8 @@ stdreply: icmpelen = max(8, min(V_icmp_quotelen, ntohs
* 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;
More information about the svn-src-all
mailing list