Messages in this thread | | | Date | Fri, 12 Apr 2013 17:11:30 -0700 | Subject | Re: [PATCH] module: Fix race condition between load and unload module | From | Linus Torvalds <> |
| |
On Fri, Apr 12, 2013 at 4:53 PM, Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote: > > Linus, I think your patch will reduce the window the race could happen, > but it should still be there, although testing with it would be > interesting to see if the original problem can be triggered with it.
Well, with my patch, there's no way you'll ever look up an object with a zero refcount, so you'll never release it twice. The atomic operations (atomic_inc_nonzero()) do guarantee that.
The "kset->list_lock" means that the list traversal is safe too.
So one particular race is definitely gone.
Now, what people who call "kset_find_obj()" really expect when not locked against the last kobject_put(), I don't know. But at least it's conceptually safe now. They'll either get NULL (either because the object doesn't exist on the list, or because it does exist but is about to be removed), or they will get a valid object that has *not* started to be torn down yet.
Linus
| |