public inbox for linux-security-module@vger.kernel.org
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@meta.com>
To: Paul Moore <paul@paul-moore.com>
Cc: Song Liu <songliubraving@meta.com>, Song Liu <song@kernel.org>,
	"linux-security-module@vger.kernel.org"
	<linux-security-module@vger.kernel.org>,
	"jmorris@namei.org" <jmorris@namei.org>,
	"serge@hallyn.com" <serge@hallyn.com>,
	Kernel Team <kernel-team@meta.com>,
	Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Subject: Re: [PATCH] lsm: make SECURITY_PATH always enabled
Date: Wed, 23 Apr 2025 20:54:24 +0000	[thread overview]
Message-ID: <8F162586-EB42-4CFA-B97E-314AF2FDB830@fb.com> (raw)
In-Reply-To: <CAHC9VhRQzEGvMxyZY5Ke+GFYHr9OOF=-cTVqsK14=cfGJwy1bQ@mail.gmail.com>



> On Apr 23, 2025, at 7:58 AM, Paul Moore <paul@paul-moore.com> wrote:

[...]

>>> Without putting much thought into what would fall under
>>> CONFIG_SECURITY_INODE, I think it would be interesting to see what
>>> hooks one might be able to make conditional on such a Kconfig knob.
>>> Using security_inode_permission() as a simple test, it looks like only
>>> SELinux and Smack provide implementations, spot checks on a few other
>>> security_*inode*() hooks shows similar, or even more limited, results.
>>> 
>>> You would need to spend some time to determine what LSM hooks are used
>>> by which LSMs and adjust their Kconfigs appropriately for the new
>>> CONFIG_SECURITY_INODE knob, but if you do that then I think that would
>>> be okay.
>> 
>> Well, I was hoping to simplify the CONFIGs by removing one. So I am
>> not sure whether adding a new CONFIG is the right thing to do.
> 
> Ah, in that case I suspect you're going to be disappointed as I'm
> fairly confident we don't want to consolidate the inode and path based
> hooks under one Kconfig knob at this point in time.  If anything, I
> think there may be some value in adding an inode Kconfig as described
> above, which I realize isn't your original goal, but still ... :)

I am thinking whether it is possible to have each LSM selects required 
hooks, and only enable those at compile time. OTOH, my primary focus is
BPF LSM, so these optimizations matter little for my use cases. 


>>>> OR, maybe we should just remove security_inode_rmdir(), and users of
>>>> security_inode_rmdir() can just use security_path_rmdir() instead?
>>> 
>>> Those two LSM hooks are called from slightly different places in the
>>> codepath which has an impact on their environment.  For example, the
>>> inode variant doesn't have to deal with directory inodes that don't
>>> have a defined rmdir op, whereas the path variant does; the inode
>>> variant doesn't have to worry about S_KERNEL_FILE files, the inode
>>> variant has a refcount'd and locked dentry, etc.  Moving an existing
>>> LSM, especially complex ones, from one LSM hook to another, is a
>>> delicate operation and might not be worth it for such a small return.
>> 
>> Given there is pushback when a new LSM hook is added, I assume
>> removing a hook (or merge two hooks into one) may be a good move.
>> Well, it is totally possible that I underestimated the complexity of
>> the work.
> 
> The funny thing is that the difficulty in adding LSM hooks is one of
> the main reasons why I am so hesitant to remove an existing hook; you
> can consider it as perhaps an unintended consequence of a general
> hostility towards the LSM.

I didn't expect this. Thanks for sharing your thoughts. 

> 
> Regardless of the above, yes, there can be a lot of complexity
> involved in adding, modifying, or consolidating LSM hooks as there can
> be decades worth of assumptions both in the LSMs and in the caller
> that need to be considered for each change.  Of course that doesn't
> mean such change can't happen - we have plenty of examples where it
> has - but such changes are often more complicated than they appear.


Song



  reply	other threads:[~2025-04-23 20:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-22 18:44 [PATCH] lsm: make SECURITY_PATH always enabled Song Liu
2025-04-22 19:53 ` Paul Moore
2025-04-22 20:31   ` Song Liu
2025-04-22 21:13     ` Paul Moore
2025-04-23  4:57       ` Song Liu
2025-04-23 14:58         ` Paul Moore
2025-04-23 20:54           ` Song Liu [this message]
2025-04-23 21:23             ` Paul Moore

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=8F162586-EB42-4CFA-B97E-314AF2FDB830@fb.com \
    --to=songliubraving@meta.com \
    --cc=jmorris@namei.org \
    --cc=kernel-team@meta.com \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=serge@hallyn.com \
    --cc=song@kernel.org \
    /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