Skip to content

Commit 81a31a8

Browse files
lrh2000gregkh
authored andcommitted
mm: page_table_check: Make it dependent on EXCLUSIVE_SYSTEM_RAM
Without EXCLUSIVE_SYSTEM_RAM, users are allowed to map arbitrary physical memory regions into the userspace via /dev/mem. At the same time, pages may change their properties (e.g., from anonymous pages to named pages) while they are still being mapped in the userspace, leading to "corruption" detected by the page table check. To avoid these false positives, this patch makes PAGE_TABLE_CHECK depends on EXCLUSIVE_SYSTEM_RAM. This dependency is understandable because PAGE_TABLE_CHECK is a hardening technique but /dev/mem without STRICT_DEVMEM (i.e., !EXCLUSIVE_SYSTEM_RAM) is itself a security problem. Even with EXCLUSIVE_SYSTEM_RAM, I/O pages may be still allowed to be mapped via /dev/mem. However, these pages are always considered as named pages, so they won't break the logic used in the page table check. Cc: <[email protected]> # 5.17 Signed-off-by: Ruihan Li <[email protected]> Acked-by: David Hildenbrand <[email protected]> Acked-by: Pasha Tatashin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d0b8616 commit 81a31a8

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Documentation/mm/page_table_check.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,22 @@ Build kernel with:
5252

5353
Optionally, build kernel with PAGE_TABLE_CHECK_ENFORCED in order to have page
5454
table support without extra kernel parameter.
55+
56+
Implementation notes
57+
====================
58+
59+
We specifically decided not to use VMA information in order to avoid relying on
60+
MM states (except for limited "struct page" info). The page table check is a
61+
separate from Linux-MM state machine that verifies that the user accessible
62+
pages are not falsely shared.
63+
64+
PAGE_TABLE_CHECK depends on EXCLUSIVE_SYSTEM_RAM. The reason is that without
65+
EXCLUSIVE_SYSTEM_RAM, users are allowed to map arbitrary physical memory
66+
regions into the userspace via /dev/mem. At the same time, pages may change
67+
their properties (e.g., from anonymous pages to named pages) while they are
68+
still being mapped in the userspace, leading to "corruption" detected by the
69+
page table check.
70+
71+
Even with EXCLUSIVE_SYSTEM_RAM, I/O pages may be still allowed to be mapped via
72+
/dev/mem. However, these pages are always considered as named pages, so they
73+
won't break the logic used in the page table check.

mm/Kconfig.debug

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ config PAGE_OWNER
9898
config PAGE_TABLE_CHECK
9999
bool "Check for invalid mappings in user page tables"
100100
depends on ARCH_SUPPORTS_PAGE_TABLE_CHECK
101+
depends on EXCLUSIVE_SYSTEM_RAM
101102
select PAGE_EXTENSION
102103
help
103104
Check that anonymous page is not being mapped twice with read write

0 commit comments

Comments
 (0)