linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: Song Liu <song@kernel.org>,
	jim.cromie@gmail.com, linux-modules@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	Jason Baron <jbaron@akamai.com>,
	Greg KH <gregkh@linuxfoundation.org>
Subject: Re: kmemleaks on ac3b43283923 ("module: replace module_layout with module_memory")
Date: Tue, 11 Apr 2023 16:10:24 +0100	[thread overview]
Message-ID: <ZDV4YGjRpuqcI7F3@arm.com> (raw)
In-Reply-To: <ZCs6jpo1nYe1Wm08@bombadil.infradead.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 <mcgrof@kernel.org> 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

  parent reply	other threads:[~2023-04-11 15:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-30 22:45 kmemleaks on ac3b43283923 ("module: replace module_layout with module_memory") jim.cromie
2023-03-31  6:59 ` Luis Chamberlain
2023-03-31 17:08   ` jim.cromie
2023-03-31 19:12     ` Luis Chamberlain
2023-03-31 21:42       ` jim.cromie
2023-04-01  0:27   ` Song Liu
2023-04-03 20:43     ` Luis Chamberlain
2023-04-05  1:38       ` jim.cromie
2023-04-05  2:01         ` Luis Chamberlain
2023-04-06  3:14           ` jim.cromie
2023-04-06 19:53             ` Luis Chamberlain
2023-04-11 15:10       ` Catalin Marinas [this message]
2023-04-11 17:07         ` Luis Chamberlain
2023-04-11 23:00           ` Luis Chamberlain
2023-04-12  9:53             ` Catalin Marinas
2023-04-12 17:22               ` Luis Chamberlain
2023-04-03 21:10 ` Konstantin Ryabitsev
2023-04-03 21:20 ` Kernel.org Bugbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZDV4YGjRpuqcI7F3@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jbaron@akamai.com \
    --cc=jim.cromie@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=song@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).