2022-03-12 15:50:02

by Pavel Skripkin

[permalink] [raw]
Subject: Re: Fw:Re: [PATCH] fs: nilfs2: fix memory leak in nilfs sysfs create device group

Hi Ryusuke,

On 3/12/22 18:11, Ryusuke Konishi wrote:
>> In case of nilfs_attach_log_writer() error code jumps to
>> failed_checkpoint label and calls destroy_nilfs() which should call
>> nilfs_sysfs_delete_device_group().
>
> nilfs_sysfs_delete_device_group() is called in destroy_nilfs()
> if nilfs->ns_flags has THE_NILFS_INIT flag -- nilfs_init() inline
> function tests this flag.
>
> The flag is set after init_nilfs() succeeded at the beginning of
> nilfs_fill_super() because the set_nilfs_init() inline in init_nilfs() sets it.
>
> So, nilfs_sysfs_delete_group() seems to be called in case of
> the above failure. Am I missing something?
>

Yeah, that's what I mean :) I can't see how reported issue is possible
with current code.


Sorry for not being clear




With regards,
Pavel Skripkin


2022-03-13 00:44:24

by Ryusuke Konishi

[permalink] [raw]
Subject: Re: Fw:Re: [PATCH] fs: nilfs2: fix memory leak in nilfs sysfs create device group

Hi Pavel and Dongliang,

On Sun, Mar 13, 2022 at 12:16 AM Pavel Skripkin <[email protected]> wrote:
>
> Hi Ryusuke,
>
> On 3/12/22 18:11, Ryusuke Konishi wrote:
> >> In case of nilfs_attach_log_writer() error code jumps to
> >> failed_checkpoint label and calls destroy_nilfs() which should call
> >> nilfs_sysfs_delete_device_group().
> >
> > nilfs_sysfs_delete_device_group() is called in destroy_nilfs()
> > if nilfs->ns_flags has THE_NILFS_INIT flag -- nilfs_init() inline
> > function tests this flag.
> >
> > The flag is set after init_nilfs() succeeded at the beginning of
> > nilfs_fill_super() because the set_nilfs_init() inline in init_nilfs() sets it.
> >
> > So, nilfs_sysfs_delete_group() seems to be called in case of
> > the above failure. Am I missing something?
> >
>
> Yeah, that's what I mean :) I can't see how reported issue is possible
> with current code.
>
>
> Sorry for not being clear

Understood, thanks for the reply.

If so, the case where nilfs_sysfs_create_device_group() itself failed,
is suspicious as mentioned in the previous mail. A possible scenario
I guess is :

- nilfs_sysfs_create_device_group() on the first mount try fails and leaks
due to lack of kobject_del() in the error path.
- Then, nilfs_sysfs_create_device_group() on the next mount try hits
the leak detector at kobject_init_and_add().

So, if the leak bug is reproducible, I'd like to ask Dongliang to
test the effect of the first patch.

Regards,
Ryusuke Konishi

>
>
>
> With regards,
> Pavel Skripkin

2022-03-14 04:33:53

by Dongliang Mu

[permalink] [raw]
Subject: Re: Fw:Re: [PATCH] fs: nilfs2: fix memory leak in nilfs sysfs create device group

