All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Serge E. Hallyn" <serge@hallyn.com>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Jan Sebastian Götte" <linux@jaseg.de>,
	"Baoquan He" <baoquan.he@linux.dev>,
	"Oscar Salvador" <osalvador@suse.de>,
	"Liam R. Howlett" <liam@infradead.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Mike Rapoport" <rppt@kernel.org>,
	"Vlastimil Babka" <vbabka@kernel.org>,
	"Dev Jain" <dev.jain@arm.com>, "Zi Yan" <ziy@nvidia.com>,
	"David Howells" <dhowells@redhat.com>,
	"Alasdair Kergon" <agk@redhat.com>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"Joshua Hahn" <joshua.hahnjy@gmail.com>,
	"Alistair Popple" <apopple@nvidia.com>,
	"Dave Young" <ruirui.yang@linux.dev>,
	"Rik van Riel" <riel@surriel.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Lance Yang" <lance.yang@linux.dev>,
	"Nico Pache" <nico.pache@linux.dev>,
	"Usama Arif" <usama.arif@linux.dev>,
	"Jann Horn" <jannh@google.com>, "Barry Song" <baohua@kernel.org>,
	"Lorenzo Stoakes" <ljs@kernel.org>,
	"Pedro Falcato" <pfalcato@suse.de>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Mike Snitzer" <snitzer@kernel.org>,
	"James Morris" <jmorris@namei.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Harry Yoo" <harry@kernel.org>,
	"Pratyush Yadav" <pratyush@kernel.org>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Peter Xu" <peterx@redhat.com>,
	"Benjamin Marzinski" <bmarzins@redhat.com>,
	"Muchun Song" <muchun.song@linux.dev>,
	"Paul Moore" <paul@paul-moore.com>,
	"Baolin Wang" <baolin.wang@linux.alibaba.com>,
	"Byungchul Park" <byungchul@sk.com>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Jarkko Sakkinen" <jarkko@kernel.org>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Randy Dunlap" <rdunlap@infradead.org>,
	"Will Deacon" <will@kernel.org>, "Rob Herring" <robh@kernel.org>,
	"Mikulas Patocka" <mpatocka@redhat.com>,
	"Ryan Roberts" <ryan.roberts@arm.com>,
	"Gregory Price" <gourry@gourry.net>,
	"Ying Huang" <ying.huang@linux.alibaba.com>,
	"Pasha Tatashin" <pasha.tatashin@soleen.com>,
	"Mimi Zohar" <zohar@linux.ibm.com>,
	"Herbert Xu" <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	"James Bottomley" <James.Bottomley@HansenPartnership.com>,
	"Michal Hocko" <mhocko@suse.com>,
	"Saravana Kannan" <saravanak@kernel.org>,
	"David Hildenbrand" <david@kernel.org>,
	"Brendan Jackman" <brendan.jackman@linux.dev>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Kiryl Shutsemau" <kas@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org,
	"Eric Biggers" <ebiggers@kernel.org>,
	linux-integrity@vger.kernel.org, robh@kernel.org,
	linux-mm@kvack.org, linux-arch@vger.kernel.org,
	linux-kernel@vger.kernel.org, kexec@lists.infradead.org,
	linux-doc@vger.kernel.org, driver-core@lists.linux.dev,
	keyrings@vger.kernel.org, linux-security-module@vger.kernel.org,
	dm-devel@lists.linux.dev, devicetree@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, linux-crypto@vger.kernel.org,
	conor+dt@kernel.org
Subject: Re: [PATCH v3 09/12] mm/rmap: Mark folios mapped into crash_memaction-marked VMAs
Date: Mon, 28 Sep 2026 17:41:43 +0000	[thread overview]
Message-ID: <20260928174143.864EC1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260928-crash-memaction-upstream-20260921-v3-9-e511e9ee2329@jaseg.de>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] mm/userfaultfd: UFFDIO_MOVE misses crash_memaction registration for swap cache
- [Medium] mm: stale crash_memaction marks when moving pages to unmarked VMAs
- [Low] mm/rmap: data race on vma->vm_flags in crash_mark_pages()
--

commit 78115d9186907359bdb879efc1ef14d161aac39a
Author: Jan Sebastian Götte <linux@jaseg.de>
Subject: mm/rmap: Mark folios mapped into crash_memaction-marked VMAs

This patch propagates crash_memaction marks set through madvise() to the
crash_memaction registry. It registers folios of a VMA carrying VM_CRASH_MARK
as they are mapped, and updates the registry when a folio moves. It also hooks
into the free path to deregister pages and avoid tracking stale data.

