linux-stable/fs/overlayfs
Amir Goldstein 124c2de2c0 ovl: relax WARN_ON() when decoding lower directory file handle
Decoding a lower directory file handle to overlay path with cold
inode/dentry cache may go as follows:

1. Decode real lower file handle to lower dir path
2. Check if lower dir is indexed (was copied up)
3. If indexed, get the upper dir path from index
4. Lookup upper dir path in overlay
5. If overlay path found, verify that overlay lower is the lower dir
   from step 1

On failure to verify step 5 above, user will get an ESTALE error and a
WARN_ON will be printed.

A mismatch in step 5 could be a result of lower directory that was renamed
while overlay was offline, after that lower directory has been copied up
and indexed.

This is a scripted reproducer based on xfstest overlay/052:

  # Create lower subdir
  create_dirs
  create_test_files $lower/lowertestdir/subdir
  mount_dirs
  # Copy up lower dir and encode lower subdir file handle
  touch $SCRATCH_MNT/lowertestdir
  test_file_handles $SCRATCH_MNT/lowertestdir/subdir -p -o $tmp.fhandle
  # Rename lower dir offline
  unmount_dirs
  mv $lower/lowertestdir $lower/lowertestdir.new/
  mount_dirs
  # Attempt to decode lower subdir file handle
  test_file_handles $SCRATCH_MNT -p -i $tmp.fhandle

Since this WARN_ON() can be triggered by user we need to relax it.

Fixes: 4b91c30a5a ("ovl: lookup connected ancestor of dir in inode cache")
Cc: <stable@vger.kernel.org> # v4.16+
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2020-07-16 00:09:17 +02:00
..
copy_up.c ovl: change ovl_copy_up_flags static 2020-07-16 00:06:16 +02:00
dir.c ovl: initialize OVL_UPPERDATA in ovl_lookup() 2020-06-02 22:20:25 +02:00
export.c ovl: relax WARN_ON() when decoding lower directory file handle 2020-07-16 00:09:17 +02:00
file.c ovl: only pass ->ki_flags to ovl_iocb_to_rwf() 2020-06-04 10:48:19 +02:00
inode.c overlayfs update for 5.8 2020-06-09 15:40:50 -07: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: remove not used argument in ovl_check_origin 2020-07-16 00:06:16 +02:00
overlayfs.h ovl: change ovl_copy_up_flags static 2020-07-16 00:06:16 +02:00
ovl_entry.h ovl: get rid of redundant members in struct ovl_fs 2020-06-04 10:48:19 +02:00
readdir.c ovl: add accessor for ofs->upper_mnt 2020-06-04 10:48:19 +02:00
super.c ovl: inode reference leak in ovl_is_inuse true case. 2020-07-16 00:05:40 +02:00
util.c ovl: add accessor for ofs->upper_mnt 2020-06-04 10:48:19 +02:00