From: Greg KH <gregkh@linuxfoundation.org>
To: David Windsor <dwindsor@gmail.com>
Cc: Roland Dreier <roland@purestorage.com>,
Djalal Harouni <tixxdz@opendz.org>,
Vasiliy Kulikov <segoon@openwall.com>,
kernel-hardening@lists.openwall.com,
Kees Cook <keescook@chromium.org>,
Ubuntu security discussion <ubuntu-hardened@lists.ubuntu.com>,
linux-kernel@vger.kernel.org, pageexec@freemail.hu,
spender@grsecurity.net
Subject: Re: [kernel-hardening] Re: Add overflow protection to kref
Date: Fri, 24 Feb 2012 10:37:26 -0800 [thread overview]
Message-ID: <20120224183726.GB23284@kroah.com> (raw)
In-Reply-To: <CAEXv5_jYj=cHsePJEf4f08KsBOfU+MVMnV0DucmVKQbg+KbxrQ@mail.gmail.com>
On Fri, Feb 24, 2012 at 12:58:35PM -0500, David Windsor wrote:
> <snip>
>
> >> Greg, I'm not sure why you're opposed to adding this checking...
> >> it's pretty clear that buggy error paths that forget to do a put are
> >> pretty common and will continue to be common in new code, and
> >> making them harder to exploit seems pretty sane to me.
> >>
> >> What's the downside?
> >
> > The downside is that there has not even been a patch sent for any of
> > this. Combine that with a lack of understanding about reference
> > counting and atomic_t usages in the kernel, and the whole thing is ripe
> > for misunderstanding and confusion.
> >
> > greg k-h
>
> This approach to adding overflow protection to kref uses
> atomic_add_unless to increment the refcounter only if it is not
> already at INT_MAX. This
> leaks the internal representation of atomic_t, which is defined as an
> int in linux/types.h, into kref.
>
> If we can agree on an approach to adding overflow protection, if it is
> indeed desired, we can then discuss adding a Kconfig option and/or a
> sysctl for this protection.
>
> Thanks,
> David
>
>
> Signed-off-by: David Windsor <dwindsor@gmail.com>
> ---
> include/linux/kref.h | 6 +++++-
> 1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/include/linux/kref.h b/include/linux/kref.h
> index 9c07dce..fc0756a 100644
> --- a/include/linux/kref.h
> +++ b/include/linux/kref.h
> @@ -38,8 +38,12 @@ static inline void kref_init(struct kref *kref)
> */
> static inline void kref_get(struct kref *kref)
> {
> + int rc = 0;
> WARN_ON(!atomic_read(&kref->refcount));
> - atomic_inc(&kref->refcount);
> + smp_mb__before_atomic_inc();
> + rc = atomic_add_unless(&kref->refcount, 1, INT_MAX);
> + smp_mb__after_atomic_inc();
> + BUG_ON(!rc);
So you are guaranteeing to crash a machine here if this fails? And you
were trying to say this is a "security" based fix?
And people wonder why I no longer have any hair...
greg k-h
next prev parent reply other threads:[~2012-02-24 18:39 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAEXv5_gkTsPHDFh+wQqD3P3D-Z+uCN-_1bVyHfHV=u7bS-tgeA@mail.gmail.com>
2012-02-16 20:45 ` Kees Cook
2012-02-17 0:24 ` Greg Kroah-Hartman
2012-02-17 1:06 ` Kees Cook
2012-02-17 1:40 ` Greg KH
2012-02-17 2:11 ` [ubuntu-hardened] " Kees Cook
2012-02-17 2:48 ` David Windsor
2012-02-17 3:32 ` Greg KH
2012-02-17 6:33 ` Alexey Dobriyan
2012-02-17 13:23 ` pageexec
2012-02-17 7:59 ` [kernel-hardening] " Vasiliy Kulikov
2012-02-17 17:53 ` Greg KH
2012-02-17 17:54 ` Greg KH
2012-02-17 19:37 ` Vasiliy Kulikov
2012-02-17 23:39 ` Djalal Harouni
2012-02-18 1:44 ` Roland Dreier
2012-02-18 16:15 ` David Windsor
2012-02-18 16:35 ` Vasiliy Kulikov
2012-02-18 16:18 ` Greg KH
2012-02-24 17:58 ` David Windsor
2012-02-24 18:37 ` Greg KH [this message]
2012-02-24 18:52 ` Kees Cook
2012-02-24 19:05 ` Nick Bowler
2012-02-24 19:13 ` Vasiliy Kulikov
2012-02-24 19:35 ` Nick Bowler
2012-02-24 21:59 ` PaX Team
2012-02-24 18:58 ` Vasiliy Kulikov
2012-02-24 19:41 ` Greg KH
2012-02-24 20:04 ` Kees Cook
2012-02-24 19:04 ` David Windsor
2012-02-24 22:14 ` PaX Team
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=20120224183726.GB23284@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=dwindsor@gmail.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pageexec@freemail.hu \
--cc=roland@purestorage.com \
--cc=segoon@openwall.com \
--cc=spender@grsecurity.net \
--cc=tixxdz@opendz.org \
--cc=ubuntu-hardened@lists.ubuntu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®