linux-brain/fs/overlayfs
Miklos Szeredi 89f15c6e82 ovl: proper cleanup of workdir
commit eea2fb4851 upstream.

When mounting overlayfs it needs a clean "work" directory under the
supplied workdir.

Previously the mount code removed this directory if it already existed and
created a new one.  If the removal failed (e.g. directory was not empty)
then it fell back to a read-only mount not using the workdir.

While this has never been reported, it is possible to get a non-empty
"work" dir from a previous mount of overlayfs in case of crash in the
middle of an operation using the work directory.

In this case the left over state should be discarded and the overlay
filesystem will be consistent, guaranteed by the atomicity of operations on
moving to/from the workdir to the upper layer.

This patch implements cleaning out any files left in workdir.  It is
implemented using real recursion for simplicity, but the depth is limited
to 2, because the worst case is that of a directory containing whiteouts
under "work".

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: SZ Lin (林上智) <sz.lin@moxa.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-15 09:40:41 +02:00
..
copy_up.c ovl: override creds with the ones from the superblock mounter 2018-09-15 09:40:41 +02:00
dir.c ovl: override creds with the ones from the superblock mounter 2018-09-15 09:40:41 +02:00
inode.c ovl: filter trusted xattr for non-admin 2018-04-13 19:50:14 +02:00
Kconfig ovl: rename filesystem type to "overlay" 2014-11-20 16:39:59 +01:00
Makefile ovl: rename filesystem type to "overlay" 2014-11-20 16:39:59 +01:00
overlayfs.h ovl: proper cleanup of workdir 2018-09-15 09:40:41 +02:00
readdir.c ovl: proper cleanup of workdir 2018-09-15 09:40:41 +02:00
super.c ovl: proper cleanup of workdir 2018-09-15 09:40:41 +02:00