[PATCH v2 0/2] mm/pagewalk: fix stale walk->action escaping walk_pmd_range()

From: Hyunwoo Kim

Date: Tue Aug 11 2026 - 13:19:49 EST


walk_pmd_range() could return with walk->action left at ACTION_AGAIN,
which causes walk_pud_range() to retry the PUD walk and invoke the walk
callbacks twice over the same range.

Patch 1 is the fix. Patch 2 adds a regression test for it.

Changes in v2:
- 1/2: reworked the changelog along the lines Lorenzo suggested and said
how the bug was found; the fix itself is unchanged (Lorenzo)
- 2/2: new, races smaps against MADV_DONTNEED and checks that Rss does not
come out twice as large as what was faulted in (Lorenzo)
- v1: https://lore.kernel.org/r/anmdrYGVqM-U4vlo@v4bel

Hyunwoo Kim (2):
mm/pagewalk: fix stale walk->action escaping walk_pmd_range()
selftests/mm: add stale walk->action race test

mm/pagewalk.c | 6 +-
tools/testing/selftests/mm/.gitignore | 1 +
tools/testing/selftests/mm/Makefile | 2 +
tools/testing/selftests/mm/ksft_pagewalk.sh | 4 +
.../testing/selftests/mm/pagewalk_race_test.c | 138 ++++++++++++++++++
tools/testing/selftests/mm/run_vmtests.sh | 2 +
tools/testing/selftests/mm/vm_util.h | 1 +
7 files changed, 150 insertions(+), 4 deletions(-)
create mode 100755 tools/testing/selftests/mm/ksft_pagewalk.sh
create mode 100644 tools/testing/selftests/mm/pagewalk_race_test.c

--
2.43.0