Re: [PATCH RFC v2 33/42] fs: add file_check_backing()
From: bot+bpf-ci
Date: Sat Nov 14 2026 - 08:56:13 EST
> fs: add file_check_backing()
TL;DR: file_check_backing() may call d_real_inode() on O_PATH overlayfs files,
which could hit WARN in ovl_d_real() (panic with panic_on_warn) and let the
pseudo-fs check pass wrongly; reachable via fuse backing open, needs
CAP_SYS_ADMIN.
> diff --git a/fs/read_write.c b/fs/read_write.c
> --- a/fs/read_write.c
> +++ b/fs/read_write.c
[ ... ]
> +int file_check_backing(const struct file *file, fmode_t mode, umode_t type)
> +{
[ ... ]
> + /* Look through stacking filesystems at the inode with the data. */
> + if (d_real_inode(file->f_path.dentry)->i_sb->s_iflags & SB_I_PSEUDO)
> + return -EINVAL;
With FMODE_PATH accepted, can d_real_inode() be reached for an O_PATH file
here? No ->open() has run on such a file.
For an overlayfs metacopy file whose data is in a data-only lower layer,
the lowerdata redirect is only resolved lazily, by ovl_open() via
ovl_verify_lowerdata() or by ovl_d_real(). For an O_PATH file this means
d_real_inode() goes into ovl_d_real(), which does the lookup and verity
check itself:
err = ovl_verify_lowerdata(dentry);
if (err)
goto bug;
...
bug:
WARN(1, "%s(%pd4, %d): real dentry not found\n", __func__, dentry, type);
return dentry;
ovl_maybe_lookup_lowerdata() treats a failed lookup as a normal runtime
event (pr_warn_ratelimited("lazy lowerdata lookup failed ...")). It can
also return -EINTR from ovl_inode_lock_interruptible(), and
ovl_maybe_validate_verity() returns -EIO for a missing or wrong digest with
verity=require. Each of these would hit WARN(1) when reached through this
helper, which panics with panic_on_warn.
In that case ovl_d_real() returns the overlayfs dentry, so the SB_I_PSEUDO
test looks at the overlayfs superblock and passes. Does the check fail
open there?
Nothing calls the helper in this commit, but later in the series
f79b9e79484f ("fuse: refuse files on pseudo filesystems as passthrough
backing files") adds file_check_backing(file, FMODE_PATH, 0) to
fuse_backing_open_file(). That gets its fd via CLASS(fd_raw), which
accepts O_PATH:
FUSE_DEV_IOC_BACKING_OPEN
fuse_backing_new()
fuse_backing_open_file()
file_check_backing()
d_real_inode()
ovl_d_real()
ovl_verify_lowerdata() fails -> WARN
This needs CAP_SYS_ADMIN and an overlayfs with data-only layers where the
data file is missing, the digest check fails, or the inode lock is
contended while a signal is pending. No fix for this was found later in
the series.
Could the pseudo filesystem check avoid forcing the lazy lowerdata lookup
on O_PATH files, or should ovl_d_real() stop warning on lookup failures now
that it has callers besides trace_uprobe?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/43599461726