lkml.org 
[lkml]   [2008]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[PATCH 03 of 12] get_task_mm should not succeed if mmput() is running and has reduced
    Date
    From
    # HG changeset patch
    # User Andrea Arcangeli <andrea@qumranet.com>
    # Date 1208872186 -7200
    # Node ID a6672bdeead0d41b2ebd6846f731d43a611645b7
    # Parent 3c804dca25b15017b22008647783d6f5f3801fa9
    get_task_mm should not succeed if mmput() is running and has reduced
    the mm_users count to zero. This can occur if a processor follows
    a tasks pointer to an mm struct because that pointer is only cleared
    after the mmput().

    If get_task_mm() succeeds after mmput() reduced the mm_users to zero then
    we have the lovely situation that one portion of the kernel is doing
    all the teardown work for an mm while another portion is happily using
    it.

    Signed-off-by: Christoph Lameter <clameter@sgi.com>

    diff --git a/kernel/fork.c b/kernel/fork.c
    --- a/kernel/fork.c
    +++ b/kernel/fork.c
    @@ -442,7 +442,8 @@
    if (task->flags & PF_BORROWED_MM)
    mm = NULL;
    else
    - atomic_inc(&mm->mm_users);
    + if (!atomic_inc_not_zero(&mm->mm_users))
    + mm = NULL;
    }
    task_unlock(task);
    return mm;

    \
     
     \ /
      Last update: 2008-04-22 16:15    [W:3.207 / U:0.784 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site