lkml.org 
[lkml]   [2014]   [Feb]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] kref: oops on zero or negative refcount
On 02/20/2014 01:14 PM, Dave Jones wrote:
> On Thu, Feb 20, 2014 at 06:44:59PM +0100, Mateusz Guzik wrote:
> > In use after free situations, it is possible for one thread to write to
> > memory that has just been reallocated to a new user. This could open up
> > potential security issues.
> >
> > diff --git a/include/linux/kref.h b/include/linux/kref.h
> > index 484604d..c3f8a0a 100644
> > --- a/include/linux/kref.h
> > +++ b/include/linux/kref.h
> > @@ -43,8 +43,10 @@ static inline void kref_get(struct kref *kref)
> > /* If refcount was 0 before incrementing then we have a race
> > * condition when this kref is freeing by some other thread right now.
> > * In this case one should use kref_get_unless_zero()
> > + *
> > + * Terminate the current thread to stop potential security exploits.
> > */
> > - WARN_ON_ONCE(atomic_inc_return(&kref->refcount) < 2);
> > + BUG_ON(atomic_inc_return(&kref->refcount) < 2);
>
> This isn't "terminating the thread", this is "lock up the box".

Only if kref_get holds a lock while encountering a refcount
underflow, right?

--
All rights reversed


\
 
 \ /
  Last update: 2014-02-20 20:01    [W:0.069 / U:0.268 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site