linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Laura Abbott <labbott@redhat.com>
Cc: Christoph Lameter <cl@linux.com>,
	Daniel Micay <danielmicay@gmail.com>,
	Pekka Enberg <penberg@kernel.org>,
	David Rientjes <rientjes@google.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Ingo Molnar <mingo@kernel.org>, Andy Lutomirski <luto@kernel.org>,
	Nicolas Pitre <nicolas.pitre@linaro.org>,
	Tejun Heo <tj@kernel.org>, Daniel Mack <daniel@zonque.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Helge Deller <deller@gmx.de>, Rik van Riel <riel@redhat.com>,
	Linux-MM <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"kernel-hardening@lists.openwall.com"
	<kernel-hardening@lists.openwall.com>
Subject: Re: [PATCH] mm: Add SLUB free list pointer obfuscation
Date: Tue, 20 Jun 2017 11:08:33 -0700	[thread overview]
Message-ID: <CAGXu5jKRLNvb2Gy77Q4pTes6oHEypG=GCB56twb8A7jvz=FpLg@mail.gmail.com> (raw)
In-Reply-To: <505961f9-b266-191a-f4b7-931410a55149@redhat.com>

On Tue, Jun 20, 2017 at 11:05 AM, Laura Abbott <labbott@redhat.com> wrote:
> On 06/19/2017 08:01 PM, Kees Cook wrote:
>> This SLUB free list pointer obfuscation code is modified from Brad
>> Spengler/PaX Team's code in the last public patch of grsecurity/PaX based
>> on my understanding of the code. Changes or omissions from the original
>> code are mine and don't reflect the original grsecurity/PaX code.
>>
>> This adds a per-cache random value to SLUB caches that is XORed with
>> their freelist pointers. This adds nearly zero overhead and frustrates the
>> very common heap overflow exploitation method of overwriting freelist
>> pointers. A recent example of the attack is written up here:
>> http://cyseclabs.com/blog/cve-2016-6187-heap-off-by-one-exploit
>>
>> This is based on patches by Daniel Micay, and refactored to avoid lots
>> of #ifdef code.
>>
>> Suggested-by: Daniel Micay <danielmicay@gmail.com>
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>> ---
>>  include/linux/slub_def.h |  4 ++++
>>  init/Kconfig             | 10 ++++++++++
>>  mm/slub.c                | 32 +++++++++++++++++++++++++++-----
>>  3 files changed, 41 insertions(+), 5 deletions(-)
>>
>> diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
>> index 07ef550c6627..0258d6d74e9c 100644
>> --- a/include/linux/slub_def.h
>> +++ b/include/linux/slub_def.h
>> @@ -93,6 +93,10 @@ struct kmem_cache {
>>  #endif
>>  #endif
>>
>> +#ifdef CONFIG_SLAB_HARDENED
>> +     unsigned long random;
>> +#endif
>> +
>>  #ifdef CONFIG_NUMA
>>       /*
>>        * Defragmentation by allocating from a remote node.
>> diff --git a/init/Kconfig b/init/Kconfig
>> index 1d3475fc9496..eb91082546bf 100644
>> --- a/init/Kconfig
>> +++ b/init/Kconfig
>> @@ -1900,6 +1900,16 @@ config SLAB_FREELIST_RANDOM
>>         security feature reduces the predictability of the kernel slab
>>         allocator against heap overflows.
>>
>> +config SLAB_HARDENED
>> +     bool "Harden slab cache infrastructure"
>> +     default y
>> +     depends on SLAB_FREELIST_RANDOM && SLUB> +      help
>> +       Many kernel heap attacks try to target slab cache metadata and
>> +       other infrastructure. This options makes minor performance
>> +       sacrifies to harden the kernel slab allocator against common
>> +       exploit methods.
>> +
>
> Going to bikeshed on SLAB_HARDENED unless this is intended to be used for
> more things. Perhaps SLAB_FREELIST_HARDENED?

Daniel's tree has a bunch of changes attached to that config name, but
it's unclear to me how many would be accepted upstream. I would be
fine with SLAB_FREELIST_HARDENED.

> What's the reason for the dependency on SLAB_FREELIST_RANDOM?

Looking at it again, I suspect the idea was to collect other configs
under SLAB_HARDENED. It should likely be either be a select or just
dropped.

-Kees

-- 
Kees Cook
Pixel Security

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2017-06-20 18:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-20  3:01 Kees Cook
2017-06-20 18:05 ` Laura Abbott
2017-06-20 18:08   ` Kees Cook [this message]

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='CAGXu5jKRLNvb2Gy77Q4pTes6oHEypG=GCB56twb8A7jvz=FpLg@mail.gmail.com' \
    --to=keescook@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=bigeasy@linutronix.de \
    --cc=cl@linux.com \
    --cc=daniel@zonque.org \
    --cc=danielmicay@gmail.com \
    --cc=deller@gmx.de \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=labbott@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=nicolas.pitre@linaro.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=penberg@kernel.org \
    --cc=riel@redhat.com \
    --cc=rientjes@google.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=tj@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