From: David Hildenbrand <david@redhat.com>
To: Oleg Nesterov <oleg@redhat.com>,
Pu Lehui <pulehui@huaweicloud.com>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: mhiramat@kernel.org, peterz@infradead.org,
akpm@linux-foundation.org, Liam.Howlett@oracle.com,
vbabka@suse.cz, jannh@google.com, pfalcato@suse.de,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
pulehui@huawei.com, Andrii Nakryiko <andrii@kernel.org>,
Jiri Olsa <jolsa@kernel.org>
Subject: Re: [RFC PATCH] mm/mmap: Fix uprobe anon page be overwritten when expanding vma during mremap
Date: Sat, 24 May 2025 23:45:46 +0200 [thread overview]
Message-ID: <e8a679eb-e40c-481d-b65a-d16f9e66c19a@redhat.com> (raw)
In-Reply-To: <20250524164516.GA11642@redhat.com>
On 24.05.25 18:45, Oleg Nesterov wrote:
> I am very glad that mm experts are already looking into this problem ;)
> I can't help, today I don't understand mm/vma.c even remotely. But let
> me ask a couple of stupid questions.
>
>> However, the
>> upcomming move_page_tables step, which use set_pte_at to remap the vma2
>> uprobe anon page to the merged vma, will over map the old uprobe anon
>> page in the merged vma, and lead the old uprobe anon page to be orphan.
>
> To be honest, I can't even understand this part due to my ignorance.
> What does "the old uprobe anon page to be orphan" actually mean?
> How can the unnecessary uprobe_mmap() lead to an "unbalanced"
> inc_mm_counter(MM_ANONPAGES) ? Or what else can explain the
> "BUG: Bad rss-counter state" from check_mm() ? Or there are more problems?
Essentially, we end up mapping an anonymous page (when install the
uprobe) after preparing the new VMA, but before moving over the pages
from the old VMA.
So when we then move over the pages from the old VMA, we overwrite the
PTE mapping an anonymous page (due to uprobe).
As we simply overwrite the PTE that is mapping an anonymous page, we run
into inconsistency later: RSS counter mismatch, memory leak, etc.
We should never be installing an anonymous page (due to uprobe) into a
VMA during mremap() before moving over the pages from the old VMA.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-05-24 21:45 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-21 9:25 [RFC PATCH] mm/mmap: Fix uprobe anon page be overwritten when expanding vma during mremap Pu Lehui
2025-05-21 10:25 ` David Hildenbrand
2025-05-22 14:37 ` Pu Lehui
2025-05-22 15:14 ` David Hildenbrand
2025-05-26 14:52 ` Pu Lehui
2025-05-26 15:48 ` Oleg Nesterov
2025-05-26 18:46 ` David Hildenbrand
2025-05-27 11:42 ` Lorenzo Stoakes
2025-05-27 11:44 ` Lorenzo Stoakes
2025-05-27 13:39 ` Pu Lehui
2025-05-27 13:38 ` Pu Lehui
2025-05-28 9:03 ` David Hildenbrand
2025-05-29 16:07 ` Pu Lehui
2025-05-30 8:33 ` David Hildenbrand
2025-05-30 8:41 ` Lorenzo Stoakes
2025-05-30 8:50 ` David Hildenbrand
2025-05-30 9:03 ` Lorenzo Stoakes
2025-05-30 9:27 ` David Hildenbrand
2025-05-30 18:09 ` Oleg Nesterov
2025-05-30 18:34 ` David Hildenbrand
2025-05-30 22:48 ` Pu Lehui
2025-05-27 13:23 ` Pu Lehui
2025-05-21 13:13 ` Lorenzo Stoakes
2025-05-22 15:00 ` Pu Lehui
2025-05-22 15:18 ` Lorenzo Stoakes
2025-05-24 16:45 ` Oleg Nesterov
2025-05-24 21:45 ` David Hildenbrand [this message]
2025-05-25 9:59 ` Oleg Nesterov
2025-05-25 10:24 ` David Hildenbrand
2025-05-26 16:29 ` Oleg Nesterov
2025-05-26 17:38 ` Oleg Nesterov
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=e8a679eb-e40c-481d-b65a-d16f9e66c19a@redhat.com \
--to=david@redhat.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=andrii@kernel.org \
--cc=jannh@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhiramat@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=pfalcato@suse.de \
--cc=pulehui@huawei.com \
--cc=pulehui@huaweicloud.com \
--cc=vbabka@suse.cz \
/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;
as well as URLs for NNTP newsgroup(s).