linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: Fix missing close devices
@ 2020-09-21  7:29 qiang.zhang
  2020-09-21 12:55 ` Johannes Thumshirn
  2020-09-23 11:15 ` Nikolay Borisov
  0 siblings, 2 replies; 5+ messages in thread
From: qiang.zhang @ 2020-09-21  7:29 UTC (permalink / raw)
  To: clm, josef, dsterba; +Cc: linux-btrfs, linux-kernel

From: Zqiang <qiang.zhang@windriver.com>

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 <qiang.zhang@windriver.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: Fix missing close devices
  2020-09-21  7:29 [PATCH] btrfs: Fix missing close devices qiang.zhang
@ 2020-09-21 12:55 ` Johannes Thumshirn
  2020-09-23 11:15 ` Nikolay Borisov
  1 sibling, 0 replies; 5+ messages in thread
From: Johannes Thumshirn @ 2020-09-21 12:55 UTC (permalink / raw)
  To: qiang.zhang, clm, josef, dsterba; +Cc: linux-btrfs, linux-kernel

On 21/09/2020 13:00, qiang.zhang@windriver.com wrote:
> From: Zqiang <qiang.zhang@windriver.com>
> 
> 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 <qiang.zhang@windriver.com>
> ---
>  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);
>  	}
> 

Hmm you didn't change anything, so my report in [1] still exists.

[1] https://lore.kernel.org/r/SN4PR0401MB359820738AC6479F9F47FEE59B3A0@SN4PR0401MB3598.namprd04.prod.outlook.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: Fix missing close devices
  2020-09-21  7:29 [PATCH] btrfs: Fix missing close devices qiang.zhang
  2020-09-21 12:55 ` Johannes Thumshirn
@ 2020-09-23 11:15 ` Nikolay Borisov
  1 sibling, 0 replies; 5+ messages in thread
From: Nikolay Borisov @ 2020-09-23 11:15 UTC (permalink / raw)
  To: qiang.zhang, clm, josef, dsterba; +Cc: linux-btrfs, linux-kernel



On 21.09.20 г. 10:29 ч., qiang.zhang@windriver.com wrote:
> From: Zqiang <qiang.zhang@windriver.com>
> 
> 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 <qiang.zhang@windriver.com>
> ---
>  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);
>  	}
> 

NAK,

Devices are properly closed via:


deactivate_locked_super
  kill_sb (btrfs_kill_super)
    kill_anon_super
      generic_shutdown_super
       put_super (btrfs_put_super)
         close_ctree


It seems you haven't done deep enough analysis of the involved call chains.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: Fix missing close devices
  2020-09-21  8:26 qiang.zhang
@ 2020-09-21  8:52 ` Johannes Thumshirn
  0 siblings, 0 replies; 5+ messages in thread
From: Johannes Thumshirn @ 2020-09-21  8:52 UTC (permalink / raw)
  To: qiang.zhang, clm, josef, dsterba; +Cc: linux-btrfs, linux-kernel

On 21/09/2020 10:27, qiang.zhang@windriver.com wrote:
> From: Zqiang <qiang.zhang@windriver.com>
> 
> 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 <qiang.zhang@windriver.com>
> ---
>  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: syzbot+582e66e5edf36a22c7b0@syzkaller.appspotmail.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] btrfs: Fix missing close devices
@ 2020-09-21  8:26 qiang.zhang
  2020-09-21  8:52 ` Johannes Thumshirn
  0 siblings, 1 reply; 5+ messages in thread
From: qiang.zhang @ 2020-09-21  8:26 UTC (permalink / raw)
  To: clm, josef, dsterba, johannes.thumshirn; +Cc: linux-btrfs, linux-kernel

From: Zqiang <qiang.zhang@windriver.com>

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 <qiang.zhang@windriver.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-23 11:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-21  7:29 [PATCH] btrfs: Fix missing close devices qiang.zhang
2020-09-21 12:55 ` Johannes Thumshirn
2020-09-23 11:15 ` Nikolay Borisov
2020-09-21  8:26 qiang.zhang
2020-09-21  8:52 ` Johannes Thumshirn

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).