* [PATCH] fs: erofs: remember if kobject_init_and_add was done @ 2022-03-15 7:51 Dongliang Mu 2022-03-15 8:33 ` Gao Xiang 2022-03-15 10:43 ` Huang Jianan 0 siblings, 2 replies; 9+ messages in thread From: Dongliang Mu @ 2022-03-15 7:51 UTC (permalink / raw) To: Gao Xiang, Chao Yu; +Cc: Dongliang Mu, syzkaller, linux-erofs, linux-kernel From: Dongliang Mu <mudongliangabcd@gmail.com> Syzkaller hit 'WARNING: kobject bug in erofs_unregister_sysfs'. This bug is triggered by injecting fault in kobject_init_and_add of erofs_unregister_sysfs. Fix this by remembering if kobject_init_and_add is successful. Note that I've tested the patch and the crash does not occur any more. Reported-by: syzkaller <syzkaller@googlegroups.com> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com> --- fs/erofs/internal.h | 1 + fs/erofs/sysfs.c | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 5aa2cf2c2f80..9e20665e3f68 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -144,6 +144,7 @@ struct erofs_sb_info { u32 feature_incompat; /* sysfs support */ + bool s_sysfs_inited; struct kobject s_kobj; /* /sys/fs/erofs/<devname> */ struct completion s_kobj_unregister; }; diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c index dac252bc9228..2b48a4df19b4 100644 --- a/fs/erofs/sysfs.c +++ b/fs/erofs/sysfs.c @@ -209,6 +209,7 @@ int erofs_register_sysfs(struct super_block *sb) "%s", sb->s_id); if (err) goto put_sb_kobj; + sbi->s_sysfs_inited = true; return 0; put_sb_kobj: @@ -221,9 +222,11 @@ void erofs_unregister_sysfs(struct super_block *sb) { struct erofs_sb_info *sbi = EROFS_SB(sb); - kobject_del(&sbi->s_kobj); - kobject_put(&sbi->s_kobj); - wait_for_completion(&sbi->s_kobj_unregister); + if (sbi->s_sysfs_inited) { + kobject_del(&sbi->s_kobj); + kobject_put(&sbi->s_kobj); + wait_for_completion(&sbi->s_kobj_unregister); + } } int __init erofs_init_sysfs(void) -- 2.25.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] fs: erofs: remember if kobject_init_and_add was done 2022-03-15 7:51 [PATCH] fs: erofs: remember if kobject_init_and_add was done Dongliang Mu @ 2022-03-15 8:33 ` Gao Xiang 2022-03-15 10:43 ` Huang Jianan 1 sibling, 0 replies; 9+ messages in thread From: Gao Xiang @ 2022-03-15 8:33 UTC (permalink / raw) To: Dongliang Mu Cc: Gao Xiang, Chao Yu, Dongliang Mu, syzkaller, linux-erofs, linux-kernel On Tue, Mar 15, 2022 at 03:51:52PM +0800, Dongliang Mu wrote: > From: Dongliang Mu <mudongliangabcd@gmail.com> > > Syzkaller hit 'WARNING: kobject bug in erofs_unregister_sysfs'. This bug > is triggered by injecting fault in kobject_init_and_add of > erofs_unregister_sysfs. > > Fix this by remembering if kobject_init_and_add is successful. > > Note that I've tested the patch and the crash does not occur any more. > > Reported-by: syzkaller <syzkaller@googlegroups.com> > Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com> Thanks for the effort! Fixes: 168e9a76200c ("erofs: add sysfs interface") Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com> Thanks, Gao Xiang ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] fs: erofs: remember if kobject_init_and_add was done 2022-03-15 7:51 [PATCH] fs: erofs: remember if kobject_init_and_add was done Dongliang Mu 2022-03-15 8:33 ` Gao Xiang @ 2022-03-15 10:43 ` Huang Jianan 2022-03-15 10:55 ` Gao Xiang 1 sibling, 1 reply; 9+ messages in thread From: Huang Jianan @ 2022-03-15 10:43 UTC (permalink / raw) To: Dongliang Mu, Gao Xiang, Chao Yu Cc: syzkaller, linux-erofs, Dongliang Mu, linux-kernel 在 2022/3/15 15:51, Dongliang Mu 写道: > From: Dongliang Mu <mudongliangabcd@gmail.com> > > Syzkaller hit 'WARNING: kobject bug in erofs_unregister_sysfs'. This bug > is triggered by injecting fault in kobject_init_and_add of > erofs_unregister_sysfs. > > Fix this by remembering if kobject_init_and_add is successful. > > Note that I've tested the patch and the crash does not occur any more. > > Reported-by: syzkaller <syzkaller@googlegroups.com> > Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com> > --- > fs/erofs/internal.h | 1 + > fs/erofs/sysfs.c | 9 ++++++--- > 2 files changed, 7 insertions(+), 3 deletions(-) > > diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h > index 5aa2cf2c2f80..9e20665e3f68 100644 > --- a/fs/erofs/internal.h > +++ b/fs/erofs/internal.h > @@ -144,6 +144,7 @@ struct erofs_sb_info { > u32 feature_incompat; > > /* sysfs support */ > + bool s_sysfs_inited; Hi Dongliang, How about using sbi->s_kobj.state_in_sysfs to avoid adding a extra member in sbi ? Thanks, Jianan > struct kobject s_kobj; /* /sys/fs/erofs/<devname> */ > struct completion s_kobj_unregister; > }; > diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c > index dac252bc9228..2b48a4df19b4 100644 > --- a/fs/erofs/sysfs.c > +++ b/fs/erofs/sysfs.c > @@ -209,6 +209,7 @@ int erofs_register_sysfs(struct super_block *sb) > "%s", sb->s_id); > if (err) > goto put_sb_kobj; > + sbi->s_sysfs_inited = true; > return 0; > > put_sb_kobj: > @@ -221,9 +222,11 @@ void erofs_unregister_sysfs(struct super_block *sb) > { > struct erofs_sb_info *sbi = EROFS_SB(sb); > > - kobject_del(&sbi->s_kobj); > - kobject_put(&sbi->s_kobj); > - wait_for_completion(&sbi->s_kobj_unregister); > + if (sbi->s_sysfs_inited) { > + kobject_del(&sbi->s_kobj); > + kobject_put(&sbi->s_kobj); > + wait_for_completion(&sbi->s_kobj_unregister); > + } > } > > int __init erofs_init_sysfs(void) ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] fs: erofs: remember if kobject_init_and_add was done 2022-03-15 10:43 ` Huang Jianan @ 2022-03-15 10:55 ` Gao Xiang 2022-03-15 11:05 ` Huang Jianan 0 siblings, 1 reply; 9+ messages in thread From: Gao Xiang @ 2022-03-15 10:55 UTC (permalink / raw) To: Huang Jianan Cc: Dongliang Mu, Gao Xiang, Chao Yu, syzkaller, linux-erofs, Dongliang Mu, linux-kernel On Tue, Mar 15, 2022 at 06:43:01PM +0800, Huang Jianan wrote: > 在 2022/3/15 15:51, Dongliang Mu 写道: > > From: Dongliang Mu <mudongliangabcd@gmail.com> > > > > Syzkaller hit 'WARNING: kobject bug in erofs_unregister_sysfs'. This bug > > is triggered by injecting fault in kobject_init_and_add of > > erofs_unregister_sysfs. > > > > Fix this by remembering if kobject_init_and_add is successful. > > > > Note that I've tested the patch and the crash does not occur any more. > > > > Reported-by: syzkaller <syzkaller@googlegroups.com> > > Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com> > > --- > > fs/erofs/internal.h | 1 + > > fs/erofs/sysfs.c | 9 ++++++--- > > 2 files changed, 7 insertions(+), 3 deletions(-) > > > > diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h > > index 5aa2cf2c2f80..9e20665e3f68 100644 > > --- a/fs/erofs/internal.h > > +++ b/fs/erofs/internal.h > > @@ -144,6 +144,7 @@ struct erofs_sb_info { > > u32 feature_incompat; > > /* sysfs support */ > > + bool s_sysfs_inited; > > Hi Dongliang, > > How about using sbi->s_kobj.state_in_sysfs to avoid adding a extra member in > sbi ? Ok, I have no tendency of these (I'm fine with either ways). I've seen some usage like: static inline int device_is_registered(struct device *dev) { return dev->kobj.state_in_sysfs; } But I'm still not sure if we need to rely on such internal interface.. More thoughts? Thanks, Gao Xiang > > Thanks, > Jianan > > > struct kobject s_kobj; /* /sys/fs/erofs/<devname> */ > > struct completion s_kobj_unregister; > > }; > > diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c > > index dac252bc9228..2b48a4df19b4 100644 > > --- a/fs/erofs/sysfs.c > > +++ b/fs/erofs/sysfs.c > > @@ -209,6 +209,7 @@ int erofs_register_sysfs(struct super_block *sb) > > "%s", sb->s_id); > > if (err) > > goto put_sb_kobj; > > + sbi->s_sysfs_inited = true; > > return 0; > > put_sb_kobj: > > @@ -221,9 +222,11 @@ void erofs_unregister_sysfs(struct super_block *sb) > > { > > struct erofs_sb_info *sbi = EROFS_SB(sb); > > - kobject_del(&sbi->s_kobj); > > - kobject_put(&sbi->s_kobj); > > - wait_for_completion(&sbi->s_kobj_unregister); > > + if (sbi->s_sysfs_inited) { > > + kobject_del(&sbi->s_kobj); > > + kobject_put(&sbi->s_kobj); > > + wait_for_completion(&sbi->s_kobj_unregister); > > + } > > } > > int __init erofs_init_sysfs(void) ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] fs: erofs: remember if kobject_init_and_add was done 2022-03-15 10:55 ` Gao Xiang @ 2022-03-15 11:05 ` Huang Jianan 2022-03-15 11:59 ` Dongliang Mu 0 siblings, 1 reply; 9+ messages in thread From: Huang Jianan @ 2022-03-15 11:05 UTC (permalink / raw) To: Gao Xiang Cc: Dongliang Mu, Gao Xiang, Chao Yu, syzkaller, linux-erofs, Dongliang Mu, linux-kernel 在 2022/3/15 18:55, Gao Xiang 写道: > On Tue, Mar 15, 2022 at 06:43:01PM +0800, Huang Jianan wrote: >> 在 2022/3/15 15:51, Dongliang Mu 写道: >>> From: Dongliang Mu <mudongliangabcd@gmail.com> >>> >>> Syzkaller hit 'WARNING: kobject bug in erofs_unregister_sysfs'. This bug >>> is triggered by injecting fault in kobject_init_and_add of >>> erofs_unregister_sysfs. >>> >>> Fix this by remembering if kobject_init_and_add is successful. >>> >>> Note that I've tested the patch and the crash does not occur any more. >>> >>> Reported-by: syzkaller <syzkaller@googlegroups.com> >>> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com> >>> --- >>> fs/erofs/internal.h | 1 + >>> fs/erofs/sysfs.c | 9 ++++++--- >>> 2 files changed, 7 insertions(+), 3 deletions(-) >>> >>> diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h >>> index 5aa2cf2c2f80..9e20665e3f68 100644 >>> --- a/fs/erofs/internal.h >>> +++ b/fs/erofs/internal.h >>> @@ -144,6 +144,7 @@ struct erofs_sb_info { >>> u32 feature_incompat; >>> /* sysfs support */ >>> + bool s_sysfs_inited; >> Hi Dongliang, >> >> How about using sbi->s_kobj.state_in_sysfs to avoid adding a extra member in >> sbi ? > Ok, I have no tendency of these (I'm fine with either ways). > I've seen some usage like: > > static inline int device_is_registered(struct device *dev) > { > return dev->kobj.state_in_sysfs; > } > > But I'm still not sure if we need to rely on such internal > interface.. More thoughts? Yeah... It seems that it is better to use some of the interfaces provided by kobject, otherwise we should still maintain this state in sbi. Thanks, Jianan > Thanks, > Gao Xiang >> Thanks, >> Jianan >> >>> struct kobject s_kobj; /* /sys/fs/erofs/<devname> */ >>> struct completion s_kobj_unregister; >>> }; >>> diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c >>> index dac252bc9228..2b48a4df19b4 100644 >>> --- a/fs/erofs/sysfs.c >>> +++ b/fs/erofs/sysfs.c >>> @@ -209,6 +209,7 @@ int erofs_register_sysfs(struct super_block *sb) >>> "%s", sb->s_id); >>> if (err) >>> goto put_sb_kobj; >>> + sbi->s_sysfs_inited = true; >>> return 0; >>> put_sb_kobj: >>> @@ -221,9 +222,11 @@ void erofs_unregister_sysfs(struct super_block *sb) >>> { >>> struct erofs_sb_info *sbi = EROFS_SB(sb); >>> - kobject_del(&sbi->s_kobj); >>> - kobject_put(&sbi->s_kobj); >>> - wait_for_completion(&sbi->s_kobj_unregister); >>> + if (sbi->s_sysfs_inited) { >>> + kobject_del(&sbi->s_kobj); >>> + kobject_put(&sbi->s_kobj); >>> + wait_for_completion(&sbi->s_kobj_unregister); >>> + } >>> } >>> int __init erofs_init_sysfs(void) ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] fs: erofs: remember if kobject_init_and_add was done 2022-03-15 11:05 ` Huang Jianan @ 2022-03-15 11:59 ` Dongliang Mu 2022-03-15 12:25 ` Gao Xiang 0 siblings, 1 reply; 9+ messages in thread From: Dongliang Mu @ 2022-03-15 11:59 UTC (permalink / raw) To: Huang Jianan Cc: Gao Xiang, Dongliang Mu, Gao Xiang, Chao Yu, syzkaller, linux-erofs, linux-kernel On Tue, Mar 15, 2022 at 7:05 PM Huang Jianan <jnhuang95@gmail.com> wrote: > > 在 2022/3/15 18:55, Gao Xiang 写道: > > On Tue, Mar 15, 2022 at 06:43:01PM +0800, Huang Jianan wrote: > >> 在 2022/3/15 15:51, Dongliang Mu 写道: > >>> From: Dongliang Mu <mudongliangabcd@gmail.com> > >>> > >>> Syzkaller hit 'WARNING: kobject bug in erofs_unregister_sysfs'. This bug > >>> is triggered by injecting fault in kobject_init_and_add of > >>> erofs_unregister_sysfs. > >>> > >>> Fix this by remembering if kobject_init_and_add is successful. > >>> > >>> Note that I've tested the patch and the crash does not occur any more. > >>> > >>> Reported-by: syzkaller <syzkaller@googlegroups.com> > >>> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com> > >>> --- > >>> fs/erofs/internal.h | 1 + > >>> fs/erofs/sysfs.c | 9 ++++++--- > >>> 2 files changed, 7 insertions(+), 3 deletions(-) > >>> > >>> diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h > >>> index 5aa2cf2c2f80..9e20665e3f68 100644 > >>> --- a/fs/erofs/internal.h > >>> +++ b/fs/erofs/internal.h > >>> @@ -144,6 +144,7 @@ struct erofs_sb_info { > >>> u32 feature_incompat; > >>> /* sysfs support */ > >>> + bool s_sysfs_inited; > >> Hi Dongliang, > >> > >> How about using sbi->s_kobj.state_in_sysfs to avoid adding a extra member in > >> sbi ? > > Ok, I have no tendency of these (I'm fine with either ways). > > I've seen some usage like: > > > > static inline int device_is_registered(struct device *dev) > > { > > return dev->kobj.state_in_sysfs; > > } > > > > But I'm still not sure if we need to rely on such internal > > interface.. More thoughts? > > Yeah... It seems that it is better to use some of the interfaces > provided by kobject, > otherwise we should still maintain this state in sbi. > I am fine with either way. Let me know if you reach to an agreement. > Thanks, > Jianan > > > Thanks, > > Gao Xiang > >> Thanks, > >> Jianan > >> > >>> struct kobject s_kobj; /* /sys/fs/erofs/<devname> */ > >>> struct completion s_kobj_unregister; > >>> }; > >>> diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c > >>> index dac252bc9228..2b48a4df19b4 100644 > >>> --- a/fs/erofs/sysfs.c > >>> +++ b/fs/erofs/sysfs.c > >>> @@ -209,6 +209,7 @@ int erofs_register_sysfs(struct super_block *sb) > >>> "%s", sb->s_id); > >>> if (err) > >>> goto put_sb_kobj; > >>> + sbi->s_sysfs_inited = true; > >>> return 0; > >>> put_sb_kobj: > >>> @@ -221,9 +222,11 @@ void erofs_unregister_sysfs(struct super_block *sb) > >>> { > >>> struct erofs_sb_info *sbi = EROFS_SB(sb); > >>> - kobject_del(&sbi->s_kobj); > >>> - kobject_put(&sbi->s_kobj); > >>> - wait_for_completion(&sbi->s_kobj_unregister); > >>> + if (sbi->s_sysfs_inited) { > >>> + kobject_del(&sbi->s_kobj); > >>> + kobject_put(&sbi->s_kobj); > >>> + wait_for_completion(&sbi->s_kobj_unregister); > >>> + } > >>> } > >>> int __init erofs_init_sysfs(void) > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] fs: erofs: remember if kobject_init_and_add was done 2022-03-15 11:59 ` Dongliang Mu @ 2022-03-15 12:25 ` Gao Xiang 2022-03-15 12:44 ` Dongliang Mu 0 siblings, 1 reply; 9+ messages in thread From: Gao Xiang @ 2022-03-15 12:25 UTC (permalink / raw) To: Dongliang Mu Cc: Huang Jianan, Dongliang Mu, Gao Xiang, Chao Yu, syzkaller, linux-erofs, linux-kernel Hi Dongliang, On Tue, Mar 15, 2022 at 07:59:26PM +0800, Dongliang Mu wrote: > On Tue, Mar 15, 2022 at 7:05 PM Huang Jianan <jnhuang95@gmail.com> wrote: > > > > 在 2022/3/15 18:55, Gao Xiang 写道: > > > On Tue, Mar 15, 2022 at 06:43:01PM +0800, Huang Jianan wrote: > > >> 在 2022/3/15 15:51, Dongliang Mu 写道: > > >>> From: Dongliang Mu <mudongliangabcd@gmail.com> > > >>> > > >>> Syzkaller hit 'WARNING: kobject bug in erofs_unregister_sysfs'. This bug > > >>> is triggered by injecting fault in kobject_init_and_add of > > >>> erofs_unregister_sysfs. > > >>> > > >>> Fix this by remembering if kobject_init_and_add is successful. > > >>> > > >>> Note that I've tested the patch and the crash does not occur any more. > > >>> > > >>> Reported-by: syzkaller <syzkaller@googlegroups.com> > > >>> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com> > > >>> --- > > >>> fs/erofs/internal.h | 1 + > > >>> fs/erofs/sysfs.c | 9 ++++++--- > > >>> 2 files changed, 7 insertions(+), 3 deletions(-) > > >>> > > >>> diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h > > >>> index 5aa2cf2c2f80..9e20665e3f68 100644 > > >>> --- a/fs/erofs/internal.h > > >>> +++ b/fs/erofs/internal.h > > >>> @@ -144,6 +144,7 @@ struct erofs_sb_info { > > >>> u32 feature_incompat; > > >>> /* sysfs support */ > > >>> + bool s_sysfs_inited; > > >> Hi Dongliang, > > >> > > >> How about using sbi->s_kobj.state_in_sysfs to avoid adding a extra member in > > >> sbi ? > > > Ok, I have no tendency of these (I'm fine with either ways). > > > I've seen some usage like: > > > > > > static inline int device_is_registered(struct device *dev) > > > { > > > return dev->kobj.state_in_sysfs; > > > } > > > > > > But I'm still not sure if we need to rely on such internal > > > interface.. More thoughts? > > > > Yeah... It seems that it is better to use some of the interfaces > > provided by kobject, > > otherwise we should still maintain this state in sbi. > > > > I am fine with either way. Let me know if you reach to an agreement. If you have time, would you mind sending another patch by using state_in_sysfs? I'd like to know Chao's perference later, and apply one of them... Thanks, Gao Xiang ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] fs: erofs: remember if kobject_init_and_add was done 2022-03-15 12:25 ` Gao Xiang @ 2022-03-15 12:44 ` Dongliang Mu 2022-03-15 13:30 ` Dongliang Mu 0 siblings, 1 reply; 9+ messages in thread From: Dongliang Mu @ 2022-03-15 12:44 UTC (permalink / raw) To: Gao Xiang Cc: Huang Jianan, Dongliang Mu, Gao Xiang, Chao Yu, syzkaller, linux-erofs, linux-kernel On Tue, Mar 15, 2022 at 8:26 PM Gao Xiang <hsiangkao@linux.alibaba.com> wrote: > > Hi Dongliang, > > On Tue, Mar 15, 2022 at 07:59:26PM +0800, Dongliang Mu wrote: > > On Tue, Mar 15, 2022 at 7:05 PM Huang Jianan <jnhuang95@gmail.com> wrote: > > > > > > 在 2022/3/15 18:55, Gao Xiang 写道: > > > > On Tue, Mar 15, 2022 at 06:43:01PM +0800, Huang Jianan wrote: > > > >> 在 2022/3/15 15:51, Dongliang Mu 写道: > > > >>> From: Dongliang Mu <mudongliangabcd@gmail.com> > > > >>> > > > >>> Syzkaller hit 'WARNING: kobject bug in erofs_unregister_sysfs'. This bug > > > >>> is triggered by injecting fault in kobject_init_and_add of > > > >>> erofs_unregister_sysfs. > > > >>> > > > >>> Fix this by remembering if kobject_init_and_add is successful. > > > >>> > > > >>> Note that I've tested the patch and the crash does not occur any more. > > > >>> > > > >>> Reported-by: syzkaller <syzkaller@googlegroups.com> > > > >>> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com> > > > >>> --- > > > >>> fs/erofs/internal.h | 1 + > > > >>> fs/erofs/sysfs.c | 9 ++++++--- > > > >>> 2 files changed, 7 insertions(+), 3 deletions(-) > > > >>> > > > >>> diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h > > > >>> index 5aa2cf2c2f80..9e20665e3f68 100644 > > > >>> --- a/fs/erofs/internal.h > > > >>> +++ b/fs/erofs/internal.h > > > >>> @@ -144,6 +144,7 @@ struct erofs_sb_info { > > > >>> u32 feature_incompat; > > > >>> /* sysfs support */ > > > >>> + bool s_sysfs_inited; > > > >> Hi Dongliang, > > > >> > > > >> How about using sbi->s_kobj.state_in_sysfs to avoid adding a extra member in > > > >> sbi ? > > > > Ok, I have no tendency of these (I'm fine with either ways). > > > > I've seen some usage like: > > > > > > > > static inline int device_is_registered(struct device *dev) > > > > { > > > > return dev->kobj.state_in_sysfs; > > > > } > > > > > > > > But I'm still not sure if we need to rely on such internal > > > > interface.. More thoughts? > > > > > > Yeah... It seems that it is better to use some of the interfaces > > > provided by kobject, > > > otherwise we should still maintain this state in sbi. > > > > > > > I am fine with either way. Let me know if you reach to an agreement. > > If you have time, would you mind sending another patch by using > state_in_sysfs? I'd like to know Chao's perference later, and > apply one of them... OK, let me test this patch in my local workspace. If it works, I will send it later. > > Thanks, > Gao Xiang > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] fs: erofs: remember if kobject_init_and_add was done 2022-03-15 12:44 ` Dongliang Mu @ 2022-03-15 13:30 ` Dongliang Mu 0 siblings, 0 replies; 9+ messages in thread From: Dongliang Mu @ 2022-03-15 13:30 UTC (permalink / raw) To: Gao Xiang Cc: Huang Jianan, Dongliang Mu, Gao Xiang, Chao Yu, syzkaller, linux-erofs, linux-kernel On Tue, Mar 15, 2022 at 8:44 PM Dongliang Mu <mudongliangabcd@gmail.com> wrote: > > On Tue, Mar 15, 2022 at 8:26 PM Gao Xiang <hsiangkao@linux.alibaba.com> wrote: > > > > Hi Dongliang, > > > > On Tue, Mar 15, 2022 at 07:59:26PM +0800, Dongliang Mu wrote: > > > On Tue, Mar 15, 2022 at 7:05 PM Huang Jianan <jnhuang95@gmail.com> wrote: > > > > > > > > 在 2022/3/15 18:55, Gao Xiang 写道: > > > > > On Tue, Mar 15, 2022 at 06:43:01PM +0800, Huang Jianan wrote: > > > > >> 在 2022/3/15 15:51, Dongliang Mu 写道: > > > > >>> From: Dongliang Mu <mudongliangabcd@gmail.com> > > > > >>> > > > > >>> Syzkaller hit 'WARNING: kobject bug in erofs_unregister_sysfs'. This bug > > > > >>> is triggered by injecting fault in kobject_init_and_add of > > > > >>> erofs_unregister_sysfs. > > > > >>> > > > > >>> Fix this by remembering if kobject_init_and_add is successful. > > > > >>> > > > > >>> Note that I've tested the patch and the crash does not occur any more. > > > > >>> > > > > >>> Reported-by: syzkaller <syzkaller@googlegroups.com> > > > > >>> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com> > > > > >>> --- > > > > >>> fs/erofs/internal.h | 1 + > > > > >>> fs/erofs/sysfs.c | 9 ++++++--- > > > > >>> 2 files changed, 7 insertions(+), 3 deletions(-) > > > > >>> > > > > >>> diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h > > > > >>> index 5aa2cf2c2f80..9e20665e3f68 100644 > > > > >>> --- a/fs/erofs/internal.h > > > > >>> +++ b/fs/erofs/internal.h > > > > >>> @@ -144,6 +144,7 @@ struct erofs_sb_info { > > > > >>> u32 feature_incompat; > > > > >>> /* sysfs support */ > > > > >>> + bool s_sysfs_inited; > > > > >> Hi Dongliang, > > > > >> > > > > >> How about using sbi->s_kobj.state_in_sysfs to avoid adding a extra member in > > > > >> sbi ? > > > > > Ok, I have no tendency of these (I'm fine with either ways). > > > > > I've seen some usage like: > > > > > > > > > > static inline int device_is_registered(struct device *dev) > > > > > { > > > > > return dev->kobj.state_in_sysfs; > > > > > } > > > > > > > > > > But I'm still not sure if we need to rely on such internal > > > > > interface.. More thoughts? > > > > > > > > Yeah... It seems that it is better to use some of the interfaces > > > > provided by kobject, > > > > otherwise we should still maintain this state in sbi. > > > > > > > > > > I am fine with either way. Let me know if you reach to an agreement. > > > > If you have time, would you mind sending another patch by using > > state_in_sysfs? I'd like to know Chao's perference later, and > > apply one of them... > > OK, let me test this patch in my local workspace. If it works, I will > send it later. Hi Gao Xiang, I've sent another patch. Please double-check. > > > > > Thanks, > > Gao Xiang > > ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-03-15 13:31 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-03-15 7:51 [PATCH] fs: erofs: remember if kobject_init_and_add was done Dongliang Mu 2022-03-15 8:33 ` Gao Xiang 2022-03-15 10:43 ` Huang Jianan 2022-03-15 10:55 ` Gao Xiang 2022-03-15 11:05 ` Huang Jianan 2022-03-15 11:59 ` Dongliang Mu 2022-03-15 12:25 ` Gao Xiang 2022-03-15 12:44 ` Dongliang Mu 2022-03-15 13:30 ` Dongliang Mu
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).