Thread (3 messages) 3 messages, 3 authors, 2024-09-02

Re: [PATCH v2 1/4] mm: Add optional close() to struct vm_special_mapping

From: Andrew Morton <akpm@linux-foundation.org>
Date: 2024-09-02 20:49:55
Also in: linux-mm, linux-s390, linux-um, lkml

Possibly related (same subject, not in this thread)

On Mon, 02 Sep 2024 21:06:48 +0200 Sven Schnelle [off-list ref] wrote:
quoted hunk ↗ jump to hunk
So uprobe_clear_state() in the beginning free's the memory area
containing the vm_special_mapping data, but exit_mmap() uses this
address later via vma->vm_private_data (which was set in _install_special_mapping().

The following change fixes this for me, but i'm not sure about any side
effects:
diff --git a/kernel/fork.c b/kernel/fork.c
index df8e4575ff01..cfcabba36c93 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1340,11 +1340,11 @@ static inline void __mmput(struct mm_struct *mm)
 {
        VM_BUG_ON(atomic_read(&mm->mm_users));
 
-       uprobe_clear_state(mm);
        exit_aio(mm);
        ksm_exit(mm);
        khugepaged_exit(mm); /* must run before exit_mmap */
        exit_mmap(mm);
+       uprobe_clear_state(mm);
        mm_put_huge_zero_folio(mm);
        set_mm_exe_file(mm, NULL);
        if (!list_empty(&mm->mmlist)) {
uprobe_clear_state() is a pretty simple low-level thing.  Side-effects
seem unlikely?  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help