From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qa0-f42.google.com (mail-qa0-f42.google.com [209.85.216.42]) by kanga.kvack.org (Postfix) with ESMTP id 958B96B0038 for ; Thu, 16 Oct 2014 10:55:46 -0400 (EDT) Received: by mail-qa0-f42.google.com with SMTP id j7so2532900qaq.29 for ; Thu, 16 Oct 2014 07:55:46 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id c44si40928465qgd.93.2014.10.16.07.55.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Oct 2014 07:55:46 -0700 (PDT) Date: Thu, 16 Oct 2014 10:55:34 -0400 (EDT) From: Mikulas Patocka Subject: Re: [PATCH] slab: implement kmalloc guard In-Reply-To: <20140915021133.GC2676@js1304-P5Q-DELUXE> Message-ID: References: <20140915021133.GC2676@js1304-P5Q-DELUXE> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Joonsoo Kim Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Alasdair G. Kergon" , Mike Snitzer , Milan Broz , kkolasa@winsoft.pl, dm-devel@redhat.com On Mon, 15 Sep 2014, Joonsoo Kim wrote: > On Thu, Sep 11, 2014 at 10:32:52PM -0400, Mikulas Patocka wrote: > > > > > > On Mon, 8 Sep 2014, Christoph Lameter wrote: > > > > > On Mon, 8 Sep 2014, Mikulas Patocka wrote: > > > > > > > I don't know what you mean. If someone allocates 10000 objects with sizes > > > > from 1 to 10000, you can't have 10000 slab caches - you can't have a slab > > > > cache for each used size. Also - you can't create a slab cache in > > > > interrupt context. > > > > > > Oh you can create them up front on bootup. And I think only the small > > > sizes matter. Allocations >=8K are pushed to the page allocator anyways. > > > > Only for SLUB. For SLAB, large allocations are still use SLAB caches up to > > 4M. But anyway - having 8K preallocated slab caches is too much. > > > > If you want to integrate this patch into the slab/slub subsystem, a better > > solution would be to store the exact size requested with kmalloc along the > > slab/slub object itself (before the preceding redzone). But it would > > result in duplicating the work - you'd have to repeat the logic in this > > patch three times - once for slab, once for slub and once for > > kmalloc_large/kmalloc_large_node. > > > > I don't know if it would be better than this patch. > > Hello, > > Out of bound write could be detected by kernel address asanitizer(KASan). > See following link. > > https://lkml.org/lkml/2014/9/10/441 > > Although this patch also looks good to me, I think that KASan is > better than this, because it could detect out of bound write and > has more features for debugging. > > Thanks. Surely, KAsan detects more bugs. But it has also high overhead. The overhead of kmalloc guard is very low. The kmalloc guard already helped to find one previously unknown bug: http://lkml.iu.edu/hypermail/linux/kernel/1409.1/02325.html Mikulas -- 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