mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 21:05:08 +00:00
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> MFC after: 5 days
This commit is contained in:
parent
8cebd0e419
commit
6ca39da354
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329561
|
@ -582,6 +582,16 @@ ah_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
|
|||
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 skip, int protoff)
|
|||
/* 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);
|
||||
|
@ -650,7 +663,7 @@ ah_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
|
|||
|
||||
/* 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;
|
||||
|
|
Loading…
Reference in a new issue