mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Mika Penttilä" <mpenttil@redhat.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/hmm: account for subpage offsets in device-private PMDs
Date: Sun, 22 Nov 2026 18:32:19 +0200	[thread overview]
Message-ID: <b447c087-292a-400f-8082-56d509f6a9b8@redhat.com> (raw)
In-Reply-To: <179535872126.34.4789080961796247940.b4-reply@b4>


On 11/22/26 16:45, Aveline Noir wrote:

> Hi Andrew,
>
> On Sun, 22 Nov 2026 01:52:46 -0800 Andrew Morton wrote:
>
>> Store the corresponding RAM backing page instead.
> This avoids the oops on the first read through the second descriptor,
> but leaves a stale backing page pointer after CPU faultback.
>
> Since the mirror XArray entries don't take a page reference, they rely
> on invalidation.  When the CPU later faults the page back to RAM,
> dmirror_interval_invalidate() skips MMU_NOTIFY_MIGRATE for the same
> mdevice, and dmirror_devmem_fault_alloc_and_copy() only clears the
> migrating descriptor's entry before the backing folio is freed.  The
> second descriptor still points to that freed backing page.
>
> Reading the same page again through the second descriptor in QEMU
> triggers a KASAN use-after-free in dmirror_do_read(), and the read
> returns the stale data instead of what the CPU wrote.

I think this is right, but a fairly artificial scenario: it needs two
descriptors open on the same test device in one test, a migration through one,
a read through the other, a CPU fault back, and then another read through
the second descriptor..

The fix lets the device private page content be read without an oops
in the context of one fd which is an improvement. 

> The second descriptor's entry probably needs to be invalidated before
> the backing page is freed, and it'd be nice to cover a second read
> after faultback in the selftest too.
>
> Thanks,
> Aveline Noir

--Mika



  reply	other threads:[~2026-11-22 16:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-31  4:07 Aveline Noir
2026-11-22  0:00 ` Andrew Morton
2026-11-22  5:55   ` Mika Penttilä
2026-11-22  9:52     ` Andrew Morton
2026-11-22 12:04       ` Mika Penttilä
2026-11-22 14:45       ` Aveline Noir
2026-11-22 16:32         ` Mika Penttilä [this message]
2026-11-22 16:41         ` Mika Penttilä
2026-11-22 17:14           ` Andrew Morton
2026-11-22 17:37             ` Mika Penttilä

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=b447c087-292a-400f-8082-56d509f6a9b8@redhat.com \
    --to=mpenttil@redhat.com \
    --cc=linux-kernel@vger.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

all inboxes | Powered by JetHome®