linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: Stephen Smalley <stephen.smalley.work@gmail.com>
Cc: linux-security-module@vger.kernel.org,
	linux-integrity@vger.kernel.org, selinux@vger.kernel.org,
	"John Johansen" <john.johansen@canonical.com>,
	"Mimi Zohar" <zohar@linux.ibm.com>,
	"Roberto Sassu" <roberto.sassu@huawei.com>,
	"Fan Wu" <wufan@kernel.org>, "Mickaël Salaün" <mic@digikod.net>,
	"Günther Noack" <gnoack@google.com>,
	"Kees Cook" <kees@kernel.org>,
	"Micah Morton" <mortonm@chromium.org>,
	"Casey Schaufler" <casey@schaufler-ca.com>,
	"Tetsuo Handa" <penguin-kernel@i-love.sakura.ne.jp>
Subject: Re: [RFC PATCH 26/29] selinux: move initcalls to the LSM framework
Date: Thu, 10 Apr 2025 23:24:00 -0400	[thread overview]
Message-ID: <CAHC9VhTDrVMW8LLbNwQ=ApcpQmdoFWk5RLMEyMBJygQLFJNE2w@mail.gmail.com> (raw)
In-Reply-To: <CAEjxPJ6ZUXoMzKPE6iwQpvG-_SruVr+kxU-a+nQXU=ToVr8wgA@mail.gmail.com>

On Thu, Apr 10, 2025 at 12:33 PM Stephen Smalley
<stephen.smalley.work@gmail.com> wrote:
> On Wed, Apr 9, 2025 at 2:55 PM Paul Moore <paul@paul-moore.com> wrote:
> >
> > SELinux currently has a number of initcalls so we've created a new
> > function, selinux_initcall(), which wraps all of these initcalls so
> > that we have a single initcall function that can be registered with the
> > LSM framework.
> >
> > Signed-off-by: Paul Moore <paul@paul-moore.com>
> > ---
>
> > diff --git a/security/selinux/include/audit.h b/security/selinux/include/audit.h
> > index d5b0425055e4..5989f8dd1e86 100644
> > --- a/security/selinux/include/audit.h
> > +++ b/security/selinux/include/audit.h
> > @@ -15,6 +15,11 @@
> >  #include <linux/audit.h>
> >  #include <linux/types.h>
> >
> > +/**
> > + * XXX
> > + */
>
> Assuming this will be fixed before merge.

Yep, I noticed that very shortly after posting and added the comment block.

> > +int selinux_audit_rule_avc_callback(u32 event);
> > +
> >  /**
> >   * selinux_audit_rule_init - alloc/init an selinux audit rule structure.
> >   * @field: the field this rule refers to
> > diff --git a/security/selinux/include/initcalls.h b/security/selinux/include/initcalls.h
> > new file mode 100644
> > index 000000000000..6674cf489473
> > --- /dev/null
> > +++ b/security/selinux/include/initcalls.h
> > @@ -0,0 +1,19 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * SELinux initcalls
> > + */
> > +
> > +#ifndef _SELINUX_INITCALLS_H
> > +#define _SELINUX_INITCALLS_H
> > +
> > +int init_sel_fs(void);
> > +int sel_netport_init(void);
> > +int sel_netnode_init(void);
> > +int sel_netif_init(void);
> > +int sel_netlink_init(void);
> > +int sel_ib_pkey_init(void);
> > +int selinux_nf_ip_init(void);
>
> The last two only exist if certain Kconfig options are set.

Good catch, thanks.  The use of the netfilter initcall is already
conditional on CONFIG_NETFILTER in selinux_initcall(), but I forgot
the InfiniBand inticall.

Unless I'm mistaken, it should be harmless to have the function
declaration regardless of if it is defined anywhere.

> > diff --git a/security/selinux/initcalls.c b/security/selinux/initcalls.c
> > new file mode 100644
> > index 000000000000..81f01f8ad215
> > --- /dev/null
> > +++ b/security/selinux/initcalls.c
> > @@ -0,0 +1,50 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * SELinux initcalls
> > + */
> > +
> > +#include <linux/init.h>
> > +
> > +#include "initcalls.h"
> > +
> > +/**
> > + * selinux_initcall - Perform the SELinux initcalls
> > + *
> > + * Used as a device initcall in the SELinux LSM definition.
> > + */
> > +int __init selinux_initcall(void)
> > +{
> > +       int rc = 0, rc_tmp = 0;
> > +
> > +       rc_tmp = init_sel_fs();
> > +       if (!rc && rc_tmp)
> > +               rc = rc_tmp;
> > +
> > +       rc_tmp = sel_netport_init();
> > +       if (!rc && rc_tmp)
> > +               rc = rc_tmp;
> > +
> > +       rc_tmp = sel_netnode_init();
> > +       if (!rc && rc_tmp)
> > +               rc = rc_tmp;
> > +
> > +       rc_tmp = sel_netif_init();
> > +       if (!rc && rc_tmp)
> > +               rc = rc_tmp;
> > +
> > +       rc_tmp = sel_netlink_init();
> > +       if (!rc && rc_tmp)
> > +               rc = rc_tmp;
> > +
> > +       rc_tmp = sel_ib_pkey_init();
>
> This one depends on CONFIG_SECURITY_INFINIBAND.

Fixed, thanks.

> > +       if (!rc && rc_tmp)
> > +               rc = rc_tmp;
> > +
> > +#if defined(CONFIG_NETFILTER)
> > +       rc_tmp = selinux_nf_ip_init();
> > +       if (!rc && rc_tmp)
> > +               rc = rc_tmp;
> > +#endif
> > +
> > +       return rc;
> > +}

