svn commit: r329907 - stable/11/sys/netipsec
Andrey V. Elsukov
ae at FreeBSD.org
Sat Feb 24 13:04:03 UTC 2018
Author: ae
Date: Sat Feb 24 13:04:02 2018
New Revision: 329907
URL: https://svnweb.freebsd.org/changeset/base/329907
Log:
MFC r329561:
Check packet length to do not make out of bounds access. Also save ah_nxt
value to use it later, since ah pointer can become invalid.
Reported by: Maxime Villard <max at m00nbsd dot net>
Modified:
stable/11/sys/netipsec/xform_ah.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/netipsec/xform_ah.c
==============================================================================
--- stable/11/sys/netipsec/xform_ah.c Sat Feb 24 10:33:31 2018 (r329906)
+++ stable/11/sys/netipsec/xform_ah.c Sat Feb 24 13:04:02 2018 (r329907)
@@ -582,6 +582,16 @@ ah_input(struct mbuf *m, struct secasvar *sav, int ski
error = EACCES;
goto bad;
}
+ 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. */
@@ -626,6 +636,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);
@@ -648,7 +661,7 @@ ah_input(struct mbuf *m, struct secasvar *sav, int ski
/* These are passed as-is to the callback. */
xd->sav = sav;
- xd->nxt = ah->ah_nxt;
+ xd->nxt = hl;
xd->protoff = protoff;
xd->skip = skip;
xd->cryptoid = cryptoid;
More information about the svn-src-all
mailing list