cgroups: fix probable race with put_css_set[_taskexit] and find_css_set

Previous thread: coredump: format_corename: don't append .%pid if multi-threaded by Linux Kernel Mailing List on Monday, October 20, 2008 - 10:04 am. (1 message)

Next thread: memcg: atomic ops for page_cgroup->flags by Linux Kernel Mailing List on Monday, October 20, 2008 - 10:04 am. (1 message)
From: Linux Kernel Mailing List
Date: Monday, October 20, 2008 - 10:03 am

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=146aa1...
Commit:     146aa1bd0511f88ddb4e92fafa2b8aad4f2f65f3
Parent:     248736c2a57206388c86f8cdd3392ee986e84f9f
Author:     Lai Jiangshan <laijs@cn.fujitsu.com>
AuthorDate: Sat Oct 18 20:28:03 2008 -0700
Committer:  Linus Torvalds <torvalds@linux-foundation.org>
CommitDate: Mon Oct 20 08:52:38 2008 -0700

    cgroups: fix probable race with put_css_set[_taskexit] and find_css_set
    
    put_css_set_taskexit may be called when find_css_set is called on other
    cpu.  And the race will occur:
    
    put_css_set_taskexit side                    find_css_set side
    
                                            |
    atomic_dec_and_test(&kref->refcount)    |
        /* kref->refcount = 0 */            |
    ....................................................................
                                            |  read_lock(&css_set_lock)
                                            |  find_existing_css_set
                                            |  get_css_set
                                            |  read_unlock(&css_set_lock);
    ....................................................................
    __release_css_set                       |
    ....................................................................
                                            | /* use a released css_set */
                                            |
    
    [put_css_set is the same. But in the current code, all put_css_set are
    put into cgroup mutex critical region as the same as find_css_set.]
    
    [akpm@linux-foundation.org: repair comments]
    [menage@google.com: eliminate race in css_set refcounting]
    Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
    Cc: Balbir Singh <balbir@in.ibm.com>
    Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
    Signed-off-by: Paul Menage <menage@google.com>
    Signed-off-by: Andrew ...
Previous thread: coredump: format_corename: don't append .%pid if multi-threaded by Linux Kernel Mailing List on Monday, October 20, 2008 - 10:04 am. (1 message)

Next thread: memcg: atomic ops for page_cgroup->flags by Linux Kernel Mailing List on Monday, October 20, 2008 - 10:04 am. (1 message)