All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhou Wang <wangzhou1@hisilicon.com>
To: Herbert Xu <herbert@gondor.apana.org.au>,
	Linux Crypto Mailing List <linux-crypto@vger.kernel.org>,
	Shukun Tan <tanshukun1@huawei.com>
Subject: Re: [PATCH] crypto: hisilicon - Cap block size at 2^31
Date: Thu, 4 Jun 2020 21:54:33 +0800	[thread overview]
Message-ID: <5ED8FD19.1010502@hisilicon.com> (raw)
In-Reply-To: <20200604073750.GA30866@gondor.apana.org.au>

On 2020/6/4 15:37, Herbert Xu wrote:
> The function hisi_acc_create_sg_pool may allocate a block of
> memory of size PAGE_SIZE * 2^(MAX_ORDER - 1).  This value may
> exceed 2^31 on ia64, which would overflow the u32.
> 
> This patch caps it at 2^31.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Fixes: d8ac7b85236b ("crypto: hisilicon - fix large sgl memory...")
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Fine to me, Thanks!

> 
> diff --git a/drivers/crypto/hisilicon/sgl.c b/drivers/crypto/hisilicon/sgl.c
> index 0e8c7e324fb4..725a739800b0 100644
> --- a/drivers/crypto/hisilicon/sgl.c
> +++ b/drivers/crypto/hisilicon/sgl.c
> @@ -66,7 +66,8 @@ struct hisi_acc_sgl_pool *hisi_acc_create_sgl_pool(struct device *dev,
>  
>  	sgl_size = sizeof(struct acc_hw_sge) * sge_nr +
>  		   sizeof(struct hisi_acc_hw_sgl);
> -	block_size = PAGE_SIZE * (1 << (MAX_ORDER - 1));
> +	block_size = 1 << (PAGE_SHIFT + MAX_ORDER <= 32 ?
> +			   PAGE_SHIFT + MAX_ORDER - 1 : 31);
>  	sgl_num_per_block = block_size / sgl_size;
>  	block_num = count / sgl_num_per_block;
>  	remain_sgl = count % sgl_num_per_block;
> 

      reply	other threads:[~2020-06-04 13:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-04  7:37 [PATCH] crypto: hisilicon - Cap block size at 2^31 Herbert Xu
2020-06-04 13:54 ` Zhou Wang [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=5ED8FD19.1010502@hisilicon.com \
    --to=wangzhou1@hisilicon.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=tanshukun1@huawei.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.