linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: Check writable zero page in page table check
@ 2022-09-02 23:27 Rick Edgecombe
  2022-09-03  2:13 ` Huang, Shaoqin
  2022-09-06  0:38 ` Pasha Tatashin
  0 siblings, 2 replies; 10+ messages in thread
From: Rick Edgecombe @ 2022-09-02 23:27 UTC (permalink / raw)
  To: pasha.tatashin, akpm, linux-mm; +Cc: rick.p.edgecombe, linux-kernel

The zero page should remain all zero, so that it can be mapped as
read-only for read faults of memory that should be zeroed. If it is ever
mapped writable to userspace, it could become non-zero and so other apps
would unexpectedly get non-zero data. So the zero page should never be
mapped writable to userspace. Check for this condition in
page_table_check_set().

Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>

---

Hi,

CONFIG_PAGE_TABLE_CHECK is pretty explicit about what it checks (and
doesn't mention the zero page), but this condition seems to fit with the
general category of "pages mapped wrongly to userspace". I added it
locally to help me debug something. Maybe it's more widely useful.

 mm/page_table_check.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/page_table_check.c b/mm/page_table_check.c
index e2062748791a..665ece0d55d4 100644
--- a/mm/page_table_check.c
+++ b/mm/page_table_check.c
@@ -102,6 +102,8 @@ static void page_table_check_set(struct mm_struct *mm, unsigned long addr,
 	if (!pfn_valid(pfn))
 		return;
 
+	BUG_ON(is_zero_pfn(pfn) && rw);
+
 	page = pfn_to_page(pfn);
 	page_ext = lookup_page_ext(page);
 	anon = PageAnon(page);

base-commit: b90cb1053190353cc30f0fef0ef1f378ccc063c5
-- 
2.17.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-09-06 16:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-02 23:27 [PATCH] mm: Check writable zero page in page table check Rick Edgecombe
2022-09-03  2:13 ` Huang, Shaoqin
2022-09-05 18:50   ` Edgecombe, Rick P
2022-09-06  0:24     ` Huang, Shaoqin
2022-09-06  0:49       ` John Hubbard
2022-09-06  0:37   ` Pasha Tatashin
2022-09-06  1:01     ` Huang, Shaoqin
2022-09-06 16:42     ` Edgecombe, Rick P
2022-09-06  0:38 ` Pasha Tatashin
2022-09-06  0:39   ` Pasha Tatashin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox