All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Eric Biggers <ebiggers3@gmail.com>
Cc: kernel-hardening@lists.openwall.com, keescook@chromium.org,
	arnd@arndb.de, tglx@linutronix.de, mingo@redhat.com,
	h.peter.anvin@intel.com, will.deacon@arm.com, dwindsor@gmail.com,
	gregkh@linuxfoundation.org,
	Elena Reshetova <elena.reshetova@intel.com>
Subject: Re: [kernel-hardening] [RFCv2 PATCH 00/18] refcount_t API + usage
Date: Thu, 19 Jan 2017 10:19:52 +0100	[thread overview]
Message-ID: <20170119091952.GH6485@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20170118215247.GA129388@gmail.com>

On Wed, Jan 18, 2017 at 01:52:47PM -0800, Eric Biggers wrote:
> There seems to be a lot of focus on converting things to use refcount_t but much
> less focus on providing a refcount_t implementation that actually meets the
> performance and security goals of the feature.

And here you go again... :-(

The refcount_t implementation does meet the security goals afaict, it
has full saturation semantics, which means an overflow bug gets turned
into a resource leak.

That covers the entirely of the security goal. If there is more, you'll
need to spell it out.

As for performance, you didn't reply to my earlier email on the subject.

> Notably, the proposed patchset
> provides no information about why the proposed implementation was chosen over
> the PaX implementation (note that I'm talking about the actual implementation of
> safe reference counts, not the atomic_t/atomic_unchecked_t division) which as
> I've already mentioned is much more efficient (less bloated and faster) while
> still meeting the security goal.

You again failed to reply to my last email on the subject. The initial
PaX thing was broken as heck, only later did you mention it got fixed. I
told you we could change to that for x86 if it could be proven to be
equivalent.

If you want to expedite matters, provide said proof.

The scheme does not make sense for LL/SC based architectures though, so
its not something that belongs in generic code.

> I'm especially worried that people will be put
> in a position where they need to take performance concerns into account when
> deciding whether to use refcount_t or not.

First show a place where refcounting is performance critical, then we
can see how much effort is required.

> And the patch even still includes
> the "don't allow incrementing a zero refcount" check which AFAICS is bogus from
> a security perspective.

Because use-after-free isn't a security problem, right? Reference
counting semantics are fairly clear that 0 means it is, or is going to
be, free()'ed. How does allowing to increment at that point make any
sense?

> Even if you and Peter disagree with the comments that I and also PaX Team have
> made, the patch must at least explain the design decisions made.

It was constructed as a generic atomic with saturation semantics because
what was said PaX had was broken as hell (note, I have myself never
looked at PaX code and have only seen what was sent me as derived code).
If that later got fixed, or the derived code was buggy or whatever, your
earlier email was the first I heard of that, and that was well after I
wrote refcount_t.

So the design decision was broken vs not-broken.

Also, refcount_t is written using generic primitives (not arch
specific), to avoid arch dependencies and provide a common
implementation to determine semantics. That does not mean architectures
cannot implement their own later on (matching semantics).

Also, I agree GCC does a very poor job generating code from it. But
again, I've not had a report where refcounting is performance critical.
I've also been very busy with other work and haven't spend much if any
time on this since your last email.

If you want something done, contribute.

  parent reply	other threads:[~2017-01-19  9:19 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-18  9:11 [kernel-hardening] [RFCv2 PATCH 00/18] refcount_t API + usage Elena Reshetova
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 01/18] kref: Add KREF_INIT() Elena Reshetova
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 02/18] kref: Add kref_read() Elena Reshetova
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 03/18] kref: Kill kref_sub() Elena Reshetova
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 04/18] kref: Use kref_get_unless_zero() more Elena Reshetova
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 05/18] kref: Implement kref_put_lock() Elena Reshetova
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 06/18] kref: Avoid more abuse Elena Reshetova
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 07/18] kref: Implement using refcount_t Elena Reshetova
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 08/18] kernel, mm: convert from atomic_t to refcount_t Elena Reshetova
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 09/18] net: " Elena Reshetova
2017-01-18 18:39   ` [kernel-hardening] " David Windsor
2017-01-19  1:11     ` Kees Cook
2017-01-19  3:29       ` David Windsor
2017-01-19  7:48         ` Reshetova, Elena
2017-01-19 15:08           ` David Windsor
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 10/18] fs: " Elena Reshetova
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 11/18] security: " Elena Reshetova
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 12/18] sound: " Elena Reshetova
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 13/18] ipc: covert " Elena Reshetova
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 14/18] tools: convert " Elena Reshetova
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 15/18] block: " Elena Reshetova
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 16/18] drivers: net " Elena Reshetova
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 17/18] drivers: misc drivers " Elena Reshetova
2017-01-18  9:11 ` [kernel-hardening] [RFCv2 PATCH 18/18] drivers: infiniband " Elena Reshetova
2017-01-18 10:30 ` [kernel-hardening] Re: [RFCv2 PATCH 00/18] refcount_t API + usage Greg KH
2017-01-18 20:06   ` Kees Cook
2017-01-18 20:35     ` Greg KH
2017-01-18 20:57       ` Kees Cook
2017-01-19  8:52       ` Peter Zijlstra
2017-01-23  7:52   ` [kernel-hardening] " Reshetova, Elena
2017-01-23  8:36     ` [kernel-hardening] " Greg KH
2017-01-23  8:52       ` [kernel-hardening] " Reshetova, Elena
2017-01-18 21:52 ` [kernel-hardening] " Eric Biggers
2017-01-19  8:31   ` Reshetova, Elena
2017-01-19  9:19   ` Peter Zijlstra [this message]
2017-01-19 10:22     ` Reshetova, Elena
2017-01-19 12:52       ` Peter Zijlstra
2017-01-19 14:15         ` Reshetova, Elena
2017-01-19 15:20     ` [kernel-hardening] " David Windsor
2017-01-19 16:00       ` [kernel-hardening] " Reshetova, Elena
2017-01-19 19:18     ` [kernel-hardening] " Eric Biggers
2017-01-20  8:36       ` Peter Zijlstra
2017-01-20  9:20         ` Reshetova, Elena
2017-01-20 10:23           ` gregkh
2017-01-20 10:44           ` Solar Designer
2017-01-20 17:52             ` Eric Biggers

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=20170119091952.GH6485@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=arnd@arndb.de \
    --cc=dwindsor@gmail.com \
    --cc=ebiggers3@gmail.com \
    --cc=elena.reshetova@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=h.peter.anvin@intel.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.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.