Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp726353imm; Mon, 1 Oct 2018 18:06:15 -0700 (PDT) X-Google-Smtp-Source: ACcGV63xaPz9u3Ei7Qqb5J0nhiJvmBX9uDKYrJmFIDmpKYLOu+t/N9V7jsiJLYHL8rW5pFMi2HVs X-Received: by 2002:a17:902:b70d:: with SMTP id d13-v6mr14038302pls.44.1538442375213; Mon, 01 Oct 2018 18:06:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538442375; cv=none; d=google.com; s=arc-20160816; b=TfWnrsndAreRibKkJ29eufUNudMz3DJ9lGUXAOzBtxIEBqLqZKNGgqF44Tt9Yxoyo9 9F8MFQajkXI4Hq3p7bV26Te3pxWNFDCOC9wJFm+rZwati5eqKCugp0EzR0fA9FNaGAp6 aPAZur4wy5kT6NrS4ZA9ws5LlV8CTwqNa6aGzt4dPycnYiuDbniF0fa6Q+VSdf7kvogu nxDKJCr7A97bS42u7/b4CS8VFSmWMckpW1pUs7DRtOKRWOglocUo1wq56yktgnpCxhm3 jykXQWXGoyhIgjyi9z4fJNoL6IZqWcI/jBWjQMri883LraCD7E9DkiUYKXWJ0ki3XmlC CMyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=sVOoGnQVVxtCQukk9qvIxsFMi2TMOCjgfBDPf6jS5YQ=; b=S7R9aSRXcZ9JbsFDfw3hPS72ekrK5o02ClhM4NiWtQgImgwQD7bkxn+/UPM1mooUt2 hJDpcUCifsKu2404vmpUQiwWh/o9oTXqJIcb8Mt46305cmjafYydiJhkohoIoEX5eFoy v0igtKws0j3Bi8qC95K7lwHMzVwRYtkv7xXFyC0ZyFgIjjQv97SIQhT2BqqqPojNpxk8 MB+oY07kxh/xWtrSg9+BLbOHbUumbHm6DhGmR+BQJBL98zb9n/YJo5iLre7hDMdQ4A7K 3lhV1e5sBIJVxTy3sJx7Y/n8EWOUdYE//LspSoJEAtHq2HZyacQYhVERMUZWp5xvtxuD bapA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="oWMa/tn1"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x192-v6si12768835pgx.686.2018.10.01.18.06.01; Mon, 01 Oct 2018 18:06:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="oWMa/tn1"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726950AbeJBHp6 (ORCPT + 99 others); Tue, 2 Oct 2018 03:45:58 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:52636 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726803AbeJBHpA (ORCPT ); Tue, 2 Oct 2018 03:45:00 -0400 Received: by mail-it1-f194.google.com with SMTP id 134-v6so1016237itz.2 for ; Mon, 01 Oct 2018 18:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sVOoGnQVVxtCQukk9qvIxsFMi2TMOCjgfBDPf6jS5YQ=; b=oWMa/tn1rXNvp56NZzs7vYF4yF3oxT5MHoSS9c41PHjSgCp2ZUK64Iy0T9L3kshGCo dpda/TnhyAjx43PVZ71axdb0UYPuvx3fIb80UKBkJwKcB1R3Lrz4r9+JSk4GFQ6BFA65 iCrps6usAwk6JEQL2Ap9vDKiNcqUyIn6NhLt8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sVOoGnQVVxtCQukk9qvIxsFMi2TMOCjgfBDPf6jS5YQ=; b=aAbVeliLNXsNByP5Ko4v8EAs3j0jjGzspuPGQvGeDtGb/pyIZG7Tz9rz+QZPpoJO21 vcca9D6xbIii6FqrOdwpAAC6LkklQDO0WCnVBF3KmwFZEDjhdTKF9ZaNoTQOsUXc6pe6 r4Mu1a4yuSTUoAWsN8eX9luC9lS/ZtNRSLqPoxlI+JguEH5Rvvbj/Pc+3uFZr82OnkR9 kVKSBfTO7nagEi1WqTsl/B9itUw/oDLDyL/gaWWU7DAQF5/p8aRJbojNJ1cMAI+4W2y+ /jB6Q3MFk7EOGM9MG4xxkP86fJRLTlLS46+o4e/O2Gt5uyQKv3/9unOKRYJDnEA2Uas3 nE0Q== X-Gm-Message-State: ABuFfoinphdKqw8//qSN8m4BGM4Z8Ps23l6G6Ef6MEvTkav+Vgy/6Mj6 zZj8F90K195yHz2xSPdNERPxow== X-Received: by 2002:a63:a902:: with SMTP id u2-v6mr12305606pge.207.1538442269214; Mon, 01 Oct 2018 18:04:29 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id v2-v6sm2793786pfe.6.2018.10.01.18.04.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Oct 2018 18:04:24 -0700 (PDT) From: Kees Cook To: James Morris Cc: Kees Cook , Casey Schaufler , John Johansen , Tetsuo Handa , Paul Moore , Stephen Smalley , "Schaufler, Casey" , LSM , Jonathan Corbet , linux-doc@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH security-next v4 17/32] LSM: Introduce CONFIG_LSM_ENABLE Date: Mon, 1 Oct 2018 17:54:50 -0700 Message-Id: <20181002005505.6112-18-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181002005505.6112-1-keescook@chromium.org> References: <20181002005505.6112-1-keescook@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To provide a set of default-enabled LSMs at boot, this introduces the new CONFIG_LSM_ENABLE. A value of "all" means all builtin LSMs are enabled by default. Any unlisted LSMs will be implicitly disabled (excepting those with LSM-specific CONFIGs for enabling/disabling). The behavior of the LSM-specific CONFIGs for SELinux are AppArmor unchanged: the default-enabled state for those LSMs remains controlled through their LSM-specific "enable" CONFIGs. Signed-off-by: Kees Cook Reviewed-by: Casey Schaufler --- include/linux/lsm_hooks.h | 2 +- security/Kconfig | 8 ++++++++ security/security.c | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index 9ecb623fb39d..fd85637a1931 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h @@ -2044,7 +2044,7 @@ extern void security_add_hooks(struct security_hook_list *hooks, int count, struct lsm_info { const char *name; /* Required. */ unsigned long flags; /* Optional: flags describing LSM */ - int *enabled; /* Optional: NULL means enabled. */ + int *enabled; /* Optional: NULL checks CONFIG_LSM_ENABLE */ int (*init)(void); /* Required. */ }; diff --git a/security/Kconfig b/security/Kconfig index 27d8b2688f75..ac23feba584d 100644 --- a/security/Kconfig +++ b/security/Kconfig @@ -276,5 +276,13 @@ config DEFAULT_SECURITY default "apparmor" if DEFAULT_SECURITY_APPARMOR default "" if DEFAULT_SECURITY_DAC +config LSM_ENABLE + string "LSMs to enable at boot time" + default "all" + help + A comma-separated list of LSMs to enable by default at boot. The + default is "all", to enable all LSM modules at boot. Any LSMs + not listed here will be disabled by default. + endmenu diff --git a/security/security.c b/security/security.c index 9459b4ee4fd9..35601000176b 100644 --- a/security/security.c +++ b/security/security.c @@ -45,6 +45,8 @@ char *lsm_names; static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] = CONFIG_DEFAULT_SECURITY; +static __initconst const char * const builtin_lsm_enable = CONFIG_LSM_ENABLE; + static __initdata bool debug; #define init_debug(...) \ do { \ @@ -182,7 +184,7 @@ static void __init parse_lsm_enable(const char *str, static void __init prepare_lsm_enable(void) { /* Prepare defaults. */ - parse_lsm_enable("all", default_enabled, true); + parse_lsm_enable(builtin_lsm_enable, default_enabled, true); } /** -- 2.17.1