* [RFC] selinux: add selinux=2 boot parameter for permissive mode through kernel cmdline
@ 2026-03-13 6:12 Marwan Seliem
2026-03-13 14:44 ` Stephen Smalley
0 siblings, 1 reply; 3+ messages in thread
From: Marwan Seliem @ 2026-03-13 6:12 UTC (permalink / raw)
To: paul, stephen.smalley.work; +Cc: omosnace, selinux, linux-kernel
Hi Paul, Stephen, Ondrej,
I wanted to reach out to ask whether a change like the following would be considered useful or acceptable upstream, before investing more time polishing it.
Background
----------
On a platform with the following Kconfig:
CONFIG_SECURITY_SELINUX_DEVELOP is not set
CONFIG_SECURITY_SELINUX_BOOTPARAM=y
The only runtime options for the selinux= boot parameter are:
selinux=0 -> SELinux disabled entirely
selinux=1 -> SELinux enforcing, non-switchable
There is no way to boot into permissive mode without either enabling
CONFIG_SECURITY_SELINUX_DEVELOP (which also enables setenforce and is
not desirable in production) or disabling SELinux entirely.
Proposal
--------
Introduce selinux=2 as a new boot parameter value that boots SELinux
in a permanently permissive mode:
- SELinux is fully initialized and policy is loaded normally
- All AVC denials are logged but never enforced
- The permissive state is non-switchable at runtime
Implementation
--------------
The change is minimal, touching only two files:
security/selinux/hooks.c:
- Introduce selinux_permissive_boot __ro_after_init
- Parse selinux=2 in selinux_enabled_setup(), set the flag
security/selinux/include/security.h:
- In the non-DEVELOP enforcing_enabled() path, return
!(selinux_permissive_boot && state->initialized)
instead of hardcoded true
The initialized gate is intentional since, enforcing_enabled()
returns false before policy is loaded, which causes systemd to observe
a permissive+no-policy state and stall boot.
Use case
---------
The primary use case is embedded platforms shipping with
enforcing locked at build time, where the ABL needs a mechanism to
boot into permissive for debugging SELinux policy issues in the field,
and without enabling DEVELOP in production builds.
Note that the ABL will be protected by secure boot in production.
Would a change like this be of interest upstream, or is there an
existing mechanism I have missed that already covers this use case?
Happy to send a proper patch if there is interest.
Thanks,
Marwan Seliem
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] selinux: add selinux=2 boot parameter for permissive mode through kernel cmdline
2026-03-13 6:12 [RFC] selinux: add selinux=2 boot parameter for permissive mode through kernel cmdline Marwan Seliem
@ 2026-03-13 14:44 ` Stephen Smalley
2026-03-13 18:01 ` Paul Moore
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Smalley @ 2026-03-13 14:44 UTC (permalink / raw)
To: Marwan Seliem; +Cc: paul, omosnace, selinux, linux-kernel
On Fri, Mar 13, 2026 at 2:12 AM Marwan Seliem <marwanmhks@gmail.com> wrote:
>
> Hi Paul, Stephen, Ondrej,
>
> I wanted to reach out to ask whether a change like the following would be considered useful or acceptable upstream, before investing more time polishing it.
>
> Background
> ----------
> On a platform with the following Kconfig:
>
> CONFIG_SECURITY_SELINUX_DEVELOP is not set
> CONFIG_SECURITY_SELINUX_BOOTPARAM=y
>
> The only runtime options for the selinux= boot parameter are:
>
> selinux=0 -> SELinux disabled entirely
> selinux=1 -> SELinux enforcing, non-switchable
>
> There is no way to boot into permissive mode without either enabling
> CONFIG_SECURITY_SELINUX_DEVELOP (which also enables setenforce and is
> not desirable in production) or disabling SELinux entirely.
Android handles this by neverallow'ing setenforce permission in their policy.
Hence, they can enable CONFIG_SECURITY_SELINUX_DEVELOP but prohibit
any userspace setenforce beyond the initial setenforce(1) by the init
program.
> Proposal
> --------
> Introduce selinux=2 as a new boot parameter value that boots SELinux
> in a permanently permissive mode:
This seems very unintuitive; would just use enforcing=0 as with the
DEVELOP case.
>
> - SELinux is fully initialized and policy is loaded normally
> - All AVC denials are logged but never enforced
> - The permissive state is non-switchable at runtime
>
> Implementation
> --------------
> The change is minimal, touching only two files:
>
> security/selinux/hooks.c:
> - Introduce selinux_permissive_boot __ro_after_init
> - Parse selinux=2 in selinux_enabled_setup(), set the flag
>
> security/selinux/include/security.h:
> - In the non-DEVELOP enforcing_enabled() path, return
> !(selinux_permissive_boot && state->initialized)
> instead of hardcoded true
>
> The initialized gate is intentional since, enforcing_enabled()
> returns false before policy is loaded, which causes systemd to observe
> a permissive+no-policy state and stall boot.
I'm a bit confused here. Why wouldn't policy be loaded, even if
booting permissive?
Regardless, I'm not sure how this is an improvement; a kernel write
vulnerability would still allow one to flip state->initialized at
runtime.
> Use case
> ---------
> The primary use case is embedded platforms shipping with
> enforcing locked at build time, where the ABL needs a mechanism to
> boot into permissive for debugging SELinux policy issues in the field,
> and without enabling DEVELOP in production builds.
>
> Note that the ABL will be protected by secure boot in production.
>
> Would a change like this be of interest upstream, or is there an
> existing mechanism I have missed that already covers this use case?
>
> Happy to send a proper patch if there is interest.
>
> Thanks,
> Marwan Seliem
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] selinux: add selinux=2 boot parameter for permissive mode through kernel cmdline
2026-03-13 14:44 ` Stephen Smalley
@ 2026-03-13 18:01 ` Paul Moore
0 siblings, 0 replies; 3+ messages in thread
From: Paul Moore @ 2026-03-13 18:01 UTC (permalink / raw)
To: Marwan Seliem, Stephen Smalley; +Cc: omosnace, selinux, linux-kernel
On Fri, Mar 13, 2026 at 10:44 AM Stephen Smalley
<stephen.smalley.work@gmail.com> wrote:
> On Fri, Mar 13, 2026 at 2:12 AM Marwan Seliem <marwanmhks@gmail.com> wrote:
> >
> > Hi Paul, Stephen, Ondrej,
> >
> > I wanted to reach out to ask whether a change like the following would be considered useful or acceptable upstream, before investing more time polishing it.
> >
> > Background
> > ----------
> > On a platform with the following Kconfig:
> >
> > CONFIG_SECURITY_SELINUX_DEVELOP is not set
> > CONFIG_SECURITY_SELINUX_BOOTPARAM=y
> >
> > The only runtime options for the selinux= boot parameter are:
> >
> > selinux=0 -> SELinux disabled entirely
> > selinux=1 -> SELinux enforcing, non-switchable
> >
> > There is no way to boot into permissive mode without either enabling
> > CONFIG_SECURITY_SELINUX_DEVELOP (which also enables setenforce and is
> > not desirable in production) or disabling SELinux entirely.
>
> Android handles this by neverallow'ing setenforce permission in their policy.
> Hence, they can enable CONFIG_SECURITY_SELINUX_DEVELOP but prohibit
> any userspace setenforce beyond the initial setenforce(1) by the init
> program.
The Android approach is what I would expect to use in a case like
this, and honestly I prefer that much more than another kernel command
line state.
--
paul-moore.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-13 18:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-13 6:12 [RFC] selinux: add selinux=2 boot parameter for permissive mode through kernel cmdline Marwan Seliem
2026-03-13 14:44 ` Stephen Smalley
2026-03-13 18:01 ` Paul Moore
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®