Skip to content

Commit bdc7f8c

Browse files
committed
Merge tag 'mm-stable-2025-06-06-16-09' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull more MM updates from Andrew Morton: "The series 'Fix uprobe pte be overwritten when expanding vma' fixes a longstanding and quite obscure bug related to the vma merging of the uprobe mmap page" * tag 'mm-stable-2025-06-06-16-09' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: selftests/mm: add test about uprobe pte be orphan during vma merge selftests/mm: extract read_sysfs and write_sysfs into vm_util mm: expose abnormal new_pte during move_ptes mm: fix uprobe pte be overwritten when expanding vma mm/damon: s/primitives/code/ on comments
2 parents d3c82f6 + efe99fa commit bdc7f8c

File tree

16 files changed

+122
-44
lines changed

16 files changed

+122
-44
lines changed

mm/damon/modules-common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
3-
* Common Primitives for DAMON Modules
3+
* Common Code for DAMON Modules
44
*
55
* Author: SeongJae Park <sj@kernel.org>
66
*/

mm/damon/modules-common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
/*
3-
* Common Primitives for DAMON Modules
3+
* Common Code for DAMON Modules
44
*
55
* Author: SeongJae Park <sj@kernel.org>
66
*/

mm/damon/ops-common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
3-
* Common Primitives for Data Access Monitoring
3+
* Common Code for Data Access Monitoring
44
*
55
* Author: SeongJae Park <sj@kernel.org>
66
*/

mm/damon/ops-common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
/*
3-
* Common Primitives for Data Access Monitoring
3+
* Common Code for Data Access Monitoring
44
*
55
* Author: SeongJae Park <sj@kernel.org>
66
*/

mm/damon/paddr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
3-
* DAMON Primitives for The Physical Address Space
3+
* DAMON Code for The Physical Address Space
44
*
55
* Author: SeongJae Park <sj@kernel.org>
66
*/

mm/damon/sysfs-common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
3-
* Common Primitives for DAMON Sysfs Interface
3+
* Common Code for DAMON Sysfs Interface
44
*
55
* Author: SeongJae Park <sj@kernel.org>
66
*/

mm/damon/sysfs-common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
/*
3-
* Common Primitives for DAMON Sysfs Interface
3+
* Common Code for DAMON Sysfs Interface
44
*
55
* Author: SeongJae Park <sj@kernel.org>
66
*/

mm/damon/vaddr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
3-
* DAMON Primitives for Virtual Address Spaces
3+
* DAMON Code for Virtual Address Spaces
44
*
55
* Author: SeongJae Park <sj@kernel.org>
66
*/

mm/mremap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ static int move_ptes(struct pagetable_move_control *pmc,
237237

238238
for (; old_addr < old_end; old_pte++, old_addr += PAGE_SIZE,
239239
new_pte++, new_addr += PAGE_SIZE) {
240+
VM_WARN_ON_ONCE(!pte_none(*new_pte));
241+
240242
if (pte_none(ptep_get(old_pte)))
241243
continue;
242244

mm/vma.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ static void init_multi_vma_prep(struct vma_prepare *vp,
169169
vp->file = vma->vm_file;
170170
if (vp->file)
171171
vp->mapping = vma->vm_file->f_mapping;
172+
173+
if (vmg && vmg->skip_vma_uprobe)
174+
vp->skip_vma_uprobe = true;
172175
}
173176

174177
/*
@@ -358,10 +361,13 @@ static void vma_complete(struct vma_prepare *vp, struct vma_iterator *vmi,
358361

359362
if (vp->file) {
360363
i_mmap_unlock_write(vp->mapping);
361-
uprobe_mmap(vp->vma);
362364

363-
if (vp->adj_next)
364-
uprobe_mmap(vp->adj_next);
365+
if (!vp->skip_vma_uprobe) {
366+
uprobe_mmap(vp->vma);
367+
368+
if (vp->adj_next)
369+
uprobe_mmap(vp->adj_next);
370+
}
365371
}
366372

367373
if (vp->remove) {
@@ -1830,6 +1836,14 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
18301836
faulted_in_anon_vma = false;
18311837
}
18321838

1839+
/*
1840+
* If the VMA we are copying might contain a uprobe PTE, ensure
1841+
* that we do not establish one upon merge. Otherwise, when mremap()
1842+
* moves page tables, it will orphan the newly created PTE.
1843+
*/
1844+
if (vma->vm_file)
1845+
vmg.skip_vma_uprobe = true;
1846+
18331847
new_vma = find_vma_prev(mm, addr, &vmg.prev);
18341848
if (new_vma && new_vma->vm_start < addr + len)
18351849
return NULL; /* should never get here */

0 commit comments

Comments
 (0)