diff mbox series

btrfs: Add missing skip-lock for locks

Message ID tencent_8F5362E361A97883B8444B1763F777C6DF05@qq.com (mailing list archive)
State New, archived
Headers show
Series btrfs: Add missing skip-lock for locks | expand

Commit Message

Edward Adam Davis Aug. 2, 2024, 11:54 a.m. UTC
The commit 939b656bc8ab missing a skip-lock in btrfs_sync_file,
it cause syzbot report WARNING: bad unlock balance in btrfs_direct_write.

Fixes: 939b656bc8ab ("btrfs: fix corruption after buffer fault in during direct IO append write")
Reported-and-tested-by: syzbot+7dbbb74af6291b5a5a8b@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=7dbbb74af6291b5a5a8b
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
 fs/btrfs/file.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Filipe Manana Aug. 2, 2024, 12:29 p.m. UTC | #1
On Fri, Aug 2, 2024 at 12:59 PM Edward Adam Davis <eadavis@qq.com> wrote:
>
> The commit 939b656bc8ab missing a skip-lock in btrfs_sync_file,
> it cause syzbot report WARNING: bad unlock balance in btrfs_direct_write.
>
> Fixes: 939b656bc8ab ("btrfs: fix corruption after buffer fault in during direct IO append write")
> Reported-and-tested-by: syzbot+7dbbb74af6291b5a5a8b@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=7dbbb74af6291b5a5a8b
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>

I had already a submitted a fix for this hours ago:

https://lore.kernel.org/linux-btrfs/7aa71067c2946ea3a7165f26899324e0df7d772e.1722588255.git.fdmanana@suse.com/

Thanks.

> ---
>  fs/btrfs/file.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index 9f10a9f23fcc..9914419f3b7d 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -1868,7 +1868,10 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
>
>  out_release_extents:
>         btrfs_release_log_ctx_extents(&ctx);
> -       btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
> +       if (skip_ilock)
> +               up_write(&inode->i_mmap_lock);
> +       else
> +               btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
>         goto out;
>  }
>
> --
> 2.43.0
>
>
diff mbox series

Patch

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 9f10a9f23fcc..9914419f3b7d 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1868,7 +1868,10 @@  int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 
 out_release_extents:
 	btrfs_release_log_ctx_extents(&ctx);
-	btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
+	if (skip_ilock)
+		up_write(&inode->i_mmap_lock);
+	else
+		btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP);
 	goto out;
 }