summaryrefslogtreecommitdiff
path: root/mm/bootmem_info.c
diff options
context:
space:
mode:
authorChen Wandun <chenwandun@huawei.com>2021-09-03 00:56:52 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2021-09-03 19:58:14 +0300
commit5e22928abe671ea1541f19afb80523442938d342 (patch)
treedf069aa66121681aff125627899b8dea51457020 /mm/bootmem_info.c
parent9b593cb20283e68e5e65b09ca10038935297f05b (diff)
downloadlinux-5e22928abe671ea1541f19afb80523442938d342.tar.xz
mm/mremap: fix memory account on do_munmap() failure
mremap will account the delta between new_len and old_len in vma_to_resize, and then call move_vma when expanding an existing memory mapping. In function move_vma, there are two scenarios when calling do_munmap: 1. move_page_tables from old_addr to new_addr success 2. move_page_tables from old_addr to new_addr fail In first scenario, it should account old_len if do_munmap fail, because the delta has already been accounted. In second scenario, new_addr/new_len will assign to old_addr/old_len if move_page_table fail, so do_munmap is try to unmap new_addr actually, if do_munmap fail, it should account the new_len, because error code will be return from move_vma, and delta will be unaccounted. What'more, because of new_len == old_len, so account old_len also is OK. In summary, account old_len will be correct if do_munmap fail. Link: https://lkml.kernel.org/r/20210717101942.120607-1-chenwandun@huawei.com Fixes: 51df7bcb6151 ("mm/mremap: account memory on do_munmap() failure") Signed-off-by: Chen Wandun <chenwandun@huawei.com> Acked-by: Dmitry Safonov <dima@arista.com> Cc: Kefeng Wang <wangkefeng.wang@huawei.com> Cc: Wei Yongjun <weiyongjun1@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/bootmem_info.c')
0 files changed, 0 insertions, 0 deletions