-- 
paul-moore.com

  reply	other threads:[~2025-04-11  3:24 UTC|newest]

Thread overview: 126+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-09 18:49 [RFC PATCH 0/29] Rework the LSM initialization Paul Moore
2025-04-09 18:49 ` [RFC PATCH 01/29] lsm: split the notifier code out into lsm_notifier.c Paul Moore
2025-04-09 21:17   ` Kees Cook
2025-04-15 12:14   ` John Johansen
2025-04-09 18:49 ` [RFC PATCH 02/29] lsm: split the init code out into lsm_init.c Paul Moore
2025-04-09 21:18   ` Kees Cook
2025-04-15 22:01   ` John Johansen
2025-04-09 18:49 ` [RFC PATCH 03/29] lsm: simplify prepare_lsm() and rename to lsm_prep_single() Paul Moore
2025-04-09 21:30   ` Kees Cook
2025-04-09 21:54     ` Paul Moore
2025-04-15 22:10   ` John Johansen
2025-04-09 18:49 ` [RFC PATCH 04/29] lsm: simplify ordered_lsm_init() and rename to lsm_init_ordered() Paul Moore
2025-04-09 21:38   ` Kees Cook
2025-04-09 22:31     ` Paul Moore
2025-04-09 18:49 ` [RFC PATCH 05/29] lsm: replace the name field with a pointer to the lsm_id struct Paul Moore
2025-04-09 21:40   ` Kees Cook
2025-04-15 22:20   ` John Johansen
2025-04-09 18:49 ` [RFC PATCH 06/29] lsm: cleanup and normalize the LSM order symbols naming Paul Moore
2025-04-09 23:00   ` Kees Cook
2025-04-15 22:23   ` John Johansen
2025-04-09 18:49 ` [RFC PATCH 07/29] lsm: rework lsm_active_cnt and lsm_idlist[] Paul Moore
2025-04-09 21:38   ` Casey Schaufler
2025-04-10 21:58     ` Paul Moore
2025-04-09 23:06   ` Kees Cook
2025-04-10 22:04     ` Paul Moore
2025-04-10 22:25       ` Kees Cook
2025-04-11  0:58         ` Casey Schaufler
2025-04-09 18:49 ` [RFC PATCH 08/29] lsm: get rid of the lsm_names list and do some cleanup Paul Moore
2025-04-09 23:13   ` Kees Cook
2025-04-10 22:47     ` Paul Moore
2025-04-11  2:15       ` Kees Cook
2025-04-11  3:14         ` Paul Moore
2025-04-15 22:30       ` John Johansen
2025-05-22 21:26   ` Casey Schaufler
2025-04-09 18:49 ` [RFC PATCH 09/29] lsm: cleanup and normalize the LSM enabled functions Paul Moore
2025-04-10  0:11   ` Kees Cook
2025-04-11  1:50     ` Paul Moore
2025-04-11  2:03       ` Paul Moore
2025-04-11  2:14       ` Paul Moore
2025-04-11  2:17         ` Kees Cook
2025-04-09 18:49 ` [RFC PATCH 10/29] lsm: cleanup the LSM blob size code Paul Moore
2025-04-09 23:29   ` Kees Cook
2025-04-15 23:02   ` John Johansen
2025-04-19  2:42   ` Fan Wu
2025-04-19  5:53     ` Kees Cook
2025-04-19 15:58       ` Fan Wu
2025-04-09 18:49 ` [RFC PATCH 11/29] lsm: cleanup initialize_lsm() and rename to lsm_init_single() Paul Moore
2025-04-09 23:30   ` Kees Cook
2025-04-15 23:04   ` John Johansen
2025-04-09 18:49 ` [RFC PATCH 12/29] lsm: cleanup the LSM ordered parsing Paul Moore
2025-04-09 18:49 ` [RFC PATCH 13/29] lsm: fold lsm_init_ordered() into security_init() Paul Moore
2025-04-09 18:49 ` [RFC PATCH 14/29] lsm: add missing function header comment blocks in lsm_init.c Paul Moore
2025-05-14 10:10   ` John Johansen
2025-04-09 18:50 ` [RFC PATCH 15/29] lsm: cleanup the debug and console output " Paul Moore
2025-04-09 18:50 ` [RFC PATCH 16/29] lsm: output available LSMs when debugging Paul Moore
2025-05-14 12:01   ` John Johansen
2025-04-09 18:50 ` [RFC PATCH 17/29] lsm: introduce an initcall mechanism into the LSM framework Paul Moore
2025-04-09 21:16   ` Kees Cook
2025-04-10 20:52     ` Paul Moore
2025-05-14 11:59   ` John Johansen
2025-04-09 18:50 ` [RFC PATCH 18/29] loadpin: move initcalls to " Paul Moore
2025-04-09 23:39   ` Kees Cook
2025-04-11  1:15     ` Paul Moore
2025-04-11  2:16       ` Kees Cook
2025-04-11  2:41         ` Paul Moore
2025-05-14 11:57   ` John Johansen
2025-04-09 18:50 ` [RFC PATCH 19/29] ipe: " Paul Moore
2025-04-09 23:40   ` Kees Cook
2025-04-14 21:19   ` Fan Wu
2025-04-15  1:58     ` Paul Moore
2025-05-14 12:02   ` John Johansen
2025-04-09 18:50 ` [RFC PATCH 20/29] smack: " Paul Moore
2025-04-09 23:42   ` Kees Cook
2025-04-11  2:30     ` Paul Moore
2025-04-10 17:30   ` Casey Schaufler
2025-04-10 17:47     ` Casey Schaufler
2025-04-11 20:09     ` Paul Moore
2025-04-14 21:04   ` Fan Wu
2025-04-15  1:54     ` Paul Moore
2025-04-09 18:50 ` [RFC PATCH 21/29] tomoyo: " Paul Moore
2025-04-09 23:43   ` Kees Cook
2025-05-14 12:05   ` John Johansen
2025-04-09 18:50 ` [RFC PATCH 22/29] safesetid: " Paul Moore
2025-04-09 23:43   ` Kees Cook
2025-04-11 19:20     ` Micah Morton
2025-04-11 20:45       ` Paul Moore
2025-05-14 12:18   ` John Johansen
2025-04-09 18:50 ` [RFC PATCH 23/29] apparmor: " Paul Moore
2025-04-09 23:44   ` Kees Cook
2025-05-14 13:33   ` John Johansen
2025-04-09 18:50 ` [RFC PATCH 24/29] lockdown: " Paul Moore
2025-04-09 23:44   ` Kees Cook
2025-05-14 13:31   ` John Johansen
2025-04-09 18:50 ` [RFC PATCH 25/29] ima,evm: " Paul Moore
2025-05-14 13:06   ` John Johansen
2025-06-11 20:09     ` Paul Moore
2025-05-30 22:03   ` Mimi Zohar
2025-06-11 20:27     ` Paul Moore
2025-06-13 20:34       ` Mimi Zohar
2025-07-21 21:59         ` Paul Moore
2025-04-09 18:50 ` [RFC PATCH 26/29] selinux: " Paul Moore
2025-04-10 16:33   ` Stephen Smalley
2025-04-11  3:24     ` Paul Moore [this message]
2025-05-23 15:12   ` Casey Schaufler
2025-04-09 18:50 ` [RFC PATCH 27/29] lsm: consolidate all of the LSM framework initcalls Paul Moore
2025-04-09 23:52   ` Kees Cook
2025-04-11  1:21     ` Paul Moore
2025-04-11  2:16       ` Kees Cook
2025-05-14 13:38   ` John Johansen
2025-04-09 18:50 ` [RFC PATCH 28/29] lsm: add a LSM_STARTED_ALL notification event Paul Moore
2025-04-09 23:53   ` Kees Cook
2025-05-14 13:34   ` John Johansen
2025-04-09 18:50 ` [RFC PATCH 29/29] lsm: add support for counting lsm_prop support among LSMs Paul Moore
2025-05-13 16:39   ` Casey Schaufler
2025-05-13 20:23     ` Paul Moore
2025-05-14 19:30       ` Casey Schaufler
2025-05-14 20:57         ` Paul Moore
2025-05-14 21:16           ` Casey Schaufler
2025-05-14 22:11             ` Paul Moore
2025-05-15 14:12               ` Casey Schaufler
2025-05-15 18:13                 ` Paul Moore
2025-05-15 19:41                   ` Casey Schaufler
2025-05-15 21:02                     ` Paul Moore
2025-04-10 14:13 ` [RFC PATCH 0/29] Rework the LSM initialization Casey Schaufler
2025-04-10 16:31   ` Kees Cook
2025-04-11  2:28   ` 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='CAHC9VhTDrVMW8LLbNwQ=ApcpQmdoFWk5RLMEyMBJygQLFJNE2w@mail.gmail.com' \
    --to=paul@paul-moore.com \
    --cc=casey@schaufler-ca.com \
    --cc=gnoack@google.com \
    --cc=john.johansen@canonical.com \
    --cc=kees@kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mic@digikod.net \
    --cc=mortonm@chromium.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=roberto.sassu@huawei.com \
    --cc=selinux@vger.kernel.org \
    --cc=stephen.smalley.work@gmail.com \
    --cc=wufan@kernel.org \
    --cc=zohar@linux.ibm.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).