Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751457AbdGQQ5y (ORCPT ); Mon, 17 Jul 2017 12:57:54 -0400 Received: from resqmta-ch2-05v.sys.comcast.net ([69.252.207.37]:38764 "EHLO resqmta-ch2-05v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751315AbdGQQ5w (ORCPT ); Mon, 17 Jul 2017 12:57:52 -0400 Date: Mon, 17 Jul 2017 11:57:50 -0500 (CDT) From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: Alexander Popov cc: Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, keescook@chromium.org Subject: Re: [PATCH 1/1] mm/slub.c: add a naive detection of double free or corruption In-Reply-To: <1500309907-9357-1-git-send-email-alex.popov@linux.com> Message-ID: References: <1500309907-9357-1-git-send-email-alex.popov@linux.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-CMAE-Envelope: MS4wfE87JYWlr5PNJno76KT3/V75/Mvh/CzI5QkfQfQ11h0zS+xuDo81hmGxGUU3n6mvjtFmH9Z3y/QFTeektzz/jRdLLZsYzMA2KsXZpNbra1vzECc51qYa WRy929ENq45qlAqxafdzuUfmq2q1beAvXHVtIL9mrnhPzJ4uqq4amZSY//4Po1Q1t4mRK2prXj7ZZ5pAG+A/5NgRPfbnGHcbMtLYnu6jDpkZByuOuOFrxP1n +2tSGnJpimj8zikdwnJq9uKwci2hM3xV6Kc9tNtkndwzq9mZbrC+VmmBDUrc2LfZQW2d74Mv7vwpMzX4aOlNOB7RLxYZevRYIIZSsZxCg4Cy600TItPNbUnp 7rxx+IM0aNTmqClziAyz8uP1wc3VuXq6DzR4gvgSCkSQlyfzEvJqkWlZo3SrqKZdTS9IPdXOQKC5U0HsWkf/ROSEMeCO1A== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1054 Lines: 31 On Mon, 17 Jul 2017, Alexander Popov wrote: > Add an assertion similar to "fasttop" check in GNU C Library allocator: > 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. Testing with hackbench doesn't show any noticeable > performance penalty. We are adding up "unnoticable performance penalties". This is used int both the critical allocation and free paths. Could this be VM_BUG_ON()? > > Signed-off-by: Alexander Popov > --- > mm/slub.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/mm/slub.c b/mm/slub.c > index 1d3f983..a106939b 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -261,6 +261,7 @@ static inline void *get_freepointer_safe(struct kmem_cache *s, void *object) > > static inline void set_freepointer(struct kmem_cache *s, void *object, void *fp) > { > + BUG_ON(object == fp); /* naive detection of double free or corruption */ > *(void **)(object + s->offset) = fp; > } > >