linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Casey Schaufler <casey@schaufler-ca.com>
To: jmorris@namei.org, linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, selinux@vger.kernel.org
Cc: john.johansen@canonical.com, keescook@chromium.org,
	penguin-kernel@i-love.sakura.ne.jp, paul@paul-moore.com,
	linux-fsdevel@vger.kernel.org, sds@tycho.nsa.gov,
	adobriyan@gmail.com, mic@digikod.net, s.mesoraca16@gmail.com,
	casey@schaufler-ca.com
Subject: [PATCH v5 06/38] LSM: Introduce CONFIG_LSM
Date: Tue, 11 Dec 2018 14:42:42 -0800	[thread overview]
Message-ID: <20181211224314.22412-7-casey@schaufler-ca.com> (raw)
In-Reply-To: <20181211224314.22412-1-casey@schaufler-ca.com>

From: Kees Cook <keescook@chromium.org>

This provides a way to declare LSM initialization order via the new
CONFIG_LSM. Currently only non-major LSMs are recognized. This will
be expanded in future patches.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 security/Kconfig    |  9 +++++++++
 security/security.c | 27 ++++++++++++++++++++++-----
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/security/Kconfig b/security/Kconfig
index d9aa521b5206..7de42bbacc28 100644
--- a/security/Kconfig
+++ b/security/Kconfig
@@ -276,5 +276,14 @@ config DEFAULT_SECURITY
 	default "apparmor" if DEFAULT_SECURITY_APPARMOR
 	default "" if DEFAULT_SECURITY_DAC
 
+config LSM
+	string "Ordered list of enabled LSMs"
+	default "integrity"
+	help
+	  A comma-separated list of LSMs, in initialization order.
+	  Any LSMs left off this list will be ignored.
+
+	  If unsure, leave this as the default.
+
 endmenu
 
diff --git a/security/security.c b/security/security.c
index 4c193aba4531..96e0b7d057b0 100644
--- a/security/security.c
+++ b/security/security.c
@@ -48,6 +48,8 @@ char *lsm_names;
 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
 	CONFIG_DEFAULT_SECURITY;
 
+static __initconst const char * const builtin_lsm_order = CONFIG_LSM;
+
 /* Ordered list of LSMs to initialize. */
 static __initdata struct lsm_info **ordered_lsms;
 
@@ -155,15 +157,30 @@ static void __init maybe_initialize_lsm(struct lsm_info *lsm)
 	}
 }
 
-/* Populate ordered LSMs list from single LSM name. */
+/* Populate ordered LSMs list from comma-separated LSM name list. */
 static void __init ordered_lsm_parse(const char *order, const char *origin)
 {
 	struct lsm_info *lsm;
+	char *sep, *name, *next;
+
+	sep = kstrdup(order, GFP_KERNEL);
+	next = sep;
+	/* Walk the list, looking for matching LSMs. */
+	while ((name = strsep(&next, ",")) != NULL) {
+		bool found = false;
+
+		for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) {
+			if ((lsm->flags & LSM_FLAG_LEGACY_MAJOR) == 0 &&
+			    strcmp(lsm->name, name) == 0) {
+				append_ordered_lsm(lsm, origin);
+				found = true;
+			}
+		}
 
-	for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) {
-		if (strcmp(lsm->name, order) == 0)
-			append_ordered_lsm(lsm, origin);
+		if (!found)
+			init_debug("%s ignored: %s\n", origin, name);
 	}
+	kfree(sep);
 }
 
 static void __init ordered_lsm_init(void)
@@ -173,7 +190,7 @@ static void __init ordered_lsm_init(void)
 	ordered_lsms = kcalloc(LSM_COUNT + 1, sizeof(*ordered_lsms),
 				GFP_KERNEL);
 
-	ordered_lsm_parse("integrity", "builtin");
+	ordered_lsm_parse(builtin_lsm_order, "builtin");
 
 	for (lsm = ordered_lsms; *lsm; lsm++)
 		maybe_initialize_lsm(*lsm);
