lkml.org 
[lkml]   [2008]   [Sep]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] cgroups: fix probable race with put_css_set[_taskexit] and find_css_set
On Tue, Sep 09, 2008 at 10:31:24PM -0700, Paul Menage wrote:
> On Tue, Sep 9, 2008 at 10:01 PM, Greg KH <greg@kroah.com> wrote:
> >
> > What are you trying to solve here with this change? I agree, it does
> > seem a bit "chaotic" :)
>
> There's a place in cgroups that uses kref_put() to release an object;
> the release function *then* takes a write-lock and removes the object
> from a lookup table; it could race with another thread that searches
> the lookup table (while holding a read-lock) and does kref_get() on
> the same object.

Ick, yeah that's not good.

What about the way everyone else solves this, grab the lock before you
call kref_put()?

> The current fix is for the release function to recheck inside the lock
> that the object's refcount is still zero, and only actually
> unlink/free it if so. And actually I've just realised that this isn't
> actually even safe, since the thread that just acquired the object
> could kref_put() it almost immediately, which would leave two threads
> both trying to unlink/free the object.

Yeah, don't do that :)

thanks,

greg k-h


\
 
 \ /
  Last update: 2008-09-10 08:21    [W:0.203 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site