linux/fs/overlayfs
Miklos Szeredi b854cc659d ovl: avoid deadlock on directory ioctl
The function ovl_dir_real_file() currently uses the inode lock to serialize
writes to the od->upperfile field.

However, this function will get called by ovl_ioctl_set_flags(), which
utilizes the inode lock too.  In this case ovl_dir_real_file() will try to
claim a lock that is owned by a function in its call stack, which won't get
released before ovl_dir_real_file() returns.

Fix by replacing the open coded compare and exchange by an explicit atomic
op.

Fixes: 61536bed21 ("ovl: support [S|G]ETFLAGS and FS[S|G]ETXATTR ioctls for directories")
Cc: stable@vger.kernel.org # v5.10
Reported-by: Icenowy Zheng <icenowy@aosc.io>
Tested-by: Icenowy Zheng <icenowy@aosc.io>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2021-01-28 10:22:48 +01:00
..
copy_up.c ovl: do not fail when setting origin xattr 2020-12-14 15:26:14 +01:00
dir.c ovl: pass ovl_fs down to functions accessing private xattrs 2020-09-02 10:58:49 +02:00
export.c ovl: propagate ovl_fs to ovl_decode_real_fh and ovl_encode_real_fh 2020-11-12 11:31:55 +01:00
file.c ovl: do not fail because of O_NOATIME 2020-12-14 15:26:14 +01:00
inode.c ovl: perform vfs_getxattr() with mounter creds 2021-01-28 10:22:48 +01:00
Kconfig docs: fix broken references to text files 2020-04-20 15:35:59 -06:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
namei.c ovl: check privs before decoding file handle 2020-12-14 15:26:14 +01:00
overlayfs.h ovl: user xattr 2020-12-14 15:26:14 +01:00
ovl_entry.h ovl: user xattr 2020-12-14 15:26:14 +01:00
readdir.c ovl: avoid deadlock on directory ioctl 2021-01-28 10:22:48 +01:00
super.c ovl: add warning on user_ns mismatch 2021-01-28 10:22:48 +01:00
util.c ovl: do not get metacopy for userxattr 2020-12-14 15:26:14 +01:00