All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: shaos <shawnq1@163.com>, Kiryl Shutsemau <kas@kernel.org>
Cc: akpm@linux-foundation.org, Peter Xu <peterx@redhat.com>,
	Liam Howlett <liam@infradead.org>,
	Lorenzo Stoakes <ljs@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [BUG] mm: mremap merge clears RWP state from an untouched neighbor
Date: Tue, 20 Oct 2026 19:34:19 +0300	[thread overview]
Message-ID: <ateYC2eXPHuy3HK1@kernel.org> (raw)
In-Reply-To: <20261020110748.959870-1-shawnq1@163.com>

(adding Kiryl)

On Tue, Oct 20, 2026 at 11:07:48AM +0000, shaos wrote:
> Hello,
> 
> An adjacent mremap() can remove userfaultfd RWP handling from a
> neighboring VMA that was not moved. The moved VMA and the existing
> neighbor use the same userfaultfd context, and UFFD_FEATURE_EVENT_REMAP
> is not negotiated. When the destination merges into the neighbor,
> mremap_userfaultfd_prep() resets the context on the expanded VMA,
> including the neighbor.
> 
> The neighbor's PTE remains PAGE_NONE with _PAGE_UFFD, but the VMA loses
> VM_UFFD_RWP. A read that delivered UFFD_PAGEFAULT_FLAG_RWP before the
> move then completes without an event. The same-mm PoC reproduces this on
> two fresh boots. No-move and nonadjacent-move controls retain the RWP
> event.
> 
> HEAD commit:    24a19b953e2a3d0ea5a8c4951a0ab8f32720c907
> source version: Linux 7.3.0-rc7
> architecture:   x86-64
> compiler:       gcc 11.4.0, GNU ld 2.38
> QEMU:           6.2.0
> 
> console output: https://gist.githubusercontent.com/shaos26/3b44971d9385a0cd18cfbf2e9bd730c6/raw/368568c2dd47417b54a957c8d9cc09f77f28b236/console-output.txt
> kernel config: https://gist.githubusercontent.com/shaos26/3b44971d9385a0cd18cfbf2e9bd730c6/raw/4989bc843fa61b5eaaaa53422238ec39e4356b70/kernel-config.txt
> reproducer: https://gist.githubusercontent.com/shaos26/3b44971d9385a0cd18cfbf2e9bd730c6/raw/109dc86c28debcaca07aedb2d450ed1e95ae5edf/poc.c
> 
> Build the kernel from the revision above with the attached config. Build
> poc.c statically with pthread support and place it at /init in a minimal
> initramfs. The positive run and controls use:
> 
>     timeout 180 qemu-system-x86_64 -accel tcg,thread=multi -cpu max \
>         -m 1024 -smp 2 -machine q35 -nodefaults \
>         -kernel build/arch/x86/boot/bzImage -initrd initramfs.cpio.gz \
>         -append "console=ttyS0 panic=-1 oops=panic loglevel=7 rwp.mode=positive" \
>         -display none -serial stdio -monitor none -no-reboot
> 
> Use rwp.mode=no_move and rwp.mode=nonadjacent for the controls. The
> positive oracle is PRECHECK fault flags=0x8 followed by POST no_event
> value=0x41 and RESULT=RWP_NEIGHBOR_ESCAPE_CONFIRMED. This is a
> userfaultfd tracking defect; no privilege escalation or cross-process
> access is demonstrated. I checked upstream master f47d223627f8; the
> relevant mremap/userfaultfd logic is unchanged there, but runtime
> validation was on v7.3-rc7.
> 
> Thanks,
> 
> shaos
> 

-- 
Sincerely yours,
Mike.


  parent reply	other threads:[~2026-10-20 16:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 11:07 [BUG] mm: mremap merge clears RWP state from an untouched neighbor shaos
2026-10-20 13:29 ` Lorenzo Stoakes (ARM)
2026-10-20 16:34 ` Mike Rapoport [this message]
2026-10-20 16:46   ` Lorenzo Stoakes (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=ateYC2eXPHuy3HK1@kernel.org \
    --to=rppt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=kas@kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=peterx@redhat.com \
    --cc=shawnq1@163.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.