• Miklos Szeredi's avatar
    ovl: avoid deadlock on directory ioctl · b854cc65
    Miklos Szeredi authored
    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: 61536bed ("ovl: support [S|G]ETFLAGS and FS[S|G]ETXATTR ioctls for directories")
    Cc: stable@vger.kernel.org # v5.10
    Reported-by: default avatarIcenowy Zheng <icenowy@aosc.io>
    Tested-by: default avatarIcenowy Zheng <icenowy@aosc.io>
    Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
    b854cc65
readdir.c 27.7 KB