mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Zilin Guan <zilin@seu.edu.cn>
Cc: qianweili@huawei.com, wangzhou1@hisilicon.com,
	davem@davemloft.net, linux-crypto@vger.kernel.org,
	linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn
Subject: Re: [PATCH] crypto: hisilicon: use kfree_sensitive() for pool cleanup
Date: Sat, 24 May 2025 08:25:13 +0800	[thread overview]
Message-ID: <aDER6cD9S5HcbV2W@gondor.apana.org.au> (raw)
In-Reply-To: <20250523133057.4025075-1-zilin@seu.edu.cn>

On Fri, May 23, 2025 at 01:30:57PM +0000, Zilin Guan wrote:
> The error path of hisi_acc_create_sgl_pool() already calls
> kfree_sensitive() to wipe sensitive data before freeing the pool.
> However, hisi_acc_free_sgl_pool() currently uses plain kfree(), which
> may leave secrets behind in memory and undo the protection applied
> during creation.
> 
> This patch replaces kfree() with kfree_sensitive() in
> hisi_acc_free_sgl_pool(), ensuring that all SGL pool deallocations
> securely clear their contents.
> 
> Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
> ---
>  drivers/crypto/hisilicon/sgl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/hisilicon/sgl.c b/drivers/crypto/hisilicon/sgl.c
> index c974f95cd126..6a88a2056708 100644
> --- a/drivers/crypto/hisilicon/sgl.c
> +++ b/drivers/crypto/hisilicon/sgl.c
> @@ -151,7 +151,7 @@ void hisi_acc_free_sgl_pool(struct device *dev, struct hisi_acc_sgl_pool *pool)
>  		dma_free_coherent(dev, block[i].size, block[i].sgl,
>  				  block[i].sgl_dma);
>  
> -	kfree(pool);
> +	kfree_sensitive(pool);
>  }
>  EXPORT_SYMBOL_GPL(hisi_acc_free_sgl_pool);

What's in the pool? If it's just pointers then that is not sensitive
information.

You should only use kfree_sensitive if plaintext or private keys are
present.

Cheers,
-- 
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:[~2025-05-24  0:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-23 13:30 Zilin Guan
2025-05-24  0:25 ` Herbert Xu [this message]

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=aDER6cD9S5HcbV2W@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=davem@davemloft.net \
    --cc=jianhao.xu@seu.edu.cn \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qianweili@huawei.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=zilin@seu.edu.cn \
    /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

all inboxes | Powered by JetHome®