* [PATCH v2] crypto: mxs-dcp: handle zero-length skcipher requests
@ 2026-09-08 9:44 Linmao Li
2026-09-09 21:03 ` Frank Li
0 siblings, 1 reply; 2+ messages in thread
From: Linmao Li @ 2026-09-08 9:44 UTC (permalink / raw)
To: Herbert Xu, David S. Miller
Cc: Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Leonard Crestez, Radu Solea, Franck LENORMAND, linux-crypto, imx,
linux-arm-kernel, linux-kernel, Linmao Li
The generic ECB and CBC implementations return success for zero-length
requests, but MXS-DCP queues them anyway. When such a request reaches
the worker, last_out_len remains zero. The CBC completion path then
subtracts AES_BLOCK_SIZE from this unsigned value when updating the IV,
causing the offset to underflow. On decryption, the resulting source
address precedes aes_in_buf.
Return success before enqueueing zero-length requests, matching the
generic implementations. This avoids the invalid source access and
leaves the IV unchanged.
Fixes: fadd7a6e616b ("crypto: mxs-dcp - Fix AES issues")
Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
---
v2: Clarify commit message: describe zero-length return-0 as existing
generic ECB/CBC behavior rather than a general API rule (Frank Li).
drivers/crypto/mxs-dcp.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
index 133ebc998236..60794b4d49fa 100644
--- a/drivers/crypto/mxs-dcp.c
+++ b/drivers/crypto/mxs-dcp.c
@@ -473,6 +473,9 @@ static int mxs_dcp_aes_enqueue(struct skcipher_request *req, int enc, int ecb)
struct dcp_aes_req_ctx *rctx = skcipher_request_ctx(req);
int ret;
+ if (!req->cryptlen)
+ return 0;
+
if (unlikely(actx->key_len != AES_KEYSIZE_128 && !actx->key_referenced))
return mxs_dcp_block_fallback(req, enc);
base-commit: 8d3ae59288f1e7d58d76558a6ee96d533bc5019f
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v2] crypto: mxs-dcp: handle zero-length skcipher requests
2026-09-08 9:44 [PATCH v2] crypto: mxs-dcp: handle zero-length skcipher requests Linmao Li
@ 2026-09-09 21:03 ` Frank Li
0 siblings, 0 replies; 2+ messages in thread
From: Frank Li @ 2026-09-09 21:03 UTC (permalink / raw)
To: Linmao Li
Cc: Herbert Xu, David S. Miller, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Leonard Crestez,
Radu Solea, Franck LENORMAND, linux-crypto, imx,
linux-arm-kernel, linux-kernel
On Tue, Sep 08, 2026 at 05:44:37PM +0800, Linmao Li wrote:
> The generic ECB and CBC implementations return success for zero-length
> requests, but MXS-DCP queues them anyway. When such a request reaches
> the worker, last_out_len remains zero. The CBC completion path then
> subtracts AES_BLOCK_SIZE from this unsigned value when updating the IV,
> causing the offset to underflow. On decryption, the resulting source
> address precedes aes_in_buf.
>
> Return success before enqueueing zero-length requests, matching the
> generic implementations. This avoids the invalid source access and
> leaves the IV unchanged.
>
> Fixes: fadd7a6e616b ("crypto: mxs-dcp - Fix AES issues")
> Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> v2: Clarify commit message: describe zero-length return-0 as existing
> generic ECB/CBC behavior rather than a general API rule (Frank Li).
> drivers/crypto/mxs-dcp.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
> index 133ebc998236..60794b4d49fa 100644
> --- a/drivers/crypto/mxs-dcp.c
> +++ b/drivers/crypto/mxs-dcp.c
> @@ -473,6 +473,9 @@ static int mxs_dcp_aes_enqueue(struct skcipher_request *req, int enc, int ecb)
> struct dcp_aes_req_ctx *rctx = skcipher_request_ctx(req);
> int ret;
>
> + if (!req->cryptlen)
> + return 0;
> +
> if (unlikely(actx->key_len != AES_KEYSIZE_128 && !actx->key_referenced))
> return mxs_dcp_block_fallback(req, enc);
>
>
> base-commit: 8d3ae59288f1e7d58d76558a6ee96d533bc5019f
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-09 21:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-08 9:44 [PATCH v2] crypto: mxs-dcp: handle zero-length skcipher requests Linmao Li
2026-09-09 21:03 ` Frank Li
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®