diff options
| author | Filipe Manana <fdmanana@suse.com> | 2024-08-02 09:38:51 +0100 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-08-19 05:45:49 +0200 |
| commit | 1a607d22dea4f60438747705495ec4d0af2ec451 (patch) | |
| tree | 212ba79a921c3f3e9f5348f5d5f8ca2d5a03f65b | |
| parent | f754591b17d0ee91c2b45fe9509d0cdc420527cb (diff) | |
| download | linux-1a607d22dea4f60438747705495ec4d0af2ec451.tar.gz linux-1a607d22dea4f60438747705495ec4d0af2ec451.tar.bz2 linux-1a607d22dea4f60438747705495ec4d0af2ec451.zip | |
btrfs: fix double inode unlock for direct IO sync writes
commit e0391e92f9ab4fb3dbdeb139c967dcfa7ac4b115 upstream.
If we do a direct IO sync write, at btrfs_sync_file(), and we need to skip
inode logging or we get an error starting a transaction or an error when
flushing delalloc, we end up unlocking the inode when we shouldn't under
the 'out_release_extents' label, and then unlock it again at
btrfs_direct_write().
Fix that by checking if we have to skip inode unlocking under that label.
Reported-by: syzbot+7dbbb74af6291b5a5a8b@syzkaller.appspotmail.com
Link: https://lore.kernel.org/linux-btrfs/000000000000dfd631061eaeb4bc@google.com/
Fixes: 939b656bc8ab ("btrfs: fix corruption after buffer fault in during direct IO append write")
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | fs/btrfs/file.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 7ca49c02e8f8..c44dfb4370d7 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2433,7 +2433,10 @@ out: out_release_extents: btrfs_release_log_ctx_extents(&ctx); - btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP); + if (skip_ilock) + up_write(&BTRFS_I(inode)->i_mmap_lock); + else + btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP); goto out; } |
