Date: Wed, 7 Mar 2018 05:47:48 +0000 (UTC) From: Gordon Tetlow <gordon@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r330565 - stable/10/sys/netipsec Message-ID: <201803070547.w275lm2e083354@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gordon Date: Wed Mar 7 05:47:48 2018 New Revision: 330565 URL: https://svnweb.freebsd.org/changeset/base/330565 Log: Port r329561 to stable/10. There were structural changes preventing MFC. Check packet length to not make an out of bounds access. Also, save ah_nxt value to use later, since the ah pointer can become invalid. Reviewed by: ae@ Approved by: so Security: CVE-2018-6916 Security: FreeBSD-SA-18:01.ipsec Modified: stable/10/sys/netipsec/xform_ah.c Modified: stable/10/sys/netipsec/xform_ah.c ============================================================================== --- stable/10/sys/netipsec/xform_ah.c Wed Mar 7 04:11:14 2018 (r330564) +++ stable/10/sys/netipsec/xform_ah.c Wed Mar 7 05:47:48 2018 (r330565) @@ -599,6 +599,16 @@ ah_input(struct mbuf *m, struct secasvar *sav, int ski m_freem(m); return EACCES; } + if (skip + authsize + rplen > m->m_pkthdr.len) { + DPRINTF(("%s: bad mbuf length %u (expecting %lu)" + " for packet in SA %s/%08lx\n", __func__, + m->m_pkthdr.len, (u_long) (skip + authsize + rplen), + ipsec_address(&sav->sah->saidx.dst, buf, sizeof(buf)), + (u_long) ntohl(sav->spi))); + AHSTAT_INC(ahs_badauthl); + error = EACCES; + goto bad; + } AHSTAT_ADD(ahs_ibytes, m->m_pkthdr.len - skip - hl); /* Get crypto descriptors. */ @@ -664,6 +674,9 @@ ah_input(struct mbuf *m, struct secasvar *sav, int ski /* Zeroize the authenticator on the packet. */ m_copyback(m, skip + rplen, authsize, ipseczeroes); + /* Save ah_nxt, since ah pointer can become invalid after "massage" */ + hl = ah->ah_nxt; + /* "Massage" the packet headers for crypto processing. */ error = ah_massage_headers(&m, sav->sah->saidx.dst.sa.sa_family, skip, ahx->type, 0); @@ -688,7 +701,7 @@ ah_input(struct mbuf *m, struct secasvar *sav, int ski tc->tc_spi = sav->spi; tc->tc_dst = sav->sah->saidx.dst; tc->tc_proto = sav->sah->saidx.proto; - tc->tc_nxt = ah->ah_nxt; + tc->tc_nxt = hl; tc->tc_protoff = protoff; tc->tc_skip = skip; tc->tc_ptr = (caddr_t) mtag; /* Save the mtag we've identified. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803070547.w275lm2e083354>