From: Rafael Aquini <aquini@redhat.com>
To: Rik van Riel <riel@redhat.com>
Cc: Dave Jones <davej@redhat.com>, Mateusz Guzik <mguzik@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kref: oops on zero or negative refcount
Date: Fri, 21 Feb 2014 09:21:02 -0300 [thread overview]
Message-ID: <20140221122101.GA10170@localhost.localdomain> (raw)
In-Reply-To: <530646C8.1070206@redhat.com>
On Thu, Feb 20, 2014 at 01:17:44PM -0500, Rik van Riel wrote:
> 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?
>
Yes, and in a quick glance through the tree it seems we have several
codesites where we can find such condition likely to happen,
unfortunately.
next prev parent reply other threads:[~2014-02-21 12:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-20 17:44 [PATCH] kref: oops on zero or negative refcount Mateusz Guzik
2014-02-20 18:14 ` Dave Jones
2014-02-20 18:17 ` Rik van Riel
2014-02-21 12:21 ` Rafael Aquini [this message]
2014-02-21 12:05 ` Mateusz Guzik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140221122101.GA10170@localhost.localdomain \
--to=aquini@redhat.com \
--cc=davej@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mguzik@redhat.com \
--cc=riel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.