Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5648849rwl; Tue, 11 Apr 2023 08:12:00 -0700 (PDT) X-Google-Smtp-Source: AKy350a4B+UEYogMjY6RfIaBaE2KgkHhPErBYthtaiOiojTA7sTs6oGPlRXaxrpDvzR0X6z5Ivzo X-Received: by 2002:aa7:dd0a:0:b0:504:b177:3eee with SMTP id i10-20020aa7dd0a000000b00504b1773eeemr2281682edv.33.1681225920029; Tue, 11 Apr 2023 08:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681225920; cv=none; d=google.com; s=arc-20160816; b=PNwos42nGcUJ8IWQGctB4cUKEB4y+fmNC6+D0W+wdODuydcPBWQ6PmcsKwfk1jBywE +/TsYEU+d77NDVq2wqwirFBkkap1hK4gE04t/DKClOsBjkoRNpXGyMDs6flnDXjJW6ww VppkvK3dWBtgK5Mr4E/nwXthsRM4xDnfQ1dQX01/RiZiCexCAPKwiK5PKTmNedGu13HQ RUW0hlNEtFT9HS5+rc6w5fBvW0GQ6tE+G9qlXq4GveweFnEw6OAAA4wClSSk8MkYuoLc 9Vo0LLXYrt4OBeK71OX49keIcIzrakOmj/niUzF3fUN1C2RwG/gX6haPnnkSGmyQLfdt acBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=j6J+Ts8JtluIM1qIiM0Pu413sKPjFO4ZnKvhKDteD5g=; b=YVkJ3h6RgU/jU2dhEnyVT9C3Odf8SPpKJZ5DZM+1QOBNcgPBZjNZsrZDYPA0MLKY+A xU5OYB8KaKmsGcg4Jn9U0VWIoQSe9QYMp01/UFa4VybUUv8wDXK40s4jgQAQZ5QnNFHF Ca//xmmCoi1C3IRjUR2iKVeuFzL7cCoqS9FUUIitBsDlTogMBlkCTqxace3vDWXRyaCP xAUULBkiQnxBX40g360BEirbpUqZ6fGelA7SBVcAC7ZbNMAueDIWxisVQDisVxQWSIOT h+7dBakQLbZaKyxFvWjZI4LNb91HEJnZMHwkRzlqv11CstPqpPYo4RqgQMyAoB/W/4oW 59Qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ca23-20020aa7cd77000000b004c698b5018esi1120263edb.347.2023.04.11.08.11.34; Tue, 11 Apr 2023 08:12:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230409AbjDKPKv (ORCPT + 99 others); Tue, 11 Apr 2023 11:10:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230310AbjDKPKq (ORCPT ); Tue, 11 Apr 2023 11:10:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CC415254; Tue, 11 Apr 2023 08:10:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3512A61F6C; Tue, 11 Apr 2023 15:10:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36DACC43443; Tue, 11 Apr 2023 15:10:27 +0000 (UTC) Date: Tue, 11 Apr 2023 16:10:24 +0100 From: Catalin Marinas To: Luis Chamberlain Cc: Song Liu , jim.cromie@gmail.com, linux-modules@vger.kernel.org, LKML , Jason Baron , Greg KH Subject: Re: kmemleaks on ac3b43283923 ("module: replace module_layout with module_memory") Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-4.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 03, 2023 at 01:43:58PM -0700, Luis Chamberlain wrote: > On Fri, Mar 31, 2023 at 05:27:04PM -0700, Song Liu wrote: > > On Fri, Mar 31, 2023 at 12:00 AM Luis Chamberlain wrote: > > > On Thu, Mar 30, 2023 at 04:45:43PM -0600, jim.cromie@gmail.com wrote: > > > > kmemleak is reporting 19 leaks during boot > > > > > > > > because the hexdumps appeared to have module-names, > > > > and Ive been hacking nearby, and see the same names > > > > every time I boot my test-vm, I needed a clearer picture > > > > Jason corroborated and bisected. > > > > > > > > the 19 leaks split into 2 groups, > > > > 9 with names of builtin modules in the hexdump, > > > > all with the same backtrace > > > > 9 without module-names (with a shared backtrace) > > > > +1 wo name-ish and a separate backtrace > > > > > > Song, please take a look. > > > > I will look into this next week. > > I'm thinking this may be it, at least this gets us to what we used to do > as per original Catalinas' 4f2294b6dc88d ("kmemleak: Add modules > support") and right before Song's patch. > > diff --git a/kernel/module/main.c b/kernel/module/main.c > index 6b6da80f363f..3b9c71fa6096 100644 > --- a/kernel/module/main.c > +++ b/kernel/module/main.c > @@ -2240,7 +2240,10 @@ static int move_module(struct module *mod, struct load_info *info) > * which is inside the block. Just mark it as not being a > * leak. > */ > - kmemleak_ignore(ptr); > + if (type == MOD_INIT_TEXT) > + kmemleak_ignore(ptr); > + else > + kmemleak_not_leak(ptr); > if (!ptr) { > t = type; > goto out_enomem; > > We used to use the grey area for the TEXT but the original commit > doesn't explain too well why we grey out init but not the others. Ie > why kmemleak_ignore() on init and kmemleak_not_leak() on the others. It's safe to use the 'grey' colour in all cases. For text sections that don't need scanning, there's a slight chance of increasing the false negatives, so marking it 'black' ignores the scanning. For the init section, if it gets discarded anyway, just going with kmemleak_not_leak() is fine. It simplifies the logic above. -- Catalin