Skip to content

RFC arm64: implement read-only page tables

Ard Biesheuvel kvmarm linux-arm-kernel linux-hardening 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest12 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12asm-generic/pgalloc: allow arch to override PMD alloc/free routinesinclude/asm-generic/pgalloc.h+11 -20 replies
2/12arm64: mm: add helpers to remap page tables read-only/read-writearch/arm64/include/asm/pgtable.h arch/arm64/mm/pageattr.c+17 -00 replies
3/12arm64: mm: use a fixmap slot for user page table modificationsarch/arm64/Kconfig arch/arm64/include/asm/fixmap.h arch/arm64/include/asm/pgalloc.h +4 more+209 -201 reply
4/12arm64: mm: remap PGD pages r/o in the linear region after allocationarch/arm64/mm/mmu.c arch/arm64/mm/pgd.c+23 -90 replies
5/12arm64: mm: remap PUD pages r/o in linear regionarch/arm64/include/asm/pgalloc.h arch/arm64/include/asm/tlb.h arch/arm64/mm/mmu.c+27 -00 replies
6/12arm64: mm: remap PMD pages r/o in linear regionarch/arm64/include/asm/pgalloc.h arch/arm64/include/asm/tlb.h arch/arm64/mm/mmu.c+28 -00 replies
7/12arm64: mm: remap PTE level user page tables r/o in the linear regionarch/arm64/include/asm/pgalloc.h arch/arm64/include/asm/tlb.h arch/arm64/mm/mmu.c+30 -00 replies
8/12arm64: mm: remap kernel PTE level page tables r/o in the linear regionarch/arm64/include/asm/pgalloc.h arch/arm64/mm/mmu.c+29 -10 replies
9/12arm64: mm: remap kernel page tables read-only at end of initarch/arm64/mm/mmu.c+20 -00 replies
10/12mm: add default definition of p4d_index()include/linux/pgtable.h+8 -00 replies
11/12arm64: efi: use set_pte_at() not set_pte() in order to pass mm pointerarch/arm64/kernel/efi.c+1 -10 replies
12/12arm64: hugetlb: use set_pte_at() not set_pte() to provide mm pointerarch/arm64/mm/hugetlbpage.c+2 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 00/12] arm64: implement read-only page tables

This RFC series implements support for mapping all user and kernel page tables read-only in the linear map, and using a special fixmap slot to make any modifications.

The purpose is to prevent page tables from being manipulated inadvertently, which is becoming more and more important on arm64, as many new hardening features such as BTI and MTE are controlled via attributes in the page tables.

This series is only half of the work that is underway to implement this in terms of hypervisor services rather than fixmap pokes, as this will allow the hypervisor to remove all write permissions from pages used as page tables. This work is being done in the context of the pKVM project, which defines a clear boundary between the hypervisor executing at EL2, and the [untrusted] host running at EL1. In this context, managing the host's page tables at HYP level should increase the robustness of the entire system substantially.

This series is posted separately for discussion, as it introduces the changes that are necessary to route all page table updates via a small set of helpers, allowing us to choose between unprotected, fixmap or HYP protection straight-forwardly.

The pKVM specific changes will be posted as a followup series.

Cc Will Deacon <[email protected]>
Cc Marc Zyngier <[email protected]>
Cc Fuad Tabba <[email protected]>
Cc Quentin Perret <[email protected]>
Cc Mark Rutland <[email protected]>
Cc James Morse <[email protected]>
Cc Catalin Marinas <[email protected]>

Ard Biesheuvel (12):
asm-generic/pgalloc: allow arch to override PMD alloc/free routines
arm64: mm: add helpers to remap page tables read-only/read-write
arm64: mm: use a fixmap slot for user page table modifications
arm64: mm: remap PGD pages r/o in the linear region after allocation
arm64: mm: remap PUD pages r/o in linear region
arm64: mm: remap PMD pages r/o in linear region
arm64: mm: remap PTE level user page tables r/o in the linear region
arm64: mm: remap kernel PTE level page tables r/o in the linear region
arm64: mm: remap kernel page tables read-only at end of init
mm: add default definition of p4d_index()
arm64: efi: use set_pte_at() not set_pte() in order to pass mm pointer
arm64: hugetlb: use set_pte_at() not set_pte() to provide mm pointer

 arch/arm64/Kconfig               |  11 ++
 arch/arm64/include/asm/fixmap.h  |   1 +
 arch/arm64/include/asm/pgalloc.h |  49 ++++++++-
 arch/arm64/include/asm/pgtable.h |  82 +++++++++++---
 arch/arm64/include/asm/tlb.h     |   6 +
 arch/arm64/kernel/efi.c          |   2 +-
 arch/arm64/mm/Makefile           |   2 +
 arch/arm64/mm/fault.c            |   8 +-
 arch/arm64/mm/hugetlbpage.c      |   4 +-
 arch/arm64/mm/mmu.c              | 115 +++++++++++++++++++-
 arch/arm64/mm/pageattr.c         |  14 +++
 arch/arm64/mm/pgd.c              |  25 +++--
 arch/arm64/mm/ro_page_tables.c   | 100 +++++++++++++++++
 include/asm-generic/pgalloc.h    |  13 ++-
 include/linux/pgtable.h          |   8 ++
 15 files changed, 405 insertions(+), 35 deletions(-)
 create mode 100644 arch/arm64/mm/ro_page_tables.c

base-commit: e783362eb54cd99b2cac8b3a9aeac942e6f6ac07

Signature · 1 line
2.30.2