~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/mm/page_table_check.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 .. SPDX-License-Identifier: GPL-2.0
  2 
  3 ================
  4 Page Table Check
  5 ================
  6 
  7 Introduction
  8 ============
  9 
 10 Page table check allows to harden the kernel by ensuring that some types of
 11 the memory corruptions are prevented.
 12 
 13 Page table check performs extra verifications at the time when new pages become
 14 accessible from the userspace by getting their page table entries (PTEs PMDs
 15 etc.) added into the table.
 16 
 17 In case of most detected corruption, the kernel is crashed. There is a small
 18 performance and memory overhead associated with the page table check. Therefore,
 19 it is disabled by default, but can be optionally enabled on systems where the
 20 extra hardening outweighs the performance costs. Also, because page table check
 21 is synchronous, it can help with debugging double map memory corruption issues,
 22 by crashing kernel at the time wrong mapping occurs instead of later which is
 23 often the case with memory corruptions bugs.
 24 
 25 It can also be used to do page table entry checks over various flags, dump
 26 warnings when illegal combinations of entry flags are detected.  Currently,
 27 userfaultfd is the only user of such to sanity check wr-protect bit against
 28 any writable flags.  Illegal flag combinations will not directly cause data
 29 corruption in this case immediately, but that will cause read-only data to
 30 be writable, leading to corrupt when the page content is later modified.
 31 
 32 Double mapping detection logic
 33 ==============================
 34 
 35 +-------------------+-------------------+-------------------+------------------+
 36 | Current Mapping   | New mapping       | Permissions       | Rule             |
 37 +===================+===================+===================+==================+
 38 | Anonymous         | Anonymous         | Read              | Allow            |
 39 +-------------------+-------------------+-------------------+------------------+
 40 | Anonymous         | Anonymous         | Read / Write      | Prohibit         |
 41 +-------------------+-------------------+-------------------+------------------+
 42 | Anonymous         | Named             | Any               | Prohibit         |
 43 +-------------------+-------------------+-------------------+------------------+
 44 | Named             | Anonymous         | Any               | Prohibit         |
 45 +-------------------+-------------------+-------------------+------------------+
 46 | Named             | Named             | Any               | Allow            |
 47 +-------------------+-------------------+-------------------+------------------+
 48 
 49 Enabling Page Table Check
 50 =========================
 51 
 52 Build kernel with:
 53 
 54 - PAGE_TABLE_CHECK=y
 55   Note, it can only be enabled on platforms where ARCH_SUPPORTS_PAGE_TABLE_CHECK
 56   is available.
 57 
 58 - Boot with 'page_table_check=on' kernel parameter.
 59 
 60 Optionally, build kernel with PAGE_TABLE_CHECK_ENFORCED in order to have page
 61 table support without extra kernel parameter.
 62 
 63 Implementation notes
 64 ====================
 65 
 66 We specifically decided not to use VMA information in order to avoid relying on
 67 MM states (except for limited "struct page" info). The page table check is a
 68 separate from Linux-MM state machine that verifies that the user accessible
 69 pages are not falsely shared.
 70 
 71 PAGE_TABLE_CHECK depends on EXCLUSIVE_SYSTEM_RAM. The reason is that without
 72 EXCLUSIVE_SYSTEM_RAM, users are allowed to map arbitrary physical memory
 73 regions into the userspace via /dev/mem. At the same time, pages may change
 74 their properties (e.g., from anonymous pages to named pages) while they are
 75 still being mapped in the userspace, leading to "corruption" detected by the
 76 page table check.
 77 
 78 Even with EXCLUSIVE_SYSTEM_RAM, I/O pages may be still allowed to be mapped via
 79 /dev/mem. However, these pages are always considered as named pages, so they
 80 won't break the logic used in the page table check.

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php