> diff --git a/include/linux/crash_memaction.h b/include/linux/crash_memaction.h
> index 5f3e114c60ad7..2de60bc12dd9f 100644
> --- a/include/linux/crash_memaction.h
> +++ b/include/linux/crash_memaction.h
[ ... ]
> @@ -50,6 +51,18 @@ static inline void crash_memaction_unmark_pfns(unsigned long pfn,
>  		__crash_memaction_unmark_pfns(pfn, nr_pages);
>  }
>  
> +static inline void crash_mark_pages(struct page *page, int nr_pages,
> +		struct vm_area_struct *vma)
> +{
> +	if (!static_branch_unlikely(&crash_memaction_active))
> +		return;
> +
> +	if (likely(!(vma->vm_flags & VM_CRASH_MARK)))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Severity: Low]
Should this lockless read of vma->vm_flags use READ_ONCE()?

The crash_mark_pages() function is called via folio_add_anon_rmap_ptes()
during migration (such as in remove_migration_pte()) holding only the
anon_vma lock. At the same time, mprotect() can update vma->vm_flags
while holding the VMA lock, but not the anon_vma lock. 

Could this concurrent modification lead to a data race or torn reads during
migration?

> +		return;
> +
> +	__crash_memaction_mark_pfns(page_to_pfn(page), nr_pages);
> +}
> +
>  void crash_memaction_mark(void *addr, size_t size, int types);
>  void crash_memaction_unmark(void *addr, size_t size);
>  
[ ... ]
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 3fb9504dff7a9..adbda968d58ef 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -2966,6 +2966,8 @@ int move_pages_huge_pmd(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd, pm
>  
>  		folio_move_anon_rmap(src_folio, dst_vma);
>  		src_folio->index = linear_anon_page_index(dst_vma, dst_addr);
> +		/* No rmap add, and the two VMAs need not agree on the flag. */
> +		crash_mark_pages(&src_folio->page, HPAGE_PMD_NR, dst_vma);
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Severity: Medium]
How are stale crash_memaction marks handled when moving to an unmarked VMA?

If a process marks a VMA with MADV_CRASH_CACHE, then moves an exclusive
anonymous page to an unmarked VMA via mremap() here in
move_pages_huge_pmd(), the destination VMA is checked but the source VMA
is not unmarked.

Because the new VMA lacks the mark, a subsequent madvise(MADV_CRASH_RESET)
will short-circuit and fail to unmark the pages. Will these pages remain
permanently marked and excluded from kdump dumps until freed, potentially
risking data loss?

>  
>  		_dst_pmd = folio_mk_pmd(src_folio, dst_vma->vm_page_prot);
>  		/* Follow mremap() behavior and treat the entry dirty after the move */
[ ... ]
> diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
> index b242fa8b22c8c..bb0a35d59daa9 100644
> --- a/mm/userfaultfd.c
> +++ b/mm/userfaultfd.c
> @@ -1326,6 +1326,7 @@ static long move_present_ptes(struct mm_struct *mm,
>  
>  		folio_move_anon_rmap(src_folio, dst_vma);
>  		src_folio->index = linear_anon_page_index(dst_vma, dst_addr);
> +		crash_mark_pages(&src_folio->page, 1, dst_vma);
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Severity: Medium]
Similar to the mremap() case above, does move_present_ptes() fail to unmark
the PFN if the page came from a marked src_vma but is moving to an unmarked
dst_vma?

[Severity: Medium]
Are we missing crash_memaction registration for swap cache folios during
UFFDIO_MOVE?

