From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-f200.google.com (mail-io0-f200.google.com [209.85.223.200]) by kanga.kvack.org (Postfix) with ESMTP id C06A96B0292 for ; Wed, 26 Jul 2017 12:20:59 -0400 (EDT) Received: by mail-io0-f200.google.com with SMTP id q64so153129604ioi.6 for ; Wed, 26 Jul 2017 09:20:59 -0700 (PDT) Received: from mail-io0-x232.google.com (mail-io0-x232.google.com. [2607:f8b0:4001:c06::232]) by mx.google.com with ESMTPS id e127si1966475itc.179.2017.07.26.09.20.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jul 2017 09:20:58 -0700 (PDT) Received: by mail-io0-x232.google.com with SMTP id m88so60981498iod.2 for ; Wed, 26 Jul 2017 09:20:58 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <20170706002718.GA102852@beast> From: Kees Cook Date: Wed, 26 Jul 2017 09:20:56 -0700 Message-ID: Subject: Re: [v3] mm: Add SLUB free list pointer obfuscation Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: To: Christopher Lameter Cc: Alexander Popov , Andrew Morton , Pekka Enberg , David Rientjes , Joonsoo Kim , "Paul E. McKenney" , Ingo Molnar , Josh Triplett , Andy Lutomirski , Nicolas Pitre , Tejun Heo , Daniel Mack , Sebastian Andrzej Siewior , Sergey Senozhatsky , Helge Deller , Rik van Riel , Linux-MM , Tycho Andersen , LKML , "kernel-hardening@lists.openwall.com" On Wed, Jul 26, 2017 at 7:08 AM, Christopher Lameter wrote: > On Tue, 25 Jul 2017, Kees Cook wrote: > >> > @@ -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); >> >> What happens if, instead of BUG_ON, we do: >> >> if (unlikely(WARN_RATELIMIT(object == fp, "double-free detected")) >> return; > > This may work for the free fastpath but the set_freepointer function is > use in multiple other locations. Maybe just add this to the fastpath > instead of to this fucnction? Do you mean do_slab_free()? -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: email@kvack.org