From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751180AbcBBFbj (ORCPT ); Tue, 2 Feb 2016 00:31:39 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:53487 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750763AbcBBFbi (ORCPT ); Tue, 2 Feb 2016 00:31:38 -0500 Date: Mon, 1 Feb 2016 21:34:27 -0800 From: Andrew Morton To: Alexander Potapenko Cc: adech.fo@gmail.com, cl@linux.com, dvyukov@google.com, ryabinin.a.a@gmail.com, rostedt@goodmis.org, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v1 1/8] kasan: Change the behavior of kmalloc_large_oob_right test Message-Id: <20160201213427.f428b08d.akpm@linux-foundation.org> In-Reply-To: <35b553cafcd5b77838aeaf5548b457dfa09e30cf.1453918525.git.glider@google.com> References: <35b553cafcd5b77838aeaf5548b457dfa09e30cf.1453918525.git.glider@google.com> X-Mailer: Sylpheed 2.7.1 (GTK+ 2.18.9; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 27 Jan 2016 19:25:06 +0100 Alexander Potapenko wrote: > depending on which allocator (SLAB or SLUB) is being used > > ... > > --- a/lib/test_kasan.c > +++ b/lib/test_kasan.c > @@ -68,7 +68,22 @@ static noinline void __init kmalloc_node_oob_right(void) > static noinline void __init kmalloc_large_oob_right(void) > { > char *ptr; > - size_t size = KMALLOC_MAX_CACHE_SIZE + 10; > + size_t size; > + > + if (KMALLOC_MAX_CACHE_SIZE == KMALLOC_MAX_SIZE) { > + /* > + * We're using the SLAB allocator. Allocate a chunk that fits > + * into a slab. > + */ > + size = KMALLOC_MAX_CACHE_SIZE - 256; > + } else { > + /* > + * KMALLOC_MAX_SIZE > KMALLOC_MAX_CACHE_SIZE. > + * We're using the SLUB allocator. Allocate a chunk that does > + * not fit into a slab to trigger the page allocator. > + */ > + size = KMALLOC_MAX_CACHE_SIZE + 10; > + } This seems a weird way of working out whether we're using SLAB or SLUB. Can't we use, umm, #ifdef CONFIG_SLAB? If not that then let's cook up something standardized rather than a weird just-happens-to-work like this.