|
|
Subscribe / Log in / New account

Re: Re: [RFC v4 PATCH 00/13] HARDENED_ATOMIC

From:  Kees Cook <keescook-AT-chromium.org>
To:  Peter Zijlstra <peterz-AT-infradead.org>
Subject:  Re: Re: [RFC v4 PATCH 00/13] HARDENED_ATOMIC
Date:  Fri, 11 Nov 2016 10:04:42 -0800
Message-ID:  <CAGXu5j+_wdv_vn=Us-i=bvCwCGk5Ks_gpoK9bHja4dDNUZi9eQ@mail.gmail.com>
Cc:  Will Deacon <will.deacon-AT-arm.com>, Greg KH <gregkh-AT-linuxfoundation.org>, David Windsor <dave-AT-progbits.org>, "kernel-hardening-AT-lists.openwall.com" <kernel-hardening-AT-lists.openwall.com>, Elena Reshetova <elena.reshetova-AT-intel.com>, Arnd Bergmann <arnd-AT-arndb.de>, Thomas Gleixner <tglx-AT-linutronix.de>, Ingo Molnar <mingo-AT-redhat.com>, "H. Peter Anvin" <h.peter.anvin-AT-intel.com>

On Fri, Nov 11, 2016 at 9:46 AM, Peter Zijlstra <peterz@infradead.org> wrote:
> On Fri, Nov 11, 2016 at 09:43:00AM -0800, Kees Cook wrote:
>> > 1) kref: Used for honest-to-goodness reference counters that want
>> > overflow protection.  Uses a new type: atomic_nowrap_t that has
>> > HARDENED_ATOMIC protection.
>>
>> Based on other feedback, it sounds like we're better off with
>> refcount_t (which kref could be implemented on top of). And refcount_t
>> would have a limited API: inc, dec_and_test (or whatever is determined
>> as sanely minimal).
>>
>> > 2) statistical counters: Atomic in all cases, but wraps.
>>
>> Yup. sequence_t seems to make the most sense on naming, I think. If we
>> want to get crazy, the type could be sequence_wrap_t.
>
> Why? atomic_t is still perfectly fine here, right?
>
>> > 3) atomic_t: All other users of atomics (locks, etc.).  Wrapping
>> > behavior depends on a CONFIG setting.
>>
>> Correct: if CONFIG_PARANOID_ATOMIC (or something) is set, atomic_t is
>> implemented as refcount_t, otherwise as sequence_t.
>
> Can't happen. There is far more atomic_t usage than reference and/or
> statistics counters.

The opt-out direction we need to take means that we can't leave
atomic_t as a possible refcount implementation. As such, we need to
convert everything to be either wrapping or non-wrapping, and define
atomic_t as one or the other via CONFIG (to allow the user to choose
their risk level).

Just replacing known-atomic_t refcounters with refcount_t is opt-in,
and won't cover new drivers that get missed by maintainers. We need a
hardened infrastructure, not just "stuff people can maybe remember to
use".

I'm totally open about how to get there, but things can't just be opt-in.

-Kees

-- 
Kees Cook
Nexus Security



to post comments


Copyright © 2016, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds