summaryrefslogtreecommitdiff
path: root/lib/atomic64.c
diff options
context:
space:
mode:
authorHuang Shijie <sjhuang@iluvatar.ai>2020-12-29 15:14:58 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-01-12 20:09:06 +0100
commit708f3baafc5b899da6dce39ad96c4c4a9770e3fd (patch)
treea447ac94871c4748e710d8aca933bf06638da765 /lib/atomic64.c
parent737cfa329c04e20b4c2d74c7ebeb4ed2e2de6598 (diff)
lib/genalloc: fix the overflow when size is too big
[ Upstream commit 36845663843fc59c5d794e3dc0641472e3e572da ] Some graphic card has very big memory on chip, such as 32G bytes. In the following case, it will cause overflow: pool = gen_pool_create(PAGE_SHIFT, NUMA_NO_NODE); ret = gen_pool_add(pool, 0x1000000, SZ_32G, NUMA_NO_NODE); va = gen_pool_alloc(pool, SZ_4G); The overflow occurs in gen_pool_alloc_algo_owner(): .... size = nbits << order; .... The @nbits is "int" type, so it will overflow. Then the gen_pool_avail() will return the wrong value. This patch converts some "int" to "unsigned long", and changes the compare code in while. Link: https://lkml.kernel.org/r/20201229060657.3389-1-sjhuang@iluvatar.ai Signed-off-by: Huang Shijie <sjhuang@iluvatar.ai> Reported-by: Shi Jiasheng <jiasheng.shi@iluvatar.ai> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'lib/atomic64.c')
0 files changed, 0 insertions, 0 deletions