Skip to content

Commit

Permalink
crypto: hisilicon - Cap block size at 2^31
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
herbertx committed Jun 15, 2020
1 parent 7cf8195 commit c61e564
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/crypto/hisilicon/sgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c61e564

Please sign in to comment.