]> git.ipfire.org Git - thirdparty/linux.git/commit
btrfs: file_remove_privs needs an exclusive lock in direct io write
authorBernd Schubert <bschubert@ddn.com>
Wed, 6 Sep 2023 15:59:03 +0000 (17:59 +0200)
committerDavid Sterba <dsterba@suse.com>
Wed, 13 Sep 2023 16:41:03 +0000 (18:41 +0200)
commit9af86694fd5d387992699ec99007ed374966ce9a
tree4ce62de59e4fd9344ad6bfae2d7fa99101b20c92
parent06ed09351b67eb1114ae106a87a0ee3ea9adb3db
btrfs: file_remove_privs needs an exclusive lock in direct io write

This was noticed by Miklos that file_remove_privs might call into
notify_change(), which requires to hold an exclusive lock. The problem
exists in FUSE and btrfs. We can fix it without any additional helpers
from VFS, in case the privileges would need to be dropped, change the
lock type to be exclusive and redo the loop.

Fixes: e9adabb9712e ("btrfs: use shared lock for direct writes within EOF")
CC: Miklos Szeredi <miklos@szeredi.hu>
CC: stable@vger.kernel.org # 5.15+
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bernd Schubert <bschubert@ddn.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/file.c