Skip to content

mm: (pte|pmd)_mkdirty() should not unconditionally allow for write access

David Hildenbrand linux-kselftest linux-mm lkml sparclinux 2 versions Applied

Status from this message: [merged mm-stable] mm-huge_memory-conditionally-call-maybe_mkwrite-and-drop-pte_wrprotect-in-__split_huge_pmd_locked.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v1 Latest posting 2/26 patches 3 repliesApplied 6/6
  2. v1 posting 1/26 patches 0 repliesSuperseded

Patches in v1 posting 2/2 All 6 applied

#Subject and filesSizeRepliesApplied
1/6selftests/mm: reuse read_pmd_pagesize() in COW selftesttools/testing/selftests/mm/cow.c tools/testing/selftests/mm/khugepaged.c tools/testing/selftests/mm/soft-dirty.c +2 more+17 -310 repliesApplied
2/6selftests/mm: mkdirty: test behavior of (pte|pmd)_mkdirty on VMAs without write permissionstools/testing/selftests/mm/Makefile tools/testing/selftests/mm/mkdirty.c+381 -00 repliesApplied
3/6sparc/mm: don't unconditionally set HW writable bit when setting PTE dirty on 64bitarch/sparc/include/asm/pgtable_64.h+66 -503 repliesApplied
4/6mm/migrate: revert "mm/migrate: fix wrongly apply write bit after mkdirty on sparc64"mm/huge_memory.c mm/migrate.c+2 -60 repliesApplied
5/6mm/huge_memory: revert "Partly revert "mm/thp: carry over dirty bit when thp splits on pmd""mm/huge_memory.c+2 -70 repliesApplied
6/6mm/huge_memory: conditionally call maybe_mkwrite() and drop pte_wrprotect() in __split_huge_pmd_locked()mm/huge_memory.c+2 -30 repliesApplied

Reviews trailers per patch

1 of 6 patches has a Reviewed-by or Acked-by.

PatchSam Ravnborg
1/6
2/6
3/6A-b
4/6
5/6
6/6

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH v1 RESEND 0/6] mm: (pte|pmd)_mkdirty() should not unconditionally allow for write access

This is the follow-up on [1], adding selftests (testing for known issues we added workarounds for and other issues that haven't been fixed yet), fixing sparc64, reverting the workarounds, and perform one cleanup.

The patch from [1] was modified slightly (updated/extended patch description, dropped one unnecessary NOP instruction from the ASM in __pte_mkhwwrite()).

Retested on x86_64 and sparc64 (sun4u in QEMU).

I scanned most architectures to make sure their (pte|pmd)_mkdirty() handling is correct. To be sure, we can run the selftests and find out if other architectures are still affectes (loongarch was fixed recently as well).

Based on master for now. I don't expect surprises regarding mm-tress, but I can rebase if there are any problems.

[1] https://lkml.kernel.org/r/[email protected]

Cc Andrew Morton <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Peter Xu <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Shuah Khan <[email protected]>
Cc Sam Ravnborg <[email protected]>
Cc Yu Zhao <[email protected]>
Cc Anshuman Khandual <[email protected]>

David Hildenbrand (6):
selftests/mm: reuse read_pmd_pagesize() in COW selftest selftests/mm: mkdirty: test behavior of (pte|pmd)_mkdirty on VMAs
without write permissions
sparc/mm: don't unconditionally set HW writable bit when setting PTE
dirty on 64bit
mm/migrate: revert "mm/migrate: fix wrongly apply write bit after
mkdirty on sparc64"
mm/huge_memory: revert "Partly revert "mm/thp: carry over dirty bit
when thp splits on pmd""
mm/huge_memory: conditionally call maybe_mkwrite() and drop
pte_wrprotect() in __split_huge_pmd_locked()

 arch/sparc/include/asm/pgtable_64.h           | 116 +++---
 mm/huge_memory.c                              |  16 +-
 mm/migrate.c                                  |   2 -
 tools/testing/selftests/mm/Makefile           |   2 +
 tools/testing/selftests/mm/cow.c              |  33 +-
 tools/testing/selftests/mm/khugepaged.c       |   4 +
 tools/testing/selftests/mm/mkdirty.c          | 379 ++++++++++++++++++
 tools/testing/selftests/mm/soft-dirty.c       |   3 +
 .../selftests/mm/split_huge_page_test.c       |   4 +
 tools/testing/selftests/mm/vm_util.c          |   4 +-
 10 files changed, 468 insertions(+), 95 deletions(-)
 create mode 100644 tools/testing/selftests/mm/mkdirty.c
Signature · 1 line
2.39.2