Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Chenghai Huang <huangchenghai2@huawei.com>
Cc: davem@davemloft.net, linux-kernel@vger.kernel.org,
	linux-crypto@vger.kernel.org, liulongfang@huawei.com,
	qianweili@huawei.com, wangzhou1@hisilicon.com,
	linwenkai6@hisilicon.com
Subject: Re: [PATCH 2/4] crypto: hisilicon/sec2 - fix scheduling while atomic in aead soft fallback
Date: Fri, 18 Sep 2026 19:13:25 +1000	[thread overview]
Message-ID: <aq0AtfUHUw1qOD2Y@gondor.apana.org.au> (raw)
In-Reply-To: <20260911102942.387778-3-huangchenghai2@huawei.com>

On Fri, Sep 11, 2026 at 06:29:40PM +0800, Chenghai Huang wrote:
> From: Wenkai Lin <linwenkai6@hisilicon.com>
> 
> 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: Chenghai Huang <huangchenghai2@huawei.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 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);

Please use SYNC_AEAD_REQUEST_ON_STACK for the fallback.

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

  reply	other threads:[~2026-09-18  9:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11 10:29 [PATCH 0/4] crypto: hisilicon - fix several issues in QM and SEC drivers Chenghai Huang
2026-09-11 10:29 ` [PATCH 1/4] crypto: hisilicon/qm - fix devm_kcalloc argument order Chenghai Huang
2026-09-11 10:29 ` [PATCH 2/4] crypto: hisilicon/sec2 - fix scheduling while atomic in aead soft fallback Chenghai Huang
2026-09-18  9:13   ` Herbert Xu [this message]
     [not found]     ` <c19bbae6-e1f1-4ca4-8156-8b1fb6746319@huawei.com>
2026-09-28  5:14       ` Herbert Xu
     [not found]         ` <82938646-1ee4-4789-8911-051c43b84d57@huawei.com>
2026-10-08  8:27           ` Herbert Xu
2026-09-11 10:29 ` [PATCH 3/4] crypto: hisilicon/qm - fix memory leak in hisi_qm_sort_devices Chenghai Huang
2026-09-11 10:29 ` [PATCH 4/4] crypto: hisilicon/qm - fix GFP flag inconsistency in hisi_qm_memory_init Chenghai Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aq0AtfUHUw1qOD2Y@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=davem@davemloft.net \
    --cc=huangchenghai2@huawei.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linwenkai6@hisilicon.com \
    --cc=liulongfang@huawei.com \
    --cc=qianweili@huawei.com \
    --cc=wangzhou1@hisilicon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox