Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp727066imm; Mon, 1 Oct 2018 18:07:13 -0700 (PDT) X-Google-Smtp-Source: ACcGV60hTiIcwCyMGphjIeykYoR1Ujpyik0ptw7RYSyEpcGeaEVzjppy3SpxKy4fHRlgXGhA6zzu X-Received: by 2002:a17:902:7043:: with SMTP id h3-v6mr14408239plt.103.1538442433917; Mon, 01 Oct 2018 18:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538442433; cv=none; d=google.com; s=arc-20160816; b=Ootcq4l6N6Z2SznquNJtFoya/fVRj5Eb9jN4EbsdmyncTar6V5DVqvmqn773PNGpjk hZUm4D+DRy7gFV/tNhl81WsTVlIbFFoPJdfZ0rqvah2ZD9pTS9nBx3vX3/X0V+IXb4m3 N7/qfEwYhn23KF7+nfhJ6JAE+SkdI2w45fWjHhlCKqTWhk4qBDM0dIs5B5HTz1KL9UhK cup1bJbN04m8IHtcXwRRGlZK6Rl4GzhxwWwvMddVBRvWSPJoKGJJ4R0CGwm/dqEhZpjR SiMuKrtu8v0BCuDSnh37xpiwcq8xhVe/tt6Rj6mOpM7tp+xzFH/MDiqr2PAEsACzAFhr HX+w== 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=0RYipdsIhsetP9y77Y83cY+AYnVXjoUOFr0d0L1Gup4=; b=Y0Z81iY5t3We4AClGt/HHO+JXMvcS1BeU/zAkVsiSUu8btoxTtqdX4Q2PgRw58vxtl R7mSAGqNAlzoAmmKQHDl5S9jclbZApipr9li/SbD98tORWsZIYWR1ImW0ASZ1wct5uiv MNbtIHszkaHTcaBkWFFyDELyacraE8lyhGQA/JYRi8iimI8quDnQ18vNVXoCnSceEXzd bBqkwQPuwmiQilQuER1h5vRwicjal1qgR/QBur96qY8JxF2Nj8357CnctOiceDyvtQea NLGmu2046+N4g3u5Vrawlq5wOaYtA38NYqBTmPBXF+/Gh2MC5JjVCMHhBg8QurASCV9d IF2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WEfbzd0L; 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 b4-v6si13549743plx.519.2018.10.01.18.06.59; Mon, 01 Oct 2018 18:07:13 -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=WEfbzd0L; 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 S1726679AbeJBHo5 (ORCPT + 99 others); Tue, 2 Oct 2018 03:44:57 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:40172 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726353AbeJBHo5 (ORCPT ); Tue, 2 Oct 2018 03:44:57 -0400 Received: by mail-it1-f195.google.com with SMTP id i191-v6so1092664iti.5 for ; Mon, 01 Oct 2018 18:04:26 -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=0RYipdsIhsetP9y77Y83cY+AYnVXjoUOFr0d0L1Gup4=; b=WEfbzd0L4U24y99D5LFveDvCDTC2jDhleO7GYaIn21f52QkqSxmL7zow5OZDB6DGLy UcgA6UvB3ar3il1u9qh29ybZoPMhAWAhAtczzIcPWb19JAa5U/3mpQrhCKsLUPbIQZGJ 2YQahoVdMA460SQ0PtPTgn/N1srQmFlB322ss= 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=0RYipdsIhsetP9y77Y83cY+AYnVXjoUOFr0d0L1Gup4=; b=AUZ6+1B/RDIkJefnejKDH2mVuBAUNkygE9pfHX6/fvVEw5aHfBptumH/ImYKh++Ztm YRHJbA1kO4H2HLLK+jXimE/V4CjU5GOHTXQqA1D7UvbZwhTHynYWZQwUf8mtDxuxuak7 my51lDH3GNiSkDcA+2xtU/OFBWIqwyHK9qnTxP8R7pHSXvU0MKzH/DCmrwQWVdNCGPk0 93Kivp6NnI3LypEMYA4/OebRYqOtkr2oA0Tell583bxMNXq4SSzK3rFhM1DvXIPaOpCC xUlUfo85+oF1ftu3dCCItmBb1be/xYrO0hbHvCSOlWGpO4Gqn2QKllNOjbIV2J/vTqci PMnQ== X-Gm-Message-State: ABuFfojoORX1MPtE8PVf2ZR2/VHh7j9pdiJplrkkSGbR+UtQuKrgWPXk 1b6XnfzijVR4/XR8KIJ/E5eOtA== X-Received: by 2002:a63:6ec4:: with SMTP id j187-v6mr12395919pgc.3.1538442265802; Mon, 01 Oct 2018 18:04:25 -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 c2-v6sm19748936pfo.107.2018.10.01.18.04.23 (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 18/32] LSM: Introduce lsm.enable= and lsm.disable= Date: Mon, 1 Oct 2018 17:54:51 -0700 Message-Id: <20181002005505.6112-19-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 This introduces the "lsm.enable=..." and "lsm.disable=..." boot parameters which each can contain a comma-separated list of LSMs to enable or disable, respectively. The string "all" matches all LSMs. This has very similar functionality to the existing per-LSM enable handling ("apparmor.enabled=...", etc), but provides a centralized place to perform the changes. These parameters take precedent over any LSM-specific boot parameters. Disabling an LSM means it will not be considered when performing initializations. Enabling an LSM means either undoing a previous LSM-specific boot parameter disabling or a undoing a default-disabled CONFIG setting. For example: "lsm.disable=apparmor apparmor.enabled=1" will result in AppArmor being disabled. "selinux.enabled=0 lsm.enable=selinux" will result in SELinux being enabled. Signed-off-by: Kees Cook Reviewed-by: Casey Schaufler --- .../admin-guide/kernel-parameters.txt | 12 ++++++++++ security/Kconfig | 4 +++- security/security.c | 22 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 32d323ee9218..67c90985d2b8 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2276,6 +2276,18 @@ lsm.debug [SECURITY] Enable LSM initialization debugging output. + lsm.disable=lsm1,...,lsmN + [SECURITY] Comma-separated list of LSMs to disable + at boot time. This overrides "lsm.enable=", + CONFIG_LSM_ENABLE, and any per-LSM CONFIGs and boot + parameters. + + lsm.enable=lsm1,...,lsmN + [SECURITY] Comma-separated list of LSMs to enable + at boot time. This overrides any omissions from + CONFIG_LSM_ENABLE, and any per-LSM CONFIGs and + boot parameters. + machvec= [IA-64] Force the use of a particular machine-vector (machvec) in a generic kernel. Example: machvec=hpzx1_swiotlb diff --git a/security/Kconfig b/security/Kconfig index ac23feba584d..1e57619fd561 100644 --- a/security/Kconfig +++ b/security/Kconfig @@ -282,7 +282,9 @@ config LSM_ENABLE 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. + not listed here will be disabled by default. This can be + changed with the "lsm.enable=" and "lsm.disable=" boot + parameters. endmenu diff --git a/security/security.c b/security/security.c index 35601000176b..3fff2d1d1ec4 100644 --- a/security/security.c +++ b/security/security.c @@ -44,6 +44,8 @@ char *lsm_names; /* Boot-time LSM user choice */ static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] = CONFIG_DEFAULT_SECURITY; +static __initdata const char *chosen_lsm_enable; +static __initdata const char *chosen_lsm_disable; static __initconst const char * const builtin_lsm_enable = CONFIG_LSM_ENABLE; @@ -185,6 +187,10 @@ static void __init prepare_lsm_enable(void) { /* Prepare defaults. */ parse_lsm_enable(builtin_lsm_enable, default_enabled, true); + + /* Process "lsm.enable=" and "lsm.disable=", if given. */ + parse_lsm_enable(chosen_lsm_enable, set_enabled, true); + parse_lsm_enable(chosen_lsm_disable, set_enabled, false); } /** @@ -240,6 +246,22 @@ static int __init enable_debug(char *str) } __setup("lsm.debug", enable_debug); +/* Explicitly enable a list of LSMs. */ +static int __init enable_lsm(char *str) +{ + chosen_lsm_enable = str; + return 1; +} +__setup("lsm.enable=", enable_lsm); + +/* Explicitly disable a list of LSMs. */ +static int __init disable_lsm(char *str) +{ + chosen_lsm_disable = str; + return 1; +} +__setup("lsm.disable=", disable_lsm); + static bool match_last_lsm(const char *list, const char *lsm) { const char *last; -- 2.17.1