[PATCH 2/4] crypto: hisilicon/sec2 - fix scheduling while atomic in aead soft fallback
From: Chenghai Huang
Date: Fri Sep 11 2026 - 06:37:33 EST
From: Wenkai Lin <linwenkai6@xxxxxxxxxxxxx>
sec_aead_soft_crypto() allocates the sub-request with GFP_KERNEL, which
may sleep. This is safe when called directly from sec_aead_crypto()
(process context), but the function is also reachable through the
backlog drain path.
When an AEAD request sits in the backlog queue and qp_send_message()
returns a non-EBUSY error, the backlog is drained in software while
the backlog spinlock is still held. The GFP_KERNEL allocation inside
aead_request_alloc() can then schedule out, triggering scheduling
while atomic.
Fix it by switching the allocation to GFP_ATOMIC so it is safe in both
the process-context path and the spinlock-held backlog drain path.
Fixes: 0a2a464f8631 ("crypto: hisilicon/sec - fix the aead software fallback for engine")
Signed-off-by: Wenkai Lin <linwenkai6@xxxxxxxxxxxxx>
Signed-off-by: Chenghai Huang <huangchenghai2@xxxxxxxxxx>
---
drivers/crypto/hisilicon/sec2/sec_crypto.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c
index 0a2f7c8b44fc..bbb6826ab256 100644
--- a/drivers/crypto/hisilicon/sec2/sec_crypto.c
+++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c
@@ -2533,7 +2533,7 @@ static int sec_aead_soft_crypto(struct sec_ctx *ctx,
struct aead_request *subreq;
int ret;
- subreq = aead_request_alloc(a_ctx->fallback_aead_tfm, GFP_KERNEL);
+ subreq = aead_request_alloc(a_ctx->fallback_aead_tfm, GFP_ATOMIC);
if (!subreq)
return -ENOMEM;
--
2.43.0