2020-09-21 08:28:48

by Zhang, Qiang

[permalink] [raw]
Subject: [PATCH] btrfs: Fix missing close devices

From: Zqiang <[email protected]>

When the btrfs fill super error, we should first close devices and
then call deactivate_locked_super func to free fs_info.

Signed-off-by: Zqiang <[email protected]>
---
fs/btrfs/super.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 8840a4fa81eb..3bfd54e8f388 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1675,6 +1675,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
error = security_sb_set_mnt_opts(s, new_sec_opts, 0, NULL);
security_free_mnt_opts(&new_sec_opts);
if (error) {
+ btrfs_close_devices(fs_devices);
deactivate_locked_super(s);
return ERR_PTR(error);
}
--
2.17.1


2020-09-21 08:53:43

by Johannes Thumshirn

[permalink] [raw]
Subject: Re: [PATCH] btrfs: Fix missing close devices

On 21/09/2020 10:27, [email protected] wrote:
> From: Zqiang <[email protected]>
>
> When the btrfs fill super error, we should first close devices and
> then call deactivate_locked_super func to free fs_info.
>
> Signed-off-by: Zqiang <[email protected]>
> ---
> fs/btrfs/super.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 8840a4fa81eb..3bfd54e8f388 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -1675,6 +1675,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
> error = security_sb_set_mnt_opts(s, new_sec_opts, 0, NULL);
> security_free_mnt_opts(&new_sec_opts);
> if (error) {
> + btrfs_close_devices(fs_devices);
> deactivate_locked_super(s);
> return ERR_PTR(error);
> }
>

I think this is the fix for the syzkaller issue:
Reported-by: [email protected]

2020-09-21 09:15:38

by Zhang, Qiang

[permalink] [raw]
Subject: 回复: [PATCH] btrfs: Fix missing close device s



________________________________________
??????: Johannes Thumshirn <[email protected]>
????ʱ??: 2020??9??21?? 16:52
?ռ???: Zhang, Qiang; [email protected]; [email protected]; [email protected]
????: [email protected]; [email protected]
????: Re: [PATCH] btrfs: Fix missing close devices

On 21/09/2020 10:27, [email protected] wrote:
> From: Zqiang <[email protected]>
>
> When the btrfs fill super error, we should first close devices and
> then call deactivate_locked_super func to free fs_info.
>
> Signed-off-by: Zqiang <[email protected]>
> ---
> fs/btrfs/super.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 8840a4fa81eb..3bfd54e8f388 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -1675,6 +1675,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
> error = security_sb_set_mnt_opts(s, new_sec_opts, 0, NULL);
> security_free_mnt_opts(&new_sec_opts);
> if (error) {
> + btrfs_close_devices(fs_devices);
> deactivate_locked_super(s);
> return ERR_PTR(error);
> }
>

>I think this is the fix for the syzkaller issue:
>Reported-by: [email protected]

Please try this patch.