mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marwan Seliem <marwanmhks@gmail.com>
To: paul@paul-moore.com, stephen.smalley.work@gmail.com
Cc: omosnace@redhat.com, selinux@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [RFC] selinux: add selinux=2 boot parameter for permissive mode through kernel cmdline
Date: Fri, 13 Mar 2026 08:12:35 +0200	[thread overview]
Message-ID: <20260313061235.9552-1-marwanmhks@gmail.com> (raw)

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

             reply	other threads:[~2026-03-13  6:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-13  6:12 Marwan Seliem [this message]
2026-03-13 14:44 ` Stephen Smalley
2026-03-13 18:01   ` 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=20260313061235.9552-1-marwanmhks@gmail.com \
    --to=marwanmhks@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=omosnace@redhat.com \
    --cc=paul@paul-moore.com \
    --cc=selinux@vger.kernel.org \
    --cc=stephen.smalley.work@gmail.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

all inboxes | Powered by JetHome®