From: Wenkai Lin <linwenkai6@hisilicon.com> driver inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/10368 CVE: NA ---------------------------------------------------------------------- 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@hisilicon.com> Signed-off-by: Ruibin Deng <dengruibin@h-partners.com> --- 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 cf3e76b10eeb..86aa3b5b69e8 100644 --- a/drivers/crypto/hisilicon/sec2/sec_crypto.c +++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c @@ -2515,7 +2515,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