crypto: krb5enc - fix sleepable flag handling in encrypt dispatch
PATCH 1/1 crypto: krb5enc - fix sleepable flag handling in encrypt dispatch
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.
--- crypto/krb5enc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
crypto/krb5enc.c +3 -2
@@ -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
Signature · 1 line
2.34.1
Herbert Xu
maintainerQuoted 13 lines · Wesley Atwell
krb5enc_encrypt_ahash_done()continues encryption from an ahash completion callback by callingkrb5enc_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 preserveCRYPTO_TFM_REQ_MAY_SLEEPwhen the encrypt step is started from callback context.Preserve the original request flags but clear
CRYPTO_TFM_REQ_MAY_SLEEPfor the callback continuation path, and use the caller-supplied flags when setting up the skcipher subrequest.
Quoted 6 lines
Fixes d1775a177f7f ("crypto: Add 'krb5enc' hash and cipher AEAD algorithm")Assisted-by Codex:GPT-5Signed-off-by Wesley Atwell <[email protected]>--- crypto/krb5enc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt