Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Hyunwoo Kim <imv4bel@gmail.com>
To: akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org,
	liam@infradead.org, vbabka@kernel.org, rppt@kernel.org,
	surenb@google.com, mhocko@suse.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, imv4bel@gmail.com
Subject: [PATCH v2 0/2] mm/pagewalk: fix stale walk->action escaping walk_pmd_range()
Date: Wed, 12 Aug 2026 01:18:56 +0900	[thread overview]
Message-ID: <20260811161949.3879321-1-imv4bel@gmail.com> (raw)

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



             reply	other threads:[~2026-08-11 16:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11 16:18 Hyunwoo Kim [this message]
2026-08-11 16:18 ` [PATCH v2 1/2] mm/pagewalk: fix stale walk->action escaping walk_pmd_range() Hyunwoo Kim
2026-08-11 16:23   ` Lorenzo Stoakes (ARM)
2026-08-11 17:10   ` David Hildenbrand (Arm)
2026-08-11 19:37   ` Andrew Morton
2026-08-11 20:17     ` Hyunwoo Kim
2026-08-11 16:18 ` [PATCH v2 2/2] selftests/mm: add stale walk->action race test Hyunwoo Kim
2026-08-11 16:33   ` Lorenzo Stoakes (ARM)
2026-08-11 17:11   ` David Hildenbrand (Arm)
2026-08-11 18:23     ` Lorenzo Stoakes (ARM)
2026-08-11 18:49       ` David Hildenbrand (Arm)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260811161949.3879321-1-imv4bel@gmail.com \
    --to=imv4bel@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox