ovl: fix missing upper fs freeze protection on copy up for ioctl
authorAmir Goldstein <amir73il@gmail.com>
Tue, 22 Jan 2019 05:01:39 +0000 (07:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 May 2019 16:23:30 +0000 (18:23 +0200)
commita9676c96e7e06f3f90e9f2e7413b949dfc4d2df5
tree754081249c0550e8573e26e20b46fd662db1c688
parent979d2433b873cde6d2d360644754d16fe9c5481b
ovl: fix missing upper fs freeze protection on copy up for ioctl

commit 3428030da004a1128cbdcf93dc03e16f184d845b upstream.

Generalize the helper ovl_open_maybe_copy_up() and use it to copy up file
with data before FS_IOC_SETFLAGS ioctl.

The FS_IOC_SETFLAGS ioctl is a bit of an odd ball in vfs, which probably
caused the confusion.  File may be open O_RDONLY, but ioctl modifies the
file.  VFS does not call mnt_want_write_file() nor lock inode mutex, but
fs-specific code for FS_IOC_SETFLAGS does.  So ovl_ioctl() calls
mnt_want_write_file() for the overlay file, and fs-specific code calls
mnt_want_write_file() for upper fs file, but there was no call for
ovl_want_write() for copy up duration which prevents overlayfs from copying
up on a frozen upper fs.

Fixes: dab5ca8fd9dd ("ovl: add lsattr/chattr support")
Cc: <stable@vger.kernel.org> # v4.19
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/overlayfs/copy_up.c
fs/overlayfs/file.c
fs/overlayfs/overlayfs.h