While the rmap is updated for present PTEs with a crash_mark_pages() call
here, the parallel move_swap_pte() path in mm/userfaultfd.c seems to
omit it:

	if (src_folio) {
		folio_move_anon_rmap(src_folio, dst_vma);
		src_folio->index = linear_anon_page_index(dst_vma, dst_addr);
	} else {

If a process marks a VMA with MADV_CRASH_SECRET, and then uses UFFDIO_MOVE
to move a swapped-out but swapcache-resident page into this VMA, the page
registration is skipped. If the system crashes before the page is faulted
in, is there a risk that the kdump kernel will dump the unmarked RAM and
leak the secret data?

>  
>  		orig_dst_pte = folio_mk_pte(src_folio, dst_vma->vm_page_prot);
>  		/* Set soft dirty bit so userspace can notice the pte was moved */

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260928-crash-memaction-upstream-20260921-v3-0-e511e9ee2329@jaseg.de?part=9

  reply	other threads:[~2026-09-28 17:41 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28 17:17 [PATCH v3 00/12] CRASH_MEMACTION: describe pages to a kdump kernel (was: CRASH_WIPE_SECRETS) Jan Sebastian Götte
2026-09-28 17:17 ` [PATCH v3 01/12] kexec: Add a crash memaction registry Jan Sebastian Götte
2026-09-28 17:36   ` sashiko-bot
2026-09-28 17:17 ` [PATCH v3 02/12] lib, kexec: Add a secret pool for key material Jan Sebastian Götte
2026-09-28 17:36   ` sashiko-bot
2026-09-28 17:17 ` [PATCH v3 03/12] mm: Wire up the crash memaction registry Jan Sebastian Götte
2026-09-28 17:38   ` sashiko-bot
2026-09-28 17:17 ` [PATCH v3 04/12] arm64: Enable " Jan Sebastian Götte
2026-09-28 17:35   ` sashiko-bot
2026-09-28 17:17 ` [PATCH v3 05/12] dm crypt: Allocate key material from the secret pool Jan Sebastian Götte
2026-09-28 17:33   ` sashiko-bot
2026-09-28 17:17 ` [PATCH v3 06/12] crypto: api - Allocate tfms " Jan Sebastian Götte
2026-09-28 17:32   ` sashiko-bot
2026-09-28 17:17 ` [PATCH v3 07/12] security/keys: Allocate key payloads " Jan Sebastian Götte
2026-09-28 17:32   ` sashiko-bot
2026-09-28 17:17 ` [PATCH v3 08/12] mm: Add VM_CRASH_MARK Jan Sebastian Götte
2026-09-28 17:34   ` sashiko-bot
2026-09-28 17:17 ` [PATCH v3 09/12] mm/rmap: Mark folios mapped into crash_memaction-marked VMAs Jan Sebastian Götte
2026-09-28 17:41   ` sashiko-bot [this message]
2026-09-28 17:17 ` [PATCH v3 10/12] mm/madvise: Add MADV_CRASH_SECRET, MADV_CRASH_CACHE and MADV_CRASH_RESET Jan Sebastian Götte
2026-09-28 17:35   ` sashiko-bot
2026-09-28 17:17 ` [PATCH v3 11/12] Documentation/mm: Document the crash memaction registry Jan Sebastian Götte
2026-09-28 17:31   ` sashiko-bot
2026-09-28 17:18 ` [PATCH v3 12/12] kexec: Expose the crash memaction bitmap in debugfs Jan Sebastian Götte
2026-09-28 17:38   ` sashiko-bot
2026-09-28 19:19   ` Randy Dunlap
2026-09-28 17:49 ` [PATCH v3 00/12] CRASH_MEMACTION: describe pages to a kdump kernel (was: CRASH_WIPE_SECRETS) Lorenzo Stoakes (ARM)
2026-09-28 18:58   ` David Hildenbrand (Arm)
2026-09-28 19:02 ` 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=20260928174143.864EC1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=agk@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=arnd@arndb.de \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=baoquan.he@linux.dev \
    --cc=bmarzins@redhat.com \
    --cc=brendan.jackman@linux.dev \
    --cc=byungchul@sk.com \
    --cc=catalin.marinas@arm.com \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=dakr@kernel.org \
    --cc=davem@davemloft.net \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dhowells@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=driver-core@lists.linux.dev \
    --cc=ebiggers@kernel.org \
    --cc=gourry@gourry.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=harry@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=jannh@google.com \
    --cc=jarkko@kernel.org \
    --cc=jmorris@namei.org \
    --cc=joshua.hahnjy@gmail.com \
    --cc=kas@kernel.org \
    --cc=kexec@lists.infradead.org \
    --cc=keyrings@vger.kernel.org \
    --cc=lance.yang@linux.dev \
    --cc=liam@infradead.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linux@jaseg.de \
    --cc=ljs@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=matthew.brost@intel.com \
    --cc=mhocko@suse.com \
    --cc=mpatocka@redhat.com \
    --cc=muchun.song@linux.dev \
    --cc=nico.pache@linux.dev \
    --cc=osalvador@suse.de \
    --cc=pasha.tatashin@soleen.com \
    --cc=paul@paul-moore.com \
    --cc=peterx@redhat.com \
    --cc=pfalcato@suse.de \
    --cc=pratyush@kernel.org \
    --cc=rafael@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=riel@surriel.com \
    --cc=robh@kernel.org \
    --cc=rppt@kernel.org \
    --cc=ruirui.yang@linux.dev \
    --cc=ryan.roberts@arm.com \
    --cc=saravanak@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=serge@hallyn.com \
    --cc=skhan@linuxfoundation.org \
    --cc=snitzer@kernel.org \
    --cc=surenb@google.com \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=will@kernel.org \
    --cc=ying.huang@linux.alibaba.com \
    --cc=ziy@nvidia.com \
    --cc=zohar@linux.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.