From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on archive.lwn.net X-Spam-Level: X-Spam-Status: No, score=-5.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable autolearn_force=no version=3.4.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by archive.lwn.net (Postfix) with ESMTP id BAB8B7D8E9 for ; Tue, 2 Oct 2018 01:04:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726731AbeJBHpA (ORCPT ); Tue, 2 Oct 2018 03:45:00 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:35163 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726739AbeJBHo7 (ORCPT ); Tue, 2 Oct 2018 03:44:59 -0400 Received: by mail-io1-f66.google.com with SMTP id w11-v6so295783iob.2 for ; Mon, 01 Oct 2018 18:04:28 -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=zecK+fw6L8v037inPgSN/m/4Zxn4FHGN1MbaVrC22C0=; b=W4XLD4PX28zRTlyMQwG4WluelnyiVxKarxOnbZJW1Hg0XwVkYB8X9PNbLDnIv1ZQZS PGRhgL0bEly4K1QxvqWo7VCdxoZ9Yl1lw/i3A1TqKCWrTDcsXCbHbvrVq0NyjqU/AbkA RXkZxkvfWFkgpS9VQTzR5GYGPp89k3p4QoRzw= 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=zecK+fw6L8v037inPgSN/m/4Zxn4FHGN1MbaVrC22C0=; b=d5nB+bLA9LqSid/2IKT8OZMcHAVrxoYJwB8CPX/ax7QL8IESDi6QnXHVQW2iXaLAmG Hda4lTymLhjgMB10yVBYQ/OTbpvitrUgDO8AVRkDNYriHke5/ZvYN7J57rzBEWx81UkC JHlmdnOZc0zGzJmaoOzkvdiaFP6LUbLoZH5jEKTIHkINUwDryNYmhnjDsf4EG2R6GlHQ 3xGYSHZgkF63O+4uBloZNQpVnhSBB6xwxazceNYvNYYhpXzEbJloXwvfF+BnaPSLr34j AmrhxeJRQrP/tbKOs/MGRJVdg6fVc6yjehNbL+CfC8eiRmABuOkgi72GqeV4DuF/xXuR sqlw== X-Gm-Message-State: ABuFfohZY9XxqQAssiCNnoKXTfG6WOh0X0X0IoKT9kCuClRhLZhKOIVq 2/wtfghRjqS8CSDzSCXkrPE1oQ== X-Google-Smtp-Source: ACcGV60kxTP3I7VxZCr+tbEyh8BJQYWzHGqempdB2XI4Z4y+BPo8K449B8pZOOBCgPdNfsqn3uWyvg== X-Received: by 2002:a62:9c4a:: with SMTP id f71-v6mr8631527pfe.135.1538442268325; Mon, 01 Oct 2018 18:04:28 -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 y19-v6sm27036514pff.14.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 27/32] LoadPin: Initialize as ordered LSM Date: Mon, 1 Oct 2018 17:55:00 -0700 Message-Id: <20181002005505.6112-28-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-doc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org This converts LoadPin from being a direct "minor" LSM into an ordered LSM. Signed-off-by: Kees Cook Reviewed-by: Casey Schaufler --- include/linux/lsm_hooks.h | 5 ----- security/Kconfig | 2 +- security/loadpin/loadpin.c | 8 +++++++- security/security.c | 1 - 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index b026ea93ff01..098ccf2caa0e 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h @@ -2091,10 +2091,5 @@ extern void __init yama_add_hooks(void); #else static inline void __init yama_add_hooks(void) { } #endif -#ifdef CONFIG_SECURITY_LOADPIN -void __init loadpin_add_hooks(void); -#else -static inline void loadpin_add_hooks(void) { }; -#endif #endif /* ! __LINUX_LSM_HOOKS_H */ diff --git a/security/Kconfig b/security/Kconfig index c68520d97fd7..e59cb9296316 100644 --- a/security/Kconfig +++ b/security/Kconfig @@ -293,7 +293,7 @@ config LSM_ENABLE config LSM_ORDER string "Default initialization order of builtin LSMs" - default "integrity" + default "loadpin,integrity" help A comma-separated list of LSMs, in initialization order. Any LSMs left off this list will be link-order initialized diff --git a/security/loadpin/loadpin.c b/security/loadpin/loadpin.c index d8a68a6f6fef..dab42bfa1e4a 100644 --- a/security/loadpin/loadpin.c +++ b/security/loadpin/loadpin.c @@ -184,13 +184,19 @@ static struct security_hook_list loadpin_hooks[] __lsm_ro_after_init = { LSM_HOOK_INIT(kernel_load_data, loadpin_load_data), }; -void __init loadpin_add_hooks(void) +static int __init loadpin_init(void) { pr_info("ready to pin (currently %senforcing)\n", enforcing ? "" : "not "); security_add_hooks(loadpin_hooks, ARRAY_SIZE(loadpin_hooks), "loadpin"); + return 0; } +DEFINE_LSM(loadpin) = { + .name = "loadpin", + .init = loadpin_init, +}; + /* Should not be mutable after boot, so not listed in sysfs (perm == 0). */ module_param(enforcing, int, 0); MODULE_PARM_DESC(enforcing, "Enforce module/firmware pinning"); diff --git a/security/security.c b/security/security.c index 6fafad44b85e..6957f5f50483 100644 --- a/security/security.c +++ b/security/security.c @@ -297,7 +297,6 @@ int __init security_init(void) */ capability_add_hooks(); yama_add_hooks(); - loadpin_add_hooks(); /* Load LSMs in specified order. */ prepare_lsm_order(); -- 2.17.1