[PATCH] crypto: essiv: avoid request access after subrequest
From: Jiale Yao
Date: Mon Sep 21 2026 - 05:10:41 EST
essiv_aead_crypt() reads rctx->assoc after submitting the child AEAD
request. An asynchronous completion can run essiv_aead_done(), free the
association buffer, and complete the outer request before the submission
call returns. The later request-context access can therefore use freed
memory and trigger a second free.
Snapshot the association buffer pointer before submitting the child
request and use the local value for synchronous cleanup.
Fixes: be1eb7f78aa8 ("crypto: essiv - create wrapper template for ESSIV generation")
Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
---
crypto/essiv.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/crypto/essiv.c b/crypto/essiv.c
index a47a3eab6935..5aea4584d5cb 100644
--- a/crypto/essiv.c
+++ b/crypto/essiv.c
@@ -189,6 +189,7 @@ static int essiv_aead_crypt(struct aead_request *req, bool enc)
int ivsize = crypto_aead_ivsize(tfm);
int ssize = req->assoclen - ivsize;
struct scatterlist *src = req->src;
+ void *assoc;
int err;
if (ssize < 0)
@@ -247,11 +248,12 @@ static int essiv_aead_crypt(struct aead_request *req, bool enc)
essiv_aead_done, req);
aead_request_set_crypt(subreq, src, req->dst, req->cryptlen, req->iv);
+ assoc = rctx->assoc;
err = enc ? crypto_aead_encrypt(subreq) :
crypto_aead_decrypt(subreq);
- if (rctx->assoc && err != -EINPROGRESS && err != -EBUSY)
- kfree(rctx->assoc);
+ if (assoc && err != -EINPROGRESS && err != -EBUSY)
+ kfree(assoc);
return err;
}
--
2.34.1