mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
mm/page_table_check: skip zero pages
page_table_check_set() accounts pages by whether they are PageAnon(). The
shared zero page is a special page, not an ordinary file-backed page.
Read faults on private anonymous mappings can install many read-only PTEs
that point at the zero page, but page_table_check currently accounts them
in file_map_count.
That lets an unprivileged process populate enough zero-page mappings to
overflow file_map_count and trip the BUG_ON() in page_table_check_set().
Skip zero pages in page_table_check accounting. They do not need the
anonymous/file mapping conflict checks that page_table_check performs for
ordinary pages, and this keeps the existing counter size and page_ext
layout unchanged.
Link: https://lore.kernel.org/1f8848512d2e3ded944f8d595c29faee8fdaeab0.1784645969.git.roxy520tt@gmail.com
Fixes: df4e817b71 ("mm: page table check")
Signed-off-by: Zhiling Zou <[email protected]>
Signed-off-by: Ren Wei <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Reported-by: Vega <[email protected]>
Assisted-by: Codex:gpt-5.4
Cc: Ye Liu <[email protected]>
Cc: <[email protected]>
This commit is contained in:
committed by
Andrew Morton
parent
0224133dba
commit
33afd07412
@@ -67,7 +67,7 @@ static void page_table_check_clear(unsigned long pfn, unsigned long pgcnt)
|
||||
struct page *page;
|
||||
bool anon;
|
||||
|
||||
if (!pfn_valid(pfn))
|
||||
if (!pfn_valid(pfn) || is_zero_pfn(pfn) || is_huge_zero_pfn(pfn))
|
||||
return;
|
||||
|
||||
page = pfn_to_page(pfn);
|
||||
@@ -102,7 +102,7 @@ static void page_table_check_set(unsigned long pfn, unsigned long pgcnt,
|
||||
struct page *page;
|
||||
bool anon;
|
||||
|
||||
if (!pfn_valid(pfn))
|
||||
if (!pfn_valid(pfn) || is_zero_pfn(pfn) || is_huge_zero_pfn(pfn))
|
||||
return;
|
||||
|
||||
page = pfn_to_page(pfn);
|
||||
|
||||
Reference in New Issue
Block a user