Re: [PATCH] btrfs: Add missing skip-lock for locks
From: Filipe Manana
Date: Fri Aug 02 2024 - 08:29:55 EST
On Fri, Aug 2, 2024 at 12:59 PM Edward Adam Davis <eadavis@xxxxxx> 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@xxxxxxxxxxxxxxxxxxxxxxxxx
> Closes: https://syzkaller.appspot.com/bug?extid=7dbbb74af6291b5a5a8b
> Signed-off-by: Edward Adam Davis <eadavis@xxxxxx>
I had already a submitted a fix for this hours ago:
https://lore.kernel.org/linux-btrfs/7aa71067c2946ea3a7165f26899324e0df7d772e.1722588255.git.fdmanana@xxxxxxxx/
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
>
>