1.. SPDX-License-Identifier: GPL-2.0 2 3================ 4Page Table Check 5================ 6 7Introduction 8============ 9 10Page table check allows to harden the kernel by ensuring that some types of 11the memory corruptions are prevented. 12 13Page table check performs extra verifications at the time when new pages become 14accessible from the userspace by getting their page table entries (PTEs PMDs 15etc.) added into the table. 16 17In case of detected corruption, the kernel is crashed. There is a small 18performance and memory overhead associated with the page table check. Therefore, 19it is disabled by default, but can be optionally enabled on systems where the 20extra hardening outweighs the performance costs. Also, because page table check 21is synchronous, it can help with debugging double map memory corruption issues, 22by crashing kernel at the time wrong mapping occurs instead of later which is 23often the case with memory corruptions bugs. 24 25Double mapping detection logic 26============================== 27 28+-------------------+-------------------+-------------------+------------------+ 29| Current Mapping | New mapping | Permissions | Rule | 30+===================+===================+===================+==================+ 31| Anonymous | Anonymous | Read | Allow | 32+-------------------+-------------------+-------------------+------------------+ 33| Anonymous | Anonymous | Read / Write | Prohibit | 34+-------------------+-------------------+-------------------+------------------+ 35| Anonymous | Named | Any | Prohibit | 36+-------------------+-------------------+-------------------+------------------+ 37| Named | Anonymous | Any | Prohibit | 38+-------------------+-------------------+-------------------+------------------+ 39| Named | Named | Any | Allow | 40+-------------------+-------------------+-------------------+------------------+ 41 42Enabling Page Table Check 43========================= 44 45Build kernel with: 46 47- PAGE_TABLE_CHECK=y 48 Note, it can only be enabled on platforms where ARCH_SUPPORTS_PAGE_TABLE_CHECK 49 is available. 50 51- Boot with 'page_table_check=on' kernel parameter. 52 53Optionally, build kernel with PAGE_TABLE_CHECK_ENFORCED in order to have page 54table support without extra kernel parameter. 55