On Sun, Mar 13, 2022 at 12:01 AM Ryusuke Konishi
<[email protected]> wrote:
>
> Hi Pavel and Dongliang,
>
> On Sun, Mar 13, 2022 at 12:16 AM Pavel Skripkin <[email protected]> wrote:
> >
> > Hi Ryusuke,
> >
> > On 3/12/22 18:11, Ryusuke Konishi wrote:
> > >> In case of nilfs_attach_log_writer() error code jumps to
> > >> failed_checkpoint label and calls destroy_nilfs() which should call
> > >> nilfs_sysfs_delete_device_group().
> > >
> > > nilfs_sysfs_delete_device_group() is called in destroy_nilfs()
> > > if nilfs->ns_flags has THE_NILFS_INIT flag -- nilfs_init() inline
> > > function tests this flag.
> > >
> > > The flag is set after init_nilfs() succeeded at the beginning of
> > > nilfs_fill_super() because the set_nilfs_init() inline in init_nilfs() sets it.
> > >
> > > So, nilfs_sysfs_delete_group() seems to be called in case of
> > > the above failure. Am I missing something?
> > >
> >
> > Yeah, that's what I mean :) I can't see how reported issue is possible
> > with current code.
> >
> >
> > Sorry for not being clear
>
> Understood, thanks for the reply.
>
> If so, the case where nilfs_sysfs_create_device_group() itself failed,
> is suspicious as mentioned in the previous mail. A possible scenario
> I guess is :
>
> - nilfs_sysfs_create_device_group() on the first mount try fails and leaks
> due to lack of kobject_del() in the error path.
> - Then, nilfs_sysfs_create_device_group() on the next mount try hits
> the leak detector at kobject_init_and_add().
>
> So, if the leak bug is reproducible, I'd like to ask Dongliang to
> test the effect of the first patch.

If my local syzkaller instance gets a reproducer, I will try to do this.

>
> Regards,
> Ryusuke Konishi
>
> >
> >
> >
> > With regards,
> > Pavel Skripkin

2022-03-17 04:31:18

by Dongliang Mu

[permalink] [raw]
Subject: Re: Fw:Re: [PATCH] fs: nilfs2: fix memory leak in nilfs sysfs create device group

On Sun, Mar 13, 2022 at 9:35 PM Dongliang Mu <[email protected]> wrote:
>
> On Sun, Mar 13, 2022 at 12:01 AM Ryusuke Konishi
> <[email protected]> wrote:
> >
> > Hi Pavel and Dongliang,
> >
> > On Sun, Mar 13, 2022 at 12:16 AM Pavel Skripkin <[email protected]> wrote:
> > >
> > > Hi Ryusuke,
> > >
> > > On 3/12/22 18:11, Ryusuke Konishi wrote:
> > > >> In case of nilfs_attach_log_writer() error code jumps to
> > > >> failed_checkpoint label and calls destroy_nilfs() which should call
> > > >> nilfs_sysfs_delete_device_group().
> > > >
> > > > nilfs_sysfs_delete_device_group() is called in destroy_nilfs()
> > > > if nilfs->ns_flags has THE_NILFS_INIT flag -- nilfs_init() inline
> > > > function tests this flag.
> > > >
> > > > The flag is set after init_nilfs() succeeded at the beginning of
> > > > nilfs_fill_super() because the set_nilfs_init() inline in init_nilfs() sets it.
> > > >
> > > > So, nilfs_sysfs_delete_group() seems to be called in case of
> > > > the above failure. Am I missing something?
> > > >
> > >
> > > Yeah, that's what I mean :) I can't see how reported issue is possible
> > > with current code.
> > >
> > >
> > > Sorry for not being clear
> >
> > Understood, thanks for the reply.
> >
> > If so, the case where nilfs_sysfs_create_device_group() itself failed,
> > is suspicious as mentioned in the previous mail. A possible scenario
> > I guess is :
> >
> > - nilfs_sysfs_create_device_group() on the first mount try fails and leaks
> > due to lack of kobject_del() in the error path.
> > - Then, nilfs_sysfs_create_device_group() on the next mount try hits
> > the leak detector at kobject_init_and_add().
> >
> > So, if the leak bug is reproducible, I'd like to ask Dongliang to
> > test the effect of the first patch.
>
> If my local syzkaller instance gets a reproducer, I will try to do this.
>
> >
> > Regards,
> > Ryusuke Konishi

Hi Ryusuke,

The crash still occurred in my newly set up syzkaller instance. It
appears after two days' fuzzing.

I remember you suggested me to add kobject_del just for testing,
right? And let's see if this crash still occurs any more.

> >
> > >
> > >
> > >
> > > With regards,
> > > Pavel Skripkin