From: Paolo Abeni <pabeni@redhat.com>
To: Casey Schaufler <casey@schaufler-ca.com>,
linux-security-module@vger.kernel.org
Cc: Paul Moore <paul@paul-moore.com>,
James Morris <jmorris@namei.org>,
"Serge E. Hallyn" <serge@hallyn.com>,
Ondrej Mosnacek <omosnace@redhat.com>,
KP Singh <kpsingh@kernel.org>
Subject: Re: [PATCH RFC 0/3] security: allow a LSM to specify NO-OP return code
Date: Wed, 23 Aug 2023 17:06:30 +0200 [thread overview]
Message-ID: <7fb26856a6859ecdce8c54ed4ef552fb87d9ffca.camel@redhat.com> (raw)
In-Reply-To: <c993c896-730e-322e-5e97-7c4804d5192b@schaufler-ca.com>
Hello,
On Mon, 2023-08-07 at 11:57 -0700, Casey Schaufler wrote:
> On 8/3/2023 10:12 AM, Paolo Abeni wrote:
> > This is another attempt to solve the current problem with eBPF LSM,
> > already discussed at least in [1].
> >
> > The basic idea is to introduce the minimum amount of changes to let
> > the core consider a no-op any LSM hooks returning the
> > LSM_RET_DEFAULT [2].
> >
> > AFAICS that is already the case for most int hooks with LSM_RET_DEFAULT
> > equal to 0 due to the current call_int_hook implementation. Even most
> > int hook with non zero LSM_RET_DEFAULT are not problematic. Specifically
> > the hooks [3]:
> >
> > fs_context_parse_param
> > dentry_init_security
> > inode_getsecurity
> > inode_setsecurity
> > inode_copy_up_xattr
> > task_prctl
> > security_secid_to_secctx
> >
> > already have special handling for to basically ignore default return
> > value from the LSMs, while:
> >
> > security_getprocattr
> > security_setprocattr
> >
> > only operate on the specified LSM.
> >
> > The only hooks that need some love are:
> >
> > * hooks that have a 0 LSM_RET_DEFAULT, but with no LSM loaded returns a
> > non zero value to the security_<hook> caller:
> > sb_set_mnt_opts
> > inode_init_security
> > inode_getsecctx
> > socket_getpeersec_stream
> > socket_getpeersec_dgram
> >
> > * hooks that have a 0 LSM_RET_DEFAULT, but internally security_<hook>
> > uses a non zero return value as a selector to perform a default
> > action:
> > inode_setxattr
> > inode_removexattr
> >
> > * hooks the somehow have to reconciliate multiple, non-zero, LSM return
> > values to take a single decision:
> > vm_enough_memory
> > xfrm_state_pol_flow_match
> >
> > This series introduces a new variant of the call_int_hook macro and
> > changes the LSM_RET_DEFAULT for the mentioned hooks, to achieve the
> > goal [2].
> >
> > The patches have been split according to the above grouping with the
> > hope to simplify the reviews, but I guess could be squashed in a single
> > one.
> >
> > A simple follow-up would be extend the new hook usage to the hooks [3]
> > to reduce the code duplication.
> >
> > Sharing as an early RFC (with almost no testing) to try to understand if
> > this path is a no go or instead is somewhat viable.
>
> I am not an advocate of adding macros for these special cases.
> The only reason the existing macros are used is that open coding
> every hook with the exact same logic would have created an enormous
> security.c file. Special cases shouldn't be hidden. The reason they
> are special should be documented.
>
> Should the stacking patch set ever come in there are going to be
> more and more kinds of special cases. I don't see that adding code
> macros for each of the peculiar behaviors is a good idea.
First things first, thank you for your feedback and I'm sorry for the
very late reply: I have been off for the past few weeks.
I'm unsure how to interpret the above: is that an explicit nack to this
approach, it that almost an ack modulo some needed cleanup or something
in between ?!? ;)
Regarding the new macro introduced in patch 1/3, I think of it more as
a generalization then a special case. In fact it could replace all the
existing:
call_int_hook(/* */, 0, ...)
call sites with no functional changes expected (modulo bugs).
I avoided that change to keep the series small, but it could clean-up
the code in the longer run and help isolating which code really needs a
special case.
But I guess there is a certain degree of personal style preferences
with this kind changes.
Any additional feedback more then welcome!
Cheers,
Paolo
prev parent reply other threads:[~2023-08-23 15:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-03 17:12 [PATCH RFC 0/3] security: allow a LSM to specify NO-OP return code Paolo Abeni
2023-08-03 17:12 ` [PATCH RFC 1/3] security: introduce and use call_int_hook_ignore_default() Paolo Abeni
2023-08-03 17:12 ` [PATCH RFC 2/3] security: two more call_int_hook_ignore_default use-cases Paolo Abeni
2023-08-03 17:12 ` [PATCH RFC 3/3] security: " Paolo Abeni
2023-08-07 18:57 ` [PATCH RFC 0/3] security: allow a LSM to specify NO-OP return code Casey Schaufler
2023-08-23 15:06 ` Paolo Abeni [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=7fb26856a6859ecdce8c54ed4ef552fb87d9ffca.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=casey@schaufler-ca.com \
--cc=jmorris@namei.org \
--cc=kpsingh@kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=omosnace@redhat.com \
--cc=paul@paul-moore.com \
--cc=serge@hallyn.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).