How to fix the bug in "WARNING: kobject bug in erofs_unregister_sysfs"?
Dongliang Mu
mudongliangabcd at gmail.com
Fri Mar 11 01:04:47 AEDT 2022
On Thu, Mar 10, 2022 at 8:39 PM Gao Xiang <hsiangkao at linux.alibaba.com> wrote:
>
> Hi Dongliang,
>
> (+ cc Jianan.)
>
> On Thu, Mar 10, 2022 at 06:15:20PM +0800, Dongliang Mu wrote:
> > Hi kernel developers,
> >
> > I am writing to kindly ask for some suggestions on fixing "WARNING:
> > kobject bug in erofs_unregister_sysfs".
> >
> > The underlying issue is in the following,
> >
> > erofs_fc_get_tree
> > -> get_tree_bdev
> > -> fill_super
> > -> erofs_fc_fill_super
> >
>
> Thanks for the report!
>
> > When erofs_register_sysfs fails in the calling kobject_init_and_add,
> > it just returned an error code and the parent function will call
> > deactivate_locked_super to do clean up.
>
> Yes, in that way we don't need to rewrite another error path (actually
> once we had another duplicated error path but Al suggested the current
> shape...)
>
> >
> > In the following stack trace, it finally calls erofs_unregister_sysfs
> > without knowing the execution status of erofs_register_sysfs, which
> > leads to the kobject bug.
> >
> > erofs_unregister_sysfs+0x46/0x60 fs/erofs/sysfs.c:225
> > erofs_put_super+0x37/0xb0 fs/erofs/super.c:771
> > generic_shutdown_super+0x14c/0x400 fs/super.c:465
> > kill_block_super+0x97/0xf0 fs/super.c:1397
> > erofs_kill_sb+0x60/0x190 fs/erofs/super.c:752
> > deactivate_locked_super+0x94/0x160 fs/super.c:335
> > get_tree_bdev+0x573/0x760 fs/super.c:1297
> >
> > I am not sure how to fix this bug. Any suggestion is appreciated.
>
> I think a simple way is to introduce a `sysfs_inited' boolean to
> sbi to indicate that. Or some better suggestion is welcomed.
Yes, it's an idea to use a boolean to indicate the execution status.
Let me first try to craft a drafted patch and test it on Syzbot.
>
> Thanks,
> Gao Xiang
>
> >
> > --
> > My best regards to you.
> >
> > No System Is Safe!
> > Dongliang Mu
More information about the Linux-erofs
mailing list