From: "PaX Team" <pageexec@freemail.hu>
To: Kees Cook <keescook@chromium.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
Eric Biggers <ebiggers3@gmail.com>,
Christoph Hellwig <hch@infradead.org>,
"axboe@kernel.dk" <axboe@kernel.dk>,
James Bottomley <James.Bottomley@hansenpartnership.com>,
Elena Reshetova <elena.reshetova@intel.com>,
Hans Liljestrand <ishkamiel@gmail.com>,
David Windsor <dwindsor@gmail.com>,
"x86@kernel.org" <x86@kernel.org>, Ingo Molnar <mingo@kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jann Horn <jann@thejh.net>,
"David S. Miller" <davem@davemloft.net>,
linux-arch <linux-arch@vger.kernel.org>,
"kernel-hardening@lists.openwall.com"
<kernel-hardening@lists.openwall.com>
Subject: Re: [PATCH] x86/refcount: Implement fast refcount_t handling
Date: Tue, 25 Apr 2017 13:26:43 +0200 [thread overview]
Message-ID: <58FF3273.8060.1C99E526@pageexec.freemail.hu> (raw)
In-Reply-To: <CAGXu5jLDybHn_K=vpXOhrsBE_-EtPA+jbXCqHmm3tUgbK24BOw@mail.gmail.com>
On 24 Apr 2017 at 13:33, Kees Cook wrote:
> On Mon, Apr 24, 2017 at 4:00 AM, PaX Team <pageexec@freemail.hu> wrote:
> > On 24 Apr 2017 at 10:32, Peter Zijlstra wrote:
> >
> >> On Fri, Apr 21, 2017 at 03:09:39PM -0700, Kees Cook wrote:
> >> > This patch ports the x86-specific atomic overflow handling from PaX's
> >> > PAX_REFCOUNT to the upstream refcount_t API. This is an updated version
> >> > from PaX that eliminates the saturation race condition by resetting the
> >> > atomic counter back to the INT_MAX saturation value on both overflow and
> >> > underflow. To win a race, a system would have to have INT_MAX threads
> >> > simultaneously overflow before the saturation handler runs.
> >
> > note that the above is wrong (and even contradicting itself and the code).
>
> True, this changelog could be more accurate (it resets to INT_MAX on
> overflow and INT_MIN on underflow). I think I'm right in saying that a
> system would need INT_MAX threads running a refcount_inc() (and a
> refcount_dec_and_test() at exactly the right moment) before the reset
> handler got scheduled, though, yes?
there's no uniform answer to this as there're several conditions
that can affect the effectiveness of the refcount protection.
e.g., how many independent leaking paths can the attacker exercise
(typically one), are these paths under some kind of locks (would
already prevent unbounded leaks/increments should the overflow
detecting thread be preempted), are negative refcounts allowed and
checked for or only signed overflow, etc.
INT_MAX threads would be needed when the leaking path is locked so
that it can only be exercised once and you'll need to get normal
(balanced) paths preempted just after the increment. if the leaking
path is lockless (can be exercised in parallel without bounds) then
2 threads are enough where the one triggering the signed overflow
would have to be preempted while the other one does INT_MAX increments
and trigger the UAF. this is where the other mechanisms i talked about
in the past become relevant: preemption or interrupts can be disabled
or negative refcount values can be detected and acted upon (your blind
copy-pasting effort passed upon this latter opportunity by not
specializing the 'jo' into 'js' for the refcount case).
next prev parent reply other threads:[~2017-04-25 11:28 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-21 22:09 Kees Cook
2017-04-24 8:32 ` Peter Zijlstra
2017-04-24 8:53 ` [kernel-hardening] " Jann Horn
2017-04-24 9:20 ` Peter Zijlstra
2017-04-24 11:00 ` PaX Team
2017-04-24 11:15 ` Peter Zijlstra
2017-04-24 13:08 ` PaX Team
2017-04-24 13:33 ` Peter Zijlstra
2017-04-24 15:15 ` PaX Team
2017-04-24 20:40 ` Kees Cook
2017-04-24 22:01 ` Peter Zijlstra
2017-04-24 22:37 ` Kees Cook
2017-04-25 1:11 ` [kernel-hardening] " Rik van Riel
2017-04-25 9:05 ` Peter Zijlstra
2017-04-25 11:26 ` PaX Team
2017-04-25 16:36 ` Kees Cook
2017-04-24 20:33 ` Kees Cook
2017-04-25 11:26 ` PaX Team [this message]
2017-04-25 16:39 ` Kees Cook
2017-04-26 2:14 ` PaX Team
2017-04-26 4:42 ` Kees Cook
2017-04-24 20:16 ` Kees Cook
2017-04-24 10:45 ` Peter Zijlstra
2017-04-24 20:19 ` Kees Cook
2017-04-24 10:48 ` Peter Zijlstra
2017-04-24 20:21 ` Kees Cook
2017-04-25 10:23 ` Peter Zijlstra
2017-04-25 11:26 ` 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=58FF3273.8060.1C99E526@pageexec.freemail.hu \
--to=pageexec@freemail.hu \
--cc=James.Bottomley@hansenpartnership.com \
--cc=arnd@arndb.de \
--cc=axboe@kernel.dk \
--cc=davem@davemloft.net \
--cc=dwindsor@gmail.com \
--cc=ebiggers3@gmail.com \
--cc=elena.reshetova@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hch@infradead.org \
--cc=ishkamiel@gmail.com \
--cc=jann@thejh.net \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=x86@kernel.org \
/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®