All of lore.kernel.org
 help / color / mirror / Atom feed
From: Corentin Labbe <clabbe.montjoie@gmail.com>
To: Gilad Ben-Yossef <gilad@benyossef.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Ofir Drang <ofir.drang@arm.com>,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] crypto: ccree: don't attempt 0 len DMA mappings
Date: Sun, 20 Feb 2022 20:24:36 +0100	[thread overview]
Message-ID: <YhKVdOI02tnvOl7R@Red> (raw)
In-Reply-To: <20220217192726.612328-1-gilad@benyossef.com>

Le Thu, Feb 17, 2022 at 09:27:26PM +0200, Gilad Ben-Yossef a écrit :
> Refuse to try mapping zero bytes as this may cause a fault
> on some configurations / platforms and it seems the prev.
> attempt is not enough and we need to be more explicit.
> 
> Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
> Reported-by: Corentin Labbe <clabbe.montjoie@gmail.com>
> Fixes: ce0fc6db38de ("crypto: ccree - protect against empty or NULL
> scatterlists")
> ---
>  drivers/crypto/ccree/cc_buffer_mgr.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c
> index a5e041d9d2cf..11e0278c8631 100644
> --- a/drivers/crypto/ccree/cc_buffer_mgr.c
> +++ b/drivers/crypto/ccree/cc_buffer_mgr.c
> @@ -258,6 +258,13 @@ static int cc_map_sg(struct device *dev, struct scatterlist *sg,
>  {
>  	int ret = 0;
>  
> +	if (!nbytes) {
> +		*mapped_nents = 0;
> +		*lbytes = 0;
> +		*nents = 0;
> +		return 0;
> +	}
> +
>  	*nents = cc_get_sgl_nents(dev, sg, nbytes, lbytes);
>  	if (*nents > max_sg_nents) {
>  		*nents = 0;
> -- 
> 2.25.1
> 

Hello

With this patch, the stacktrace I reported is not present anymore.

Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Tested-on: r8a7795-salvator-x

Regards

  reply	other threads:[~2022-02-20 19:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-17 19:27 [PATCH] crypto: ccree: don't attempt 0 len DMA mappings Gilad Ben-Yossef
2022-02-20 19:24 ` Corentin Labbe [this message]
2022-02-23  3:32 ` Herbert Xu

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=YhKVdOI02tnvOl7R@Red \
    --to=clabbe.montjoie@gmail.com \
    --cc=davem@davemloft.net \
    --cc=gilad@benyossef.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ofir.drang@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.