From patchwork Tue Sep 25 00:18:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10613105 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C8E815A6 for ; Tue, 25 Sep 2018 00:19:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88B9029E9D for ; Tue, 25 Sep 2018 00:19:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C4E229EE6; Tue, 25 Sep 2018 00:19:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C42529E9D for ; Tue, 25 Sep 2018 00:19:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727482AbeIYGXm (ORCPT ); Tue, 25 Sep 2018 02:23:42 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:39083 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728835AbeIYGXk (ORCPT ); Tue, 25 Sep 2018 02:23:40 -0400 Received: by mail-pg1-f193.google.com with SMTP id 85-v6so7044577pge.6 for ; Mon, 24 Sep 2018 17:18:55 -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=gU8yPNVAJgM0Xsl0Xg5cYn4RlLsSLFMLd0v2DDJ1qcc=; b=DsyIjfnmbUEIcckKSghwPU6vbUtA3jFBt7UXg0nenJyyTmedsS/1ngyUfKFE3uSifv 6L3u3gAq24e8/rqldOC3FwmzYXXN8NvXuASwSOrovYWebTiwfT7r4sRg8UivsYBScKb9 eVlnvx/ruLqfPFRcXrZHXO6xD4nqtaLFlFC7o= 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=gU8yPNVAJgM0Xsl0Xg5cYn4RlLsSLFMLd0v2DDJ1qcc=; b=Fw+GO/BkPPS2rCfE/E1KN9FhFItBm9xyc6Znc3L7aar06TKs8/qIqIrUJYHD4PwlBZ kyYCUzDfHRABUNWMJbHYaiCmEcg7/cV2A0hMba4C1684tZ//BqVDMTJhoO8q8c0LoUqB +OXz5jyz8N2/t2IS7m3SSvxgGjd/SxW2KEolwMEsXia9GX2gx0vJ7yZFe6hxo1yhQs6U pnc7Psl/hYBbHDWkuBqIILO7dG3yFbkL9tIiLNc79uUl85UIu19dSJls2pUGXWqjgC8z ieLzJf10TaVChhKMrB/5ds80hRzt3J55S+DSEywZDgZrvwjsxV+SX4HkTPUECQ9yXkMA GHVA== X-Gm-Message-State: ABuFfoiWK8iKmV40dyCRQqPncuuZh6w9Bvg6Vd22QS9XjwDXzFtmrKTF loeq2xGsbgE2t/x6c1zQ5dUVhQ== X-Google-Smtp-Source: ACcGV61G2pnFUw/Q4F1NXTTg0KFo8jl0iUqoLOz6In9fV1XKgsmQsPAANPdQEU1hs8nNzJ7dovGUTg== X-Received: by 2002:a63:4281:: with SMTP id p123-v6mr907162pga.91.1537834735149; Mon, 24 Sep 2018 17:18:55 -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-v6sm516945pgf.58.2018.09.24.17.18.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Sep 2018 17:18:48 -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 v3 23/29] LSM: Introduce "lsm.order=" for boottime ordering Date: Mon, 24 Sep 2018 17:18:26 -0700 Message-Id: <20180925001832.18322-24-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180925001832.18322-1-keescook@chromium.org> References: <20180925001832.18322-1-keescook@chromium.org> Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Provide a way to reorder LSM initialization using the new "lsm.order=" comma-separated list of LSMs. Any LSMs not listed will be added in builtin order. Signed-off-by: Kees Cook --- Documentation/admin-guide/kernel-parameters.txt | 6 ++++++ security/security.c | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 67c90985d2b8..c7c1a0d253ee 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2288,6 +2288,12 @@ CONFIG_LSM_ENABLE, and any per-LSM CONFIGs and boot parameters. + lsm.order=lsm1,...,lsmN + [SECURITY] Choose order of enabled LSM + initialization. Any builtin LSMs not listed here + will be implicitly appended to the list in builtin + order. + machvec= [IA-64] Force the use of a particular machine-vector (machvec) in a generic kernel. Example: machvec=hpzx1_swiotlb diff --git a/security/security.c b/security/security.c index e38df0314f5e..f1c3581d870f 100644 --- a/security/security.c +++ b/security/security.c @@ -44,6 +44,7 @@ char *lsm_names; /* Boot-time LSM user choice */ static __initdata const char *chosen_lsm_enable; static __initdata const char *chosen_lsm_disable; +static __initdata const char *chosen_lsm_order; static __initdata const char *chosen_major_lsm; static __initconst const char * const builtin_lsm_enable = CONFIG_LSM_ENABLE; @@ -160,11 +161,14 @@ static void __init parse_lsm_order(const char *order, const char *origin) kfree(sep); } -/* Populate ordered LSMs list from builtin list of LSMs. */ +/* Populate ordered LSMs list from commandline and builtin list of LSMs. */ static void __init prepare_lsm_order(void) { struct lsm_info *lsm; + /* Parse order from commandline, if present. */ + parse_lsm_order(chosen_lsm_order, "cmdline"); + /* Parse order from builtin list. */ parse_lsm_order(builtin_lsm_order, "builtin"); @@ -324,6 +328,14 @@ static int __init choose_major_lsm(char *str) } __setup("security=", choose_major_lsm); +/* Explicitly choose LSM initialization order. */ +static int __init choose_lsm_order(char *str) +{ + chosen_lsm_order = str; + return 1; +} +__setup("lsm.order=", choose_lsm_order); + /* Enable LSM order debugging. */ static int __init enable_debug(char *str) {