diff mbox series

[1/2] super: move lockdep assert

Message ID 20230828-vfs-super-fixes-v1-1-b37a4a04a88f@kernel.org (mailing list archive)
State New, archived
Headers show
Series Small follow-up fixes for this cycle | expand

Commit Message

Christian Brauner Aug. 28, 2023, 11:26 a.m. UTC
Fix braino and move the lockdep assertion after put_super() otherwise we
risk a use-after-free.

Fixes: 2c18a63b760a ("super: wait until we passed kill super")
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 fs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Kara Aug. 28, 2023, 11:55 a.m. UTC | #1
On Mon 28-08-23 13:26:23, Christian Brauner wrote:
> Fix braino and move the lockdep assertion after put_super() otherwise we
> risk a use-after-free.
> 
> Fixes: 2c18a63b760a ("super: wait until we passed kill super")
> Signed-off-by: Christian Brauner <brauner@kernel.org>

Yeah, pretty obvious. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/super.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/super.c b/fs/super.c
> index ef87103e2a51..779247eb219c 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -570,8 +570,8 @@ static bool grab_super_dead(struct super_block *sb)
>  		return true;
>  	}
>  	wait_var_event(&sb->s_flags, wait_dead(sb));
> -	put_super(sb);
>  	lockdep_assert_not_held(&sb->s_umount);
> +	put_super(sb);
>  	return false;
>  }
>  
> 
> -- 
> 2.34.1
>
Christoph Hellwig Aug. 28, 2023, 12:01 p.m. UTC | #2
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/fs/super.c b/fs/super.c
index ef87103e2a51..779247eb219c 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -570,8 +570,8 @@  static bool grab_super_dead(struct super_block *sb)
 		return true;
 	}
 	wait_var_event(&sb->s_flags, wait_dead(sb));
-	put_super(sb);
 	lockdep_assert_not_held(&sb->s_umount);
+	put_super(sb);
 	return false;
 }