mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] crypto: krb5enc - fix sleepable flag handling in encrypt dispatch
@ 2026-03-09  6:26 Wesley Atwell
  2026-03-21  8:41 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Wesley Atwell @ 2026-03-09  6:26 UTC (permalink / raw)
  To: herbert, davem, dhowells; +Cc: linux-crypto, linux-kernel, Wesley Atwell

krb5enc_encrypt_ahash_done() continues encryption from an ahash
completion callback by calling krb5enc_dispatch_encrypt().

That helper takes a flags argument for this continuation path, but it
ignored that argument and reused aead_request_flags(req) when setting
up the skcipher subrequest callback. This can incorrectly preserve
CRYPTO_TFM_REQ_MAY_SLEEP when the encrypt step is started from callback
context.

Preserve the original request flags but clear
CRYPTO_TFM_REQ_MAY_SLEEP for the callback continuation path, and use
the caller-supplied flags when setting up the skcipher subrequest.

Fixes: d1775a177f7f ("crypto: Add 'krb5enc' hash and cipher AEAD algorithm")
Assisted-by: Codex:GPT-5
Signed-off-by: Wesley Atwell <atwellwea@gmail.com>
---
 crypto/krb5enc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/crypto/krb5enc.c b/crypto/krb5enc.c
index a1de55994d92..1bfe8370cf94 100644
--- a/crypto/krb5enc.c
+++ b/crypto/krb5enc.c
@@ -154,7 +154,7 @@ static int krb5enc_dispatch_encrypt(struct aead_request *req,
 		dst = scatterwalk_ffwd(areq_ctx->dst, req->dst, req->assoclen);
 
 	skcipher_request_set_tfm(skreq, enc);
-	skcipher_request_set_callback(skreq, aead_request_flags(req),
+	skcipher_request_set_callback(skreq, flags,
 				      krb5enc_encrypt_done, req);
 	skcipher_request_set_crypt(skreq, src, dst, req->cryptlen, req->iv);
 
@@ -192,7 +192,8 @@ static void krb5enc_encrypt_ahash_done(void *data, int err)
 
 	krb5enc_insert_checksum(req, ahreq->result);
 
-	err = krb5enc_dispatch_encrypt(req, 0);
+	err = krb5enc_dispatch_encrypt(req,
+				       aead_request_flags(req) & ~CRYPTO_TFM_REQ_MAY_SLEEP);
 	if (err != -EINPROGRESS)
 		aead_request_complete(req, err);
 }

base-commit: 1f318b96cc84d7c2ab792fcc0bfd42a7ca890681
-- 
2.34.1


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

* Re: [PATCH] crypto: krb5enc - fix sleepable flag handling in encrypt dispatch
  2026-03-09  6:26 [PATCH] crypto: krb5enc - fix sleepable flag handling in encrypt dispatch Wesley Atwell
@ 2026-03-21  8:41 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2026-03-21  8:41 UTC (permalink / raw)
  To: Wesley Atwell; +Cc: davem, dhowells, linux-crypto, linux-kernel

On Mon, Mar 09, 2026 at 12:26:24AM -0600, Wesley Atwell wrote:
> krb5enc_encrypt_ahash_done() continues encryption from an ahash
> completion callback by calling krb5enc_dispatch_encrypt().
> 
> That helper takes a flags argument for this continuation path, but it
> ignored that argument and reused aead_request_flags(req) when setting
> up the skcipher subrequest callback. This can incorrectly preserve
> CRYPTO_TFM_REQ_MAY_SLEEP when the encrypt step is started from callback
> context.
> 
> Preserve the original request flags but clear
> CRYPTO_TFM_REQ_MAY_SLEEP for the callback continuation path, and use
> the caller-supplied flags when setting up the skcipher subrequest.
> 
> Fixes: d1775a177f7f ("crypto: Add 'krb5enc' hash and cipher AEAD algorithm")
> Assisted-by: Codex:GPT-5
> Signed-off-by: Wesley Atwell <atwellwea@gmail.com>
> ---
>  crypto/krb5enc.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2026-03-21  8:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-09  6:26 [PATCH] crypto: krb5enc - fix sleepable flag handling in encrypt dispatch Wesley Atwell
2026-03-21  8:41 ` Herbert Xu

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

all inboxes | Powered by JetHome®