Skip to content

Commit

Permalink
ipsec esp: avoid dereferencing freed secasindex
Browse files Browse the repository at this point in the history
It is possible that SA was removed while processing packed, in which
case it is changed to the DEAD state and it index is removed from the
tree. Dereferencing sav->sah then touches freed memory.

Reviewed by:	ae
Sponsored by:	NVIDIA networking
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44079
  • Loading branch information
kostikbel committed Feb 26, 2024
1 parent 1b3f4cc commit 1a56620
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sys/netipsec/xform_esp.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,13 @@ esp_input_cb(struct cryptop *crp)
xd = crp->crp_opaque;
CURVNET_SET(xd->vnet);
sav = xd->sav;
if (sav->state >= SADB_SASTATE_DEAD) {
/* saidx is freed */
DPRINTF(("%s: dead SA %p spi %#x\n", __func__, sav, sav->spi));
ESPSTAT_INC(esps_notdb);
error = ESRCH;
goto bad;
}
skip = xd->skip;
protoff = xd->protoff;
cryptoid = xd->cryptoid;
Expand Down

0 comments on commit 1a56620

Please sign in to comment.