]> git.baikalelectronics.ru Git - kernel.git/commit
mm/z3fold: avoid possible underflow in z3fold_alloc()
authorMiaohe Lin <linmiaohe@huawei.com>
Thu, 1 Jul 2021 01:50:27 +0000 (18:50 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 1 Jul 2021 03:47:28 +0000 (20:47 -0700)
commitdfdd300d5ec380c3cdd10dc8ae095ff7218dba71
tree7c6bcfdf892c9c32c5db5f19f141e6d87d305804
parentfeef1b2c2b4d1b08aef62427ee21601584247648
mm/z3fold: avoid possible underflow in z3fold_alloc()

It is not enough to just make sure the z3fold header is not larger than
the page size.  When z3fold header is equal to PAGE_SIZE, we would
underflow when check alloc size against PAGE_SIZE - ZHDR_SIZE_ALIGNED -
CHUNK_SIZE in z3fold_alloc().  Make sure there has remaining spaces for
its buddy to fix this theoretical issue.

Link: https://lkml.kernel.org/r/20210619093151.1492174-3-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Vitaly Wool <vitaly.wool@konsulko.com>
Cc: Hillf Danton <hdanton@sina.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/z3fold.c