The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serge@hallyn.com>
To: Christian Brauner <brauner@kernel.org>
Cc: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>,
	linux-security-module@vger.kernel.org, bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	paul@paul-moore.com, jmorris@namei.org, viro@zeniv.linux.org.uk,
	jack@suse.cz, ast@kernel.org, daniel@iogearbox.net,
	andrii@kernel.org, kpsingh@kernel.org, matt@bobrowski.net,
	eddyz87@gmail.com
Subject: Re: [RFC PATCH 0/2] security: Add pre-lookup pathname open check
Date: Wed, 2 Dec 2026 09:36:20 -0600	[thread overview]
Message-ID: <axA69Ju93XRbfvMR@hallyn.com> (raw)
In-Reply-To: <20261202-funkhaus-bernhardiner-gedreht-d212d37a1254@brauner>

On Wed, Dec 02, 2026 at 03:35:14PM +0100, Christian Brauner wrote:
> 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.

FWIW, I agree here.  This seems the wrong place to solve this.

-serge

      reply	other threads:[~2026-12-02 15:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  9:48 [RFC PATCH 0/2] security: Add pre-lookup pathname open check Anastasios Papagiannis
2026-11-20  9:48 ` [RFC PATCH 1/2] security: Add hook for unresolved pathname opens Anastasios Papagiannis
2026-11-20 10:44   ` bot+bpf-ci
2026-11-20  9:48 ` [RFC PATCH 2/2] selftests/bpf: Test pathname open enforcement Anastasios Papagiannis
2026-12-02 14:35 ` [RFC PATCH 0/2] security: Add pre-lookup pathname open check Christian Brauner
2026-12-02 15:36   ` Serge E. Hallyn [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=axA69Ju93XRbfvMR@hallyn.com \
    --to=serge@hallyn.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brauner@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=jack@suse.cz \
    --cc=jmorris@namei.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=matt@bobrowski.net \
    --cc=paul@paul-moore.com \
    --cc=tasos.papagiannnis@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox