[RFC PATCH 0/2] security: Add pre-lookup pathname open check

From: Anastasios Papagiannis

Date: Fri Nov 20 2026 - 04:48:51 EST


Some security policies need to inspect the original open pathname, for
example to report or block suspected path traversal attempts. A resolved
pathname no longer preserves components such as "..", and requests that
fail lookup may never reach a hook exposing the resolved target.

Today, in Tetragon[1] we capture kernel-copied names through
getname/getname_flags probes and correlates them with open
results. Enforcement additionally probes do_open and passes decisions
through BPF maps to the file_open LSM hook. This requires correlating
state across several internal probes and the enforcement hook.

This series proposes security_file_open_name(), an LSM hook exposing
the kernel-copied pathname, the VFS-selected starting path, effective
open flags, creation mode and lookup flags before pathname traversal.
BPF LSM programs can inspect these arguments and reject requests before
file creation or truncation. Existing checks on the resolved object
continue to apply.

This is submitted as an RFC in order to get feedback on whether the
proposed LSM hook is a reasonable addition.

[1] https://github.com/cilium/tetragon

Anastasios Papagiannis (2):
security: Add hook for unresolved pathname opens
selftests/bpf: Test pathname open enforcement

fs/namei.c | 15 ++-
include/linux/lsm_hook_defs.h | 2 +
include/linux/security.h | 10 ++
security/security.c | 27 +++++
.../selftests/bpf/prog_tests/file_open_name.c | 103 ++++++++++++++++++
.../selftests/bpf/progs/file_open_name.c | 56 ++++++++++
6 files changed, 211 insertions(+), 2 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/file_open_name.c
create mode 100644 tools/testing/selftests/bpf/progs/file_open_name.c


base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.56.0