linux/fs/overlayfs
Amir Goldstein a1e0eb8f55 ovl: check access to copy_file_range source with src mounter creds
Commit 5dae222a5f ("vfs: allow copy_file_range to copy across devices")
allowed filesystems that implement the copy_file_range() f_op to decide
if they want to access cross-sb copy from/to the same fs type.

The same commit added checks to verify same sb copy for filesystems that
implement ->copy_file_range() and do not support cross-sb copy at the
time, namely, to ceph, fuse and nfs.

The two remaining fs which implement ->copy_file_range(), cifs and
overlayfs started to support cross-sb copy from this time.

While overlayfs does support cross-sb copy when the two underlying files
are on the same base fs, the copy operation on the two real files from
two different overalyfs filesystems is performed with the mounter
creds of the destination overlayfs and the read permission access hook
for the source file was called with the wrong creds.

This could cause either deny of access to copy which would otherwise be
allowed (e.g. with splice) or allow read access to file which would
otherwise be denied.

Fix the latter case by explicitly verifying read access to source file
with the source overlayfs mounter creds.

The former case remains a quirk of cross-sb overlayfs copy, but
userspace could fall back to regular copy so no harm done.

Fixes: 5dae222a5f ("vfs: allow copy_file_range to copy across devices")
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Link: https://patch.msgid.link/20260712122421.203113-1-amir73il@gmail.com
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2026-07-22 16:42:28 +02:00
..
copy_up.c ovl: use linked upper dentry in copy-up tmpfile 2026-07-01 15:26:24 +02:00
dir.c Fixing livelocks in shrink_dcache_tree() 2026-04-21 07:30:44 -07:00
export.c vfs-7.1-rc1.kino 2026-04-13 12:19:01 -07:00
file.c ovl: check access to copy_file_range source with src mounter creds 2026-07-22 16:42:28 +02:00
inode.c ovl: fix comment about locking order 2026-07-01 15:26:25 +02:00
Kconfig fs: prepare for stackable filesystems backing file helpers 2023-12-23 16:35:08 +02:00
Makefile ovl: Move xattr support to new xattrs.c file 2023-10-31 00:12:59 +02:00
namei.c treewide: change inode->i_ino from unsigned long to u64 2026-03-06 14:31:28 +01:00
overlayfs.h vfs-7.1-rc1.directory 2026-04-13 10:24:33 -07:00
ovl_entry.h ovl: make fsync after metadata copy-up opt-in mount option 2026-03-27 12:48:10 +01:00
params.c ovl: make fsync after metadata copy-up opt-in mount option 2026-03-27 12:48:10 +01:00
params.h ovl: Prepare for mounting case-insensitive enabled layers 2025-09-23 12:29:35 +02:00
readdir.c ovl: keep err zero after successful ovl_cache_get() 2026-05-18 14:56:15 +02:00
super.c vfs-7.1-rc1.directory 2026-04-13 10:24:33 -07:00
util.c ovl: fix verity lazy-load guard broken by fsverity_active() semantic change 2026-05-06 08:37:30 -07:00
xattrs.c ovl: fix trusted xattr escape prefix matching 2026-07-22 13:48:00 +02:00