From: Alexander Popov <alex.popov@linux.com>
To: Kees Cook <keescook@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
David Rientjes <rientjes@google.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Ingo Molnar <mingo@kernel.org>,
Josh Triplett <josh@joshtriplett.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@kvack.org, Tycho Andersen <tycho@docker.com>,
linux-kernel@vger.kernel.org,
kernel-hardening@lists.openwall.com
Subject: Re: [v3] mm: Add SLUB free list pointer obfuscation
Date: Tue, 25 Jul 2017 00:17:11 +0300 [thread overview]
Message-ID: <cdd42a1b-ce15-df8c-6bd1-b0943275986f@linux.com> (raw)
In-Reply-To: <20170706002718.GA102852@beast>
>From 86f4f1f6deb76849e00c761fa30eeb479f789c35 Mon Sep 17 00:00:00 2001
From: Alexander Popov <alex.popov@linux.com>
Date: Mon, 24 Jul 2017 23:16:28 +0300
Subject: [PATCH 2/2] mm/slub.c: add a naive detection of double free or
corruption
On 06.07.2017 03:27, 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 pointer address and value. 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 minimize the
> use of #ifdef.
Hello!
This is an addition to the SLAB_FREELIST_HARDENED feature. I'm sending it
according the discussion here:
http://www.openwall.com/lists/kernel-hardening/2017/07/17/9
-- >8 --
Add an assertion similar to "fasttop" check in GNU C Library allocator
as a part of SLAB_FREELIST_HARDENED feature. An object added to a singly
linked freelist should not point to itself. That helps to detect some
double free errors (e.g. CVE-2017-2636) without slub_debug and KASAN.
Signed-off-by: Alexander Popov <alex.popov@linux.com>
---
mm/slub.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mm/slub.c b/mm/slub.c
index c92d636..f39d06e 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -290,6 +290,10 @@ static inline void set_freepointer(struct kmem_cache *s,
void *object, void *fp)
{
unsigned long freeptr_addr = (unsigned long)object + s->offset;
+#ifdef CONFIG_SLAB_FREELIST_HARDENED
+ BUG_ON(object == fp); /* naive detection of double free or corruption */
+#endif
+
*(void **)freeptr_addr = freelist_ptr(s, fp, freeptr_addr);
}
--
2.7.4
next prev parent reply other threads:[~2017-07-24 21:17 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-06 0:27 [PATCH v3] mm: Add SLUB free list pointer obfuscation Kees Cook
2017-07-06 13:43 ` Christoph Lameter
2017-07-06 15:48 ` Kees Cook
2017-07-06 15:55 ` Christoph Lameter
2017-07-06 16:16 ` [kernel-hardening] " Daniel Micay
2017-07-06 17:53 ` Rik van Riel
2017-07-06 18:50 ` Kees Cook
2017-07-07 13:50 ` Christoph Lameter
2017-07-07 16:51 ` Kees Cook
2017-07-07 17:06 ` Christoph Lameter
2017-07-07 18:43 ` Kees Cook
2017-07-24 21:17 ` Alexander Popov [this message]
2017-07-25 9:42 ` [v3] " Alexander Popov
2017-07-26 0:21 ` Kees Cook
2017-07-26 14:08 ` Christopher Lameter
2017-07-26 16:20 ` Kees Cook
2017-07-26 16:55 ` Christopher Lameter
2017-07-26 17:13 ` Kees Cook
2017-07-27 15:15 ` Christopher Lameter
2017-07-27 22:48 ` Alexander Popov
2017-07-27 23:53 ` Christopher Lameter
2017-07-31 20:17 ` Alexander Popov
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=cdd42a1b-ce15-df8c-6bd1-b0943275986f@linux.com \
--to=alex.popov@linux.com \
--cc=akpm@linux-foundation.org \
--cc=bigeasy@linutronix.de \
--cc=cl@linux.com \
--cc=daniel@zonque.org \
--cc=deller@gmx.de \
--cc=iamjoonsoo.kim@lge.com \
--cc=josh@joshtriplett.org \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.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 \
--cc=tycho@docker.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