mm: make persistent huge zero folio read-only
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v7 Latest3 patches 23 repliesIn review
- v63 patches 12 repliesSuperseded
- v53 patches 2 repliesSuperseded
Earlier versions · 4
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v4 RFC | 3 patches | 0 replies | Superseded | |
| v3 RFC | 3 patches | 2 replies | Superseded | |
| v2 RFC | 3 patches | 19 replies | Superseded | |
| v1 RFC | 3 patches | 11 replies | Superseded |
Changes in v7 from the cover letter
- Rebase onto the latest mm-unstable and adapt to huge_zero_init() (per David).
- Switch to a page-based interface and move TLB flushing into the architecture implementations (per Will, Dave and David).
- https://lore.kernel.org/r/[email protected]/
Patches in v7 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | mm: make persistent huge zero folio read-onlyinclude/ mm/ | +27 | 21 replies | |
| 2/3 | arm64/mm: add set_direct_map_ro()arch/ arch/ | +14 | 2 replies | |
| 3/3 | x86/mm: add set_direct_map_ro()arch/ arch/ | +12 | 0 replies |
Reviews trailers per patch
1 of 3 patches has a Reviewed-by or Acked-by.
| Patch | Will Deacon |
|---|---|
| 1/3 | |
| 2/3 | A-b |
| 3/3 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v7 0/3] mm: make persistent huge zero folio read-only
The persistent huge zero folio is shared globally and must remain zero after initialization. As Jann Horn pointed out [1], kernel bugs can write to pages that are intended to be read-only, including in security-sensitive paths. Protecting the folio's direct-map mapping turns such writes into faults instead of silently corrupting the shared zero page.
This series makes that protection available to MM code and applies it to the persistent huge zero folio. It is best-effort: arm64 and x86 protect the permanent direct-map mapping, while highmem folios and architectures without support retain the existing behavior.
The interface remains page-based to match the existing direct-map helpers. The wider address-based conversion discussed in [2] can be handled separately. Permission changes and TLB invalidation stay together in the architecture code, avoiding a noflush interface that is easy to misuse.
Patches 2 and 3 add arm64 and x86 support. The approach follows the huge-zero-folio discussion in [3].
v6 -> v7:
- Rebase onto the latest mm-unstable and adapt to huge_zero_init() (per David).
- Switch to a page-based interface and move TLB flushing into the architecture implementations (per Will, Dave and David).
- https://lore.kernel.org/r/[email protected]/
v5 -> v6:
- Patch #01: Skip the direct-map permission change and TLB flush for highmem folios, which have no permanent direct-map mapping.
- https://lore.kernel.org/all/[email protected]/
RFC v4 -> v5:
- Drop the RFC tag.
- No code changes.
- https://lore.kernel.org/all/[email protected]/
RFC v3 -> RFC v4:
- Patch #01: Flush the direct-map range after changing it read-only, since the folio was cleared through writable mappings after SMP initialization (per Usama, thanks!).
- Patch #01: Keep the flush in the caller to preserve the set_direct_map_ro_noflush() contract and make the flushed range explicit.
- Patch #01: Clarify the noflush API contract and the reason stale writable translations must be invalidated.
- https://lore.kernel.org/linux-mm/[email protected]/
RFC v2 -> RFC v3:
- Patch #01: Replace arch_make_pages_readonly() with set_direct_map_ro_noflush() in the existing set_direct_map* family (per Mike and David, thanks!).
- Patch #01: Use a direct-map address and number of pages, and document the direct-map-only and no-TLB-flush semantics (per David, thanks!).
- Patch #02 and #03: Update the arm64 and x86 implementations for set_direct_map_ro_noflush().
- https://lore.kernel.org/linux-mm/[email protected]/
RFC v1 -> RFC v2:
- Patch #01: Drop the READONLY_HUGE_ZERO_FOLIO Kconfig option
(per Dave, thanks!).
- Patch #01: Replace the huge-zero-folio-specific hook with a generic page-range hook (per David, thanks!).
- Patch #02 and #03: Update the arm64 and x86 implementations for the new hook.
- https://lore.kernel.org/linux-mm/[email protected]/
Xueyuan Chen (3):
mm: make persistent huge zero folio read-only
arm64/mm: add set_direct_map_ro()
x86/mm: add set_direct_map_ro()
arch/arm64/include/asm/set_memory.h | 2 ++ arch/arm64/mm/pageattr.c | 12 ++++++++++++ arch/x86/include/asm/set_memory.h | 2 ++ arch/x86/mm/pat/set_memory.c | 10 ++++++++++ include/linux/set_memory.h | 17 +++++++++++++++++ mm/huge_memory.c | 13 ++++++++++--- 6 files changed, 53 insertions(+), 3 deletions(-)
base-commit: 88297631d4d42f6004cb39c0ba3da7d2d10a616f
Signature · 1 line
2.47.3