]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
btrfs: fix double inode unlock for direct IO sync writes
authorFilipe Manana <fdmanana@suse.com>
Fri, 2 Aug 2024 08:38:51 +0000 (09:38 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Aug 2024 13:34:38 +0000 (15:34 +0200)
commitd924a0be2f218501588cf463d70f1c71afea06d9
treece7c5031671800888b8c2aa9c3b43d2c7bc358a6
parentec87dd6084532e192d4ef27fce8a435c5b8a4407
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>
fs/btrfs/file.c