[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <57533126-eb30-4b56-bc4d-2f27514ae5ad@huaweicloud.com>
Date: Tue, 27 May 2025 21:38:03 +0800
From: Pu Lehui <pulehui@...weicloud.com>
To: David Hildenbrand <david@...hat.com>, Oleg Nesterov <oleg@...hat.com>
Cc: lorenzo.stoakes@...cle.com, mhiramat@...nel.org, peterz@...radead.org,
Liam.Howlett@...cle.com, akpm@...ux-foundation.org, vbabka@...e.cz,
jannh@...gle.com, pfalcato@...e.de, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, pulehui@...wei.com
Subject: Re: [RFC PATCH] mm/mmap: Fix uprobe anon page be overwritten when
expanding vma during mremap
Hi David,
On 2025/5/27 2:46, David Hildenbrand wrote:
> On 26.05.25 17:48, Oleg Nesterov wrote:
>> Hi Lehui,
>>
>> As I said, I don't understand mm/, so can't comment, but...
>>
>> On 05/26, Pu Lehui wrote:
>>>
>>> To make things simpler, perhaps we could try post-processing, that is:
>>>
>>> diff --git a/mm/mremap.c b/mm/mremap.c
>>> index 83e359754961..46a757fd26dc 100644
>>> --- a/mm/mremap.c
>>> +++ b/mm/mremap.c
>>> @@ -240,6 +240,11 @@ static int move_ptes(struct pagetable_move_control
>>> *pmc,
>>> if (pte_none(ptep_get(old_pte)))
>>> continue;
>>>
>>> + /* skip move pte when expanded range has uprobe */
>>> + if (unlikely(pte_present(*new_pte) &&
>>> + vma_has_uprobes(pmc->new, new_addr,
>>> new_addr +
>>> PAGE_SIZE)))
>>> + continue;
>>> +
>>
>> I was thinking about
>>
>> WARN_ON(!pte_none(*new_pte))
>>
>> at the start of the main loop.
>>
>> Obviously not to fix the problem, but rather to make it more explicit.
>
> Yeah, WARN_ON_ONCE().
>
> We really should fix the code to not install uprobes into the area we
> are moving.
Alright, so let's try this direction.
>
> Likely, the correct fix will be to pass the range as well to
> uprobe_mmap(), and passing that range to build_probe_list().
It will be great. But IIUC, the range we expand to is already included
when entering uprobe_mmap and also build_probe_list.
copy_vma
vma_merge_new_range
vma_expand
commit_merge
vma_set_range(vma, vmg->start, vmg->end, vmg->pgoff);
vmg_adjust_set_range(vmg); <-- adjust with new range
vma_complete
uprobe_mmap
move_page_tables
move_ptes
set_pte_at(mm, new_addr, new_pte, pte);
>
> Only when growing using mremap(), we want to call it on the extended
> range only.
>
Powered by blists - more mailing lists