Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH] crypto: essiv: avoid request access after subrequest
@ 2026-09-21  9:04 Jiale Yao
  2026-09-21  9:09 ` jiale yao
  2026-09-21 13:07 ` [PATCH] " Ard Biesheuvel
  0 siblings, 2 replies; 3+ messages in thread
From: Jiale Yao @ 2026-09-21  9:04 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Mike Snitzer, Ard Biesheuvel,
	linux-crypto, linux-kernel
  Cc: Jiale Yao

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@163.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-21 13:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-21  9:04 [PATCH] crypto: essiv: avoid request access after subrequest Jiale Yao
2026-09-21  9:09 ` jiale yao
2026-09-21 13:07 ` [PATCH] " Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox