Skip to content

Commit c61e564

Browse files
committed
crypto: hisilicon - Cap block size at 2^31
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 <[email protected]> Fixes: d8ac7b8 ("crypto: hisilicon - fix large sgl memory...") Signed-off-by: Herbert Xu <[email protected]>
1 parent 7cf8195 commit c61e564

File tree

1 file changed

+2
-1
lines changed
  • drivers/crypto/hisilicon

1 file changed

+2
-1
lines changed

drivers/crypto/hisilicon/sgl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ struct hisi_acc_sgl_pool *hisi_acc_create_sgl_pool(struct device *dev,
6666

6767
sgl_size = sizeof(struct acc_hw_sge) * sge_nr +
6868
sizeof(struct hisi_acc_hw_sgl);
69-
block_size = PAGE_SIZE * (1 << (MAX_ORDER - 1));
69+
block_size = 1 << (PAGE_SHIFT + MAX_ORDER <= 32 ?
70+
PAGE_SHIFT + MAX_ORDER - 1 : 31);
7071
sgl_num_per_block = block_size / sgl_size;
7172
block_num = count / sgl_num_per_block;
7273
remain_sgl = count % sgl_num_per_block;

0 commit comments

Comments
 (0)