[PATCH 00/13] fs: let d_real() fail

From: Christian Brauner

Date: Sun Nov 15 2026 - 09:02:41 EST


overlayfs looks up the data of a metacopy file in a data-only layer
lazily and validates its verity digest when it's first needed. Both can
fail but d_real() has no way to report it. So ovl_d_real() warns and
hands back the overlayfs dentry and every caller silently works with an
inode that doesn't host the data:

- uprobes get created just fine and fail later with a bogus -EIO. Every
new uprobe warns again for each of them. With panic_on_warn that's a
panic.
- IMA skips detecting changes to the backing file and hands out a cached
verdict.
- IPE evaluates its policy against an inode that has none of the
dm-verity or fs-verity properties of the real file.

And that's not limited to files nobody opened yet. A metadata-only
copy-up of an open file makes overlayfs validate the digest again.

As Amir pointed out the correct fix is to teach the callers to deal with
an error. So d_real() may now fail for D_REAL_DATA and all callers
handle it: uprobes fail when they're created, IMA treats it like failing
to hash the file, IPE denies and the bpf kfunc returns NULL. Then
d_real_inode() goes away so nobody can ignore the error again. The first
patch only drops the WARN.

This came out of the same work as the freeze protection fixes for
backing files (cf. [1]). I ran into it with the pseudo filesystem
series (cf. [2]) where file_check_backing() looks at the file hosting
the data of O_PATH files registered for fuse passthrough. With this
series it can just return the error. But this stands on its own.

[1]: https://lore.kernel.org/r/20261114-work-fs-frozen_writes-v1-0-f5ae61c898b1@xxxxxxxxxx
[2]: https://lore.kernel.org/r/20261114-work-loop-pseudo-v2-0-98639a2286fb@xxxxxxxxxx

Signed-off-by: Christian Brauner (Amutable) <brauner@xxxxxxxxxx>
---
Christian Brauner (13):
ovl: don't warn when the lazy lowerdata lookup fails in ovl_d_real()
fs: add d_real_data_inode() and d_real_metadata_inode()
tracing/uprobes: handle errors from resolving the real inode
bpf: handle errors from resolving the real inode in uprobe_multi
selftests/bpf: handle d_real_data_inode() errors in bpf_testmod
ima: handle errors from resolving the real inode
ima,evm: use d_real_metadata_inode()
ipe: handle errors from resolving the real inode
bpf: return NULL from bpf_real_data_inode() on errors
ovl: return the error from the lazy lowerdata lookup in ovl_d_real()
fs: remove d_real_inode()
selftests/ftrace: add uprobe tests on overlayfs
selftests/bpf: add uprobe_multi test on overlayfs without data

Documentation/filesystems/porting.rst | 10 ++
Documentation/filesystems/vfs.rst | 6 +
fs/bpf_fs_kfuncs.c | 13 +-
fs/overlayfs/super.c | 19 ++-
include/linux/dcache.h | 47 ++++++-
kernel/trace/bpf_trace.c | 9 +-
kernel/trace/trace_probe.h | 1 +
kernel/trace/trace_uprobe.c | 57 +++++++--
security/integrity/evm/evm_crypto.c | 2 +-
security/integrity/ima/ima_api.c | 17 ++-
security/integrity/ima/ima_main.c | 11 +-
security/ipe/eval.c | 15 ++-
security/ipe/eval.h | 1 +
.../selftests/bpf/prog_tests/uprobe_multi_test.c | 141 +++++++++++++++++++++
.../testing/selftests/bpf/test_kmods/bpf_testmod.c | 11 +-
.../test.d/dynevent/add_remove_uprobe_overlayfs.tc | 92 ++++++++++++++
16 files changed, 408 insertions(+), 44 deletions(-)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261115-work-ovl-d_real-219930df9ec3