Re: [PATCH RFC 07/11] mm/mremap: use ptep_get() for the destination PTE

Muhammad Usama Anjum <[email protected]> Thu, 30 Jul 2026 13:59:24 +0100
Newsgroups org.kernel.vger.linux-parisc,dev.linux.lists.damon,org.freedesktop.lists.dri-devel,org.freedesktop.lists.intel-gfx,org.kernel.vger.bpf,org.kernel.vger.linux-arch,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-perf-users,org.kernel.vger.linux-trace-kernel,org.kvack.linux-mm,org.xenproject.lists.xen-devel
Message-ID <[email protected]>
On 30/07/2026 12:29 pm, Alexander Gordeev wrote:
> On Mon, Jul 27, 2026 at 05:46:58PM +0100, Muhammad Usama Anjum wrote:
>> move_ptes() directly dereferences new_ptep when checking that the
>> destination slot is empty. new_ptep now points to hw_pte_t table storage,
>> while pte_none() consumes a logical pte_t value.
>>
>> Read the destination entry through the standard ptep_get() accessor before
>> passing the logical value to pte_none().
>>
>> Signed-off-by: Muhammad Usama Anjum <[email protected]>
>> ---
>>  mm/mremap.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/mremap.c b/mm/mremap.c
>> index d966ee8248b6b..ecb90ccee6fdd 100644
>> --- a/mm/mremap.c
>> +++ b/mm/mremap.c
>> @@ -264,7 +264,7 @@ static int move_ptes(struct pagetable_move_control *pmc,
>>  
>>  	for (; old_addr < old_end; old_ptep += nr_ptes, old_addr += nr_ptes * PAGE_SIZE,
>>  		new_ptep += nr_ptes, new_addr += nr_ptes * PAGE_SIZE) {
>> -		VM_WARN_ON_ONCE(!pte_none(*new_ptep));
>> +		VM_WARN_ON_ONCE(!pte_none(ptep_get(new_ptep)));
> 
> Same as the previous patch, except that I did it already:
> https://lore.kernel.org/linux-mm/[email protected]/
I'll drop this patch.

> 
>>  
>>  		nr_ptes = 1;
>>  		max_nr_ptes = (old_end - old_addr) >> PAGE_SHIFT;
>> -- 
>> 2.47.3
>>

-- 
Thanks,
Usama