From f0993522412d567c96241f1dc7d9f2bd03d501f0 Mon Sep 17 00:00:00 2001 From: Liu Shixin Date: Tue, 17 May 2022 07:38:49 +0000 Subject: [PATCH] mm/memory.c: update the first page in clear_gigantic_page_chunk hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I57SM0 CVE: NA -------------------------------- Patch "mm: parallelize clear_gigantic_page" make clear_gigantic_page to be parallelized. But forgot to update the first page which results the first page for each block is still the head page. Fix it by calculating the first page for each block. By the way, add a check to pointer p in order to prevent kernel panic. Fixes: ae0cd4d46ced ("mm: parallelize clear_gigantic_page") Signed-off-by: Liu Shixin Reviewed-by: Kefeng Wang Signed-off-by: Yongqiang Liu --- mm/memory.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 98c2872f8415..8be034c0f10b 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4721,14 +4721,15 @@ static int clear_gigantic_page_chunk(unsigned long start, unsigned long end, struct cgp_args *args) { struct page *base_page = args->base_page; - struct page *p = base_page; + struct page *p = mem_map_offset(base_page, start); unsigned long addr = args->addr; unsigned long i; might_sleep(); for (i = start; i < end; i++, p = mem_map_next(p, base_page, i)) { cond_resched(); - clear_user_highpage(p, addr + i * PAGE_SIZE); + if (p) + clear_user_highpage(p, addr + i * PAGE_SIZE); } return KTASK_RETURN_SUCCESS; -- GitLab