Re: [RFC PATCH 0/2] security: Add pre-lookup pathname open check
From: Christian Brauner
Date: Wed Dec 02 2026 - 09:35:40 EST
On Fri, Nov 20, 2026 at 11:48:18AM +0200, Anastasios Papagiannis wrote:
> 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.
That's really weird. The string doesn't tell you at all what gets
opened. The hook only sees the string userspace passed in. Symlink
bodies, magic links like /proc/self/fd/N and mount crossings all happen
after it ran.
The raw_symlink test illustrates that. The hook sees "./alias", not
"target". So a ".." filter is bypassed by a symlink whose target
contains "..", and bind mounts make the same file reachable under any
number of names.
Whatever the policy infers about where the string leads can also change
through a concurrent rename or mount before we walk it.
If you want to keep a lookup from escaping a directory that's
RESOLVE_BENEATH or RESOLVE_IN_ROOT. They check ".." during the walk on
the actual dentries, fail with -EAGAIN if a rename or mount raced with
it and also cover absolute symlinks and magic links.
> BPF LSM programs can inspect these arguments and reject requests before
> file creation or truncation.
You can already do that on the object? security_path_mknod() and
security_inode_create() run before we create the file and
security_file_open() runs before we truncate it.
This also puts an LSM call into path_init() which every lookup goes
through and grows struct nameidata for all of them and calls the hook up
to 3 times per open: RCU walk, ref-walk, LOOKUP_REVAL. So it also makes
LOOKUP_RCU and the -ECHILD retry part of an LSM interface. That VFS
guts, so no.
Tetragon already gets the name from its probes and that's fine for
observability. I don't want LSM hooks used as a tracing interface for
names? That seems very misguided.