Re: kmemleaks on ac3b43283923 ("module: replace module_layout with module_memory")

From: Luis Chamberlain
Date: Tue Apr 04 2023 - 22:01:38 EST


On Tue, Apr 04, 2023 at 07:38:41PM -0600, jim.cromie@xxxxxxxxx wrote:
> On Mon, Apr 3, 2023 at 2:44 PM Luis Chamberlain <mcgrof@xxxxxxxxxx> 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@xxxxxxxxxx> wrote:
> > > >
> > > > On Thu, Mar 30, 2023 at 04:45:43PM -0600, jim.cromie@xxxxxxxxx wrote:
> > > > > hi Luis, etal
> > > > >
> > > > > 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.
> >
> > Catalinas, any thoughts / suggestions? Should we just stick to
> > kmemleak_not_leak() for both now?
> >
> > Luis
>
> So I have mixed results.
>
> your patch fixed the 19 leaks on my worktree / branch where I found them.
>
> on top of
> ac3b43283923 module: replace module_layout with module_memory
>
> it fixed the (same) 19, but gets a few new ones.
> whats weird is that once they report, they disappear from
> /sys/kernel/debug/kmemleak

I think I missed the MOD_INIT_DATA and MOD_INIT_RODATA. Can you try the
patch below instead: