From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-f198.google.com (mail-io0-f198.google.com [209.85.223.198]) by kanga.kvack.org (Postfix) with ESMTP id 650236B03A1 for ; Tue, 11 Apr 2017 12:19:09 -0400 (EDT) Received: by mail-io0-f198.google.com with SMTP id k3so4289617ioe.6 for ; Tue, 11 Apr 2017 09:19:09 -0700 (PDT) Received: from mail-io0-x22b.google.com (mail-io0-x22b.google.com. [2607:f8b0:4001:c06::22b]) by mx.google.com with ESMTPS id 188si2419306itg.18.2017.04.11.09.19.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Apr 2017 09:19:08 -0700 (PDT) Received: by mail-io0-x22b.google.com with SMTP id t68so10367301iof.0 for ; Tue, 11 Apr 2017 09:19:08 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <20170404113022.GC15490@dhcp22.suse.cz> <20170404151600.GN15132@dhcp22.suse.cz> <20170404194220.GT15132@dhcp22.suse.cz> <20170404201334.GV15132@dhcp22.suse.cz> <20170411134618.GN6729@dhcp22.suse.cz> <20170411141956.GP6729@dhcp22.suse.cz> From: Kees Cook Date: Tue, 11 Apr 2017 09:19:07 -0700 Message-ID: Subject: Re: [PATCH] mm: Add additional consistency check Content-Type: text/plain; charset=UTF-8 Sender: owner-linux-mm@kvack.org List-ID: To: Christoph Lameter Cc: Michal Hocko , Andrew Morton , Pekka Enberg , David Rientjes , Joonsoo Kim , Linux-MM , LKML On Tue, Apr 11, 2017 at 9:16 AM, Christoph Lameter wrote: > On Tue, 11 Apr 2017, Michal Hocko wrote: > >> static inline void *index_to_obj(struct kmem_cache *cache, struct page *page, >> @@ -3813,14 +3818,18 @@ void kfree(const void *objp) >> { >> struct kmem_cache *c; >> unsigned long flags; >> + struct page *page; >> >> trace_kfree(_RET_IP_, objp); >> >> if (unlikely(ZERO_OR_NULL_PTR(objp))) >> return; >> + page = virt_to_head_page(obj); >> + if (CHECK_DATA_CORRUPTION(!PageSlab(page))) > > There is a flag SLAB_DEBUG_OBJECTS that is available for this check. > Consistency checks are configuraable in the slab allocator. > > Mentioned that before and got this lecture about data consistency checks. It seems that enabling the debug checks comes with a non-trivial performance impact. I'd like to see consistency checks by default so we can handle intentional heap corruption attacks better. This check isn't expensive... -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