-- 
2.14.5


  parent reply	other threads:[~2018-12-11 22:47 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-11 22:42 [PATCH v5 00/38] LSM: Module stacking for SARA and Landlock Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 01/38] LSM: Introduce LSM_FLAG_LEGACY_MAJOR Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 02/38] LSM: Provide separate ordered initialization Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 03/38] LSM: Plumb visibility into optional "enabled" state Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 04/38] LSM: Lift LSM selection out of individual LSMs Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 05/38] LSM: Build ordered list of LSMs to initialize Casey Schaufler
2018-12-11 22:42 ` Casey Schaufler [this message]
2018-12-11 22:42 ` [PATCH v5 07/38] LSM: Introduce "lsm=" for boottime LSM selection Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 08/38] LSM: Tie enabling logic to presence in ordered list Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 09/38] LSM: Prepare for reorganizing "security=" logic Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 10/38] LSM: Refactor "security=" in terms of enable/disable Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 11/38] LSM: Separate idea of "major" LSM from "exclusive" LSM Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 12/38] apparmor: Remove SECURITY_APPARMOR_BOOTPARAM_VALUE Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 13/38] selinux: Remove SECURITY_SELINUX_BOOTPARAM_VALUE Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 14/38] LSM: Add all exclusive LSMs to ordered initialization Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 15/38] LSM: Split LSM preparation from initialization Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 16/38] LoadPin: Initialize as ordered LSM Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 17/38] Yama: " Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 18/38] LSM: Introduce enum lsm_order Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 19/38] capability: Initialize as LSM_ORDER_FIRST Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 20/38] procfs: add smack subdir to attrs Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 21/38] Smack: Abstract use of cred security blob Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 22/38] SELinux: " Casey Schaufler
2018-12-11 22:42 ` [PATCH v5 23/38] SELinux: Remove cred security blob poisoning Casey Schaufler
2018-12-11 22:43 ` [PATCH v5 24/38] SELinux: Remove unused selinux_is_enabled Casey Schaufler
2018-12-11 22:43 ` [PATCH v5 25/38] AppArmor: Abstract use of cred security blob Casey Schaufler
2018-12-11 22:43 ` [PATCH v5 26/38] TOMOYO: " Casey Schaufler
2018-12-11 22:43 ` [PATCH v5 27/38] Infrastructure management of the " Casey Schaufler
2018-12-11 22:43 ` [PATCH v5 28/38] SELinux: Abstract use of file " Casey Schaufler
2018-12-11 22:43 ` [PATCH v5 29/38] Smack: " Casey Schaufler
2018-12-11 22:43 ` [PATCH v5 30/38] LSM: Infrastructure management of the file security Casey Schaufler
2018-12-11 22:43 ` [PATCH v5 31/38] SELinux: Abstract use of inode security blob Casey Schaufler
2018-12-11 22:43 ` [PATCH v5 32/38] Smack: " Casey Schaufler
2018-12-11 22:43 ` [PATCH v5 33/38] LSM: Infrastructure management of the inode security Casey Schaufler
2018-12-11 22:43 ` [PATCH v5 34/38] LSM: Infrastructure management of the task security Casey Schaufler
2018-12-11 22:43 ` [PATCH v5 35/38] SELinux: Abstract use of ipc security blobs Casey Schaufler
2018-12-11 22:43 ` [PATCH v5 36/38] Smack: " Casey Schaufler
2018-12-11 22:43 ` [PATCH v5 37/38] LSM: Infrastructure management of the ipc security blob Casey Schaufler
2018-12-12 16:05 ` [PATCH v5 38/38] TOMOYO: Update LSM flags to no longer be exclusive Casey Schaufler
  -- strict thread matches above, loose matches on Subject: below --
2018-11-26 23:22 [PATCH v5 00/38] LSM: Module stacking for SARA and Landlock Casey Schaufler
2018-11-26 23:31 ` [PATCH v5 06/38] LSM: Introduce CONFIG_LSM Casey Schaufler

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=20181211224314.22412-7-casey@schaufler-ca.com \
    --to=casey@schaufler-ca.com \
    --cc=adobriyan@gmail.com \
    --cc=jmorris@namei.org \
    --cc=john.johansen@canonical.com \
    --cc=keescook@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mic@digikod.net \
    --cc=paul@paul-moore.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=s.mesoraca16@gmail.com \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@vger.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;
as well as URLs for NNTP newsgroup(s).