|
Message-Id: <1502468246-1262-1-git-send-email-alex.popov@linux.com> Date: Fri, 11 Aug 2017 19:17:26 +0300 From: Alexander Popov <alex.popov@...ux.com> To: Kees Cook <keescook@...omium.org>, Andrew Morton <akpm@...ux-foundation.org>, Christoph Lameter <cl@...ux.com>, Pekka Enberg <penberg@...nel.org>, David Rientjes <rientjes@...gle.com>, Joonsoo Kim <iamjoonsoo.kim@....com>, Paul E McKenney <paulmck@...ux.vnet.ibm.com>, Ingo Molnar <mingo@...nel.org>, Tejun Heo <tj@...nel.org>, Andy Lutomirski <luto@...nel.org>, Nicolas Pitre <nicolas.pitre@...aro.org>, linux-mm@...ck.org, Rik van Riel <riel@...hat.com>, Tycho Andersen <tycho@...ker.com>, Alexander Popov <alex.popov@...ux.com>, linux-kernel@...r.kernel.org, kernel-hardening@...ts.openwall.com Subject: [linux-next][PATCH v2] mm/slub.c: add a naive detection of double free or corruption 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@...ux.com> --- mm/slub.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/slub.c b/mm/slub.c index b9c7f1a..77b2781 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
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.