Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932968AbbFIPDP (ORCPT ); Tue, 9 Jun 2015 11:03:15 -0400 Received: from foss.arm.com ([217.140.101.70]:51184 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753804AbbFIPDI (ORCPT ); Tue, 9 Jun 2015 11:03:08 -0400 Date: Tue, 9 Jun 2015 16:03:03 +0100 From: Catalin Marinas To: "Zhang, Yanmin" Cc: Christoph Lameter , "Liu, XinwuX" , "penberg@kernel.org" , "mpm@selenic.com" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "He, Bo" , "Chen, Lin Z" Subject: Re: [PATCH] slub/slab: fix kmemleak didn't work on some case Message-ID: <20150609150303.GB4808@e104818-lin.cambridge.arm.com> References: <99C214DF91337140A8D774E25DF6CD5FC89DA2@shsmsx102.ccr.corp.intel.com> <20150608101302.GB31349@e104818-lin.cambridge.arm.com> <55769F85.5060909@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55769F85.5060909@linux.intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2089 Lines: 49 On Tue, Jun 09, 2015 at 09:10:45AM +0100, Zhang, Yanmin wrote: > On 2015/6/8 18:13, Catalin Marinas wrote: > > As I replied already, I don't think this is that bad, or at least not > > worse than what kmemleak already does (looking at all data whether it's > > pointer or not). > > It depends. As for memleak, developers prefers there are false alarms instead > of missing some leaked memory. Lots of false positives aren't that nice, you spend a lot of time debugging them (I've been there in the early kmemleak days). Anyway, your use case is not about false positives vs. negatives but just false negatives. My point is that there is a lot of random, pointer-like data read by kmemleak even without this memset (e.g. thread stacks, non-pointer data in kmalloc'ed structures, data/bss sections). Just doing this memset may reduce the chance of false negatives a bit but I don't think it would be noticeable. If there is some serious memory leak (lots of objects), they would likely show up at some point. Even if it's a one-off leak, it's possible that it shows up after some time (e.g. the object pointing to this memory block is freed). > > It also doesn't solve the kmem_cache_alloc() case where > > the original object size is no longer available. > > Such issue around kmem_cache_alloc() case happens only when the > caller doesn't initialize or use the full object, so the object keeps > old dirty data. The kmem_cache blocks size would be aligned to a cache line, so you still have some extra bytes never touched by the caller. > This patch is to resolve the redundant unused space (more than object size) > although the full object is used by kernel. So this solves only the cases where the original object size is still known (e.g. kmalloc). It could also be solved by telling kmemleak the actual object size. -- Catalin -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/