[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YjCV9PEK6nE7ufjd@B-P7TQMD6M-0146.local>
Date: Tue, 15 Mar 2022 21:34:44 +0800
From: Gao Xiang <hsiangkao@...ux.alibaba.com>
To: Dongliang Mu <dzm91@...t.edu.cn>
Cc: Gao Xiang <xiang@...nel.org>, Chao Yu <chao@...nel.org>,
Dongliang Mu <mudongliangabcd@...il.com>,
linux-erofs@...ts.ozlabs.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fs: erofs: add sanity check for kobject in
erofs_unregister_sysfs
On Tue, Mar 15, 2022 at 09:28:14PM +0800, Dongliang Mu wrote:
> From: Dongliang Mu <mudongliangabcd@...il.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 adding sanity check for kobject in erofs_unregister_sysfs
>
> Note that I've tested the patch and the crash does not occur any more.
>
> Signed-off-by: Dongliang Mu <mudongliangabcd@...il.com>
Reviewed-by: Gao Xiang <hsiangkao@...ux.alibaba.com>
Thanks,
Gao Xiang
> ---
> fs/erofs/sysfs.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c
> index dac252bc9228..f3babf1e6608 100644
> --- a/fs/erofs/sysfs.c
> +++ b/fs/erofs/sysfs.c
> @@ -221,9 +221,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_kobj.state_in_sysfs) {
> + 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
Powered by blists - more mailing lists