Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <lkp@intel.com>
Fixes: d8ac7b85236b ("crypto: hisilicon - fix large sgl memory...")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+2 -1
+2 -1
drivers/crypto/hisilicon/sgl.c
··· 66 66 67 67 sgl_size = sizeof(struct acc_hw_sge) * sge_nr + 68 68 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); 70 71 sgl_num_per_block = block_size / sgl_size; 71 72 block_num = count / sgl_num_per_block; 72 73 remain_sgl = count % sgl_num_per_block;