From: Al Viro <viro@zeniv.linux.org.uk>
To: "tianjia.zhang" <tianjia.zhang@linux.alibaba.com>
Cc: Mateusz Guzik <mjguzik@gmail.com>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] file: Call security_file_alloc() after initializing the filp
Date: Fri, 12 Dec 2025 15:51:14 +0000 [thread overview]
Message-ID: <20251212155114.GG1712166@ZenIV> (raw)
In-Reply-To: <038af1cc-a0f1-46a6-8382-5bca44161aee@linux.alibaba.com>
On Fri, Dec 12, 2025 at 06:01:53PM +0800, tianjia.zhang wrote:
> The scenario is as follows: I have hooked all LSM functions and
> abstracted struct file into an object using higher-level logic. In my
> handler functions, I need to print the file path of this object for
> debugging purposes. However, doing so will cause a crash unless I
> explicitly know that handler in the file_alloc_security context—which,
> in my case, I don't.
>
> Of course, obtaining the path isn't strictly required; I understand that
> in certain situations—such as during initialization—there may be no
> valid path at all. Even so, it would be acceptable if I could reliably
> determine from filp->f_path that fetching the path is inappropriate. The
> problem is that, without knowing whether I'm in the file_alloc_security
> context, I have no reliable way to decide whether it's safe to attempt
> retrieving the path.
<sarcasm>
"I can't figure out which of the functions in my code is calling (directly)
this function in my code; there's a predicate that might allow me to do
that, but it doesn't really work without this change to function outside
of my code. With this change I can make the things work; no, I won't
tell you which predicate it is, you'll just have to avoid any changes
in the area in the future, lest my code breaks".
</sarcasm>
In case it's not obvious from the above, your reasoning is unconvincing.
next prev parent reply other threads:[~2025-12-12 15:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-09 7:53 [PATCH] file: Call security_file_alloc() after initializing the filp Tianjia Zhang
2025-12-09 8:22 ` Mateusz Guzik
2025-12-12 10:01 ` tianjia.zhang
2025-12-12 11:44 ` Mateusz Guzik
2025-12-12 15:51 ` Al Viro [this message]
2025-12-09 9:13 ` Al Viro
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=20251212155114.GG1712166@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mjguzik@gmail.com \
--cc=tianjia.zhang@linux.alibaba.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.