Skip to content

Commit a942da2

Browse files
mudonglianghsiangkao
authored andcommitted
fs: erofs: add sanity check for kobject in erofs_unregister_sysfs
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 adding sanity check for kobject in erofs_unregister_sysfs Note that I've tested the patch and the crash does not occur any more. Link: https://lore.kernel.org/r/20220315132814.12332-1-dzm91@hust.edu.cn Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com> Fixes: 168e9a7 ("erofs: add sysfs interface") Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
1 parent 9f2731d commit a942da2

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

fs/erofs/sysfs.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,11 @@ void erofs_unregister_sysfs(struct super_block *sb)
221221
{
222222
struct erofs_sb_info *sbi = EROFS_SB(sb);
223223

224-
kobject_del(&sbi->s_kobj);
225-
kobject_put(&sbi->s_kobj);
226-
wait_for_completion(&sbi->s_kobj_unregister);
224+
if (sbi->s_kobj.state_in_sysfs) {
225+
kobject_del(&sbi->s_kobj);
226+
kobject_put(&sbi->s_kobj);
227+
wait_for_completion(&sbi->s_kobj_unregister);
228+
}
227229
}
228230

229231
int __init erofs_init_sysfs(void)

0 commit comments

Comments
 (0)