提交 ce4cce2f 编写于 作者: G Guo Hui 提交者: Yang Yingliang

mm/page_alloc: fix managed_pages of zone is incorrect and out of bounds

uniontech inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I3RFV8
CVE: NA

----------------------------------------------------------------

Commit eb761d65 ("mm: parallelize deferred struct page initialization
within each node") the code "++zone" in follow code:
    /* Sanity check that the next zone really is unpopulated */
    WARN_ON(++zid < MAX_NR_ZONES && populated_zone(++zone));
    VM_BUG_ON(nr_init != nr_free);

    zone->managed_pages += nr_free;

makes the managed_pages statistics of the current zone incorrect
and the zone may have out-of-bounds memory when
CONFIG_DEFERRED_STRUCT_PAGE_INIT=y, causing the Virtual machine
system startup to fail when the Virtual machine system current
allocated memory is set to half of the Virtual machine
maximum memory using virt-manager tool

Fix it by putting the code “zone->managed_pages += nr_free;”
before “++zone” code

Fixes: eb761d65 ("mm: parallelize deferred struct page initialization
within each node")
Reported-by: NPeng Yuanbo <pengyuanbo@uniontech.com>
Signed-off-by: NGuo Hui <guohui@uniontech.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 fba3955b
......@@ -1688,12 +1688,13 @@ static int __init deferred_init_memmap(void *data)
nr_free += atomic64_read(&args.nr_pages);
}
/* Sanity check that the next zone really is unpopulated */
WARN_ON(++zid < MAX_NR_ZONES && populated_zone(++zone));
VM_BUG_ON(nr_init != nr_free);
zone->managed_pages += nr_free;
/* Sanity check that the next zone really is unpopulated */
WARN_ON(++zid < MAX_NR_ZONES && populated_zone(++zone));
pr_info("node %d initialised, %lu pages in %ums\n", nid, nr_free,
jiffies_to_msecs(jiffies - start));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册