Received: by 2002:a4a:301c:0:0:0:0:0 with SMTP id q28-v6csp127180oof; Mon, 24 Sep 2018 17:26:19 -0700 (PDT) X-Google-Smtp-Source: ACcGV62EqGhFg8i4MQNJG5AR/FqasOfsPnzm46fRBgYF5X9HR3sKXuOknS4BufAqeIpPhjXFGXhK X-Received: by 2002:a17:902:710e:: with SMTP id a14-v6mr971635pll.179.1537835179120; Mon, 24 Sep 2018 17:26:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537835179; cv=none; d=google.com; s=arc-20160816; b=xGDkVaHSk+5ETfh+nLIC5jwYv9HRAIFUvGJUHvasR6XB77pCyIZXbpVOhyPmjTU8pZ 5P20+gtem7omaPpbI+MH1yKdaqMZDHpDXN8UC3A65Z+l/iWzeVB7a6Sf9zjqHANONmbf ATRj6DVTA43RGZhYOAqDiRO55hqgMuhMj+iCNf0WfQQGrPl12LGEnJz2oLwsxxDmrDa8 pztubSp7MbjLNyKBPASp6R/kajBk3dwGiVlwV+HkVq0jovcBApa/NPaJfk1yFeGKuhLF qe8bMhukqT5RzBosm7jaBhn+Oq5vmBNsKFDtwhJspvwvxp12aVqRViFGTHvW87AspF3I /6Wg== 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=Pya6MC5far/FOfcushoRqmIT4FUPYgdqjyBKbeVxUoc=; b=gcSgQNcwdIghPvxPfH+vi97+8WTXhtuwqMT7dGLlG8T7CQAtdipe+/hn4bYgAaaxzu ROAW6LHm4945GF9WPVvaW2GQYtd+zwTxESqe9MFH2Fg4fLJr7m7BiQcTyOnEC2WS31Fn 83JtTHZ55QmHAvTXjgWkLfpNurUB1Yh4mOCCSad5sRfvbySo3Vl+/EnQHu2NiB+Y4nC2 9oJVBIi39z7x8ArumHqJ0kELCl2UNFdAO6LYYskZ3qgQF6LPR1ZWGZFr1G9ULgxzXkdo a7Bec11n6ul51oJdtSCioIVBIQ9aBIP+sJAtAaFy/ohpvII1BL2POFwYozwAp/e5VjY3 36oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=UCVgRcnc; 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 p19-v6si696268pgm.109.2018.09.24.17.26.03; Mon, 24 Sep 2018 17:26:19 -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=UCVgRcnc; 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 S1728266AbeIYGaJ (ORCPT + 99 others); Tue, 25 Sep 2018 02:30:09 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:41585 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727441AbeIYGaI (ORCPT ); Tue, 25 Sep 2018 02:30:08 -0400 Received: by mail-pf1-f196.google.com with SMTP id m77-v6so1224943pfi.8 for ; Mon, 24 Sep 2018 17:25:20 -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=Pya6MC5far/FOfcushoRqmIT4FUPYgdqjyBKbeVxUoc=; b=UCVgRcncAb7cIHCs1DGQLChJ9vknqvr/KNTZmJDV0LdfEJZVVSzD0shsoQEJqe4PXs UwUKLSseT07JL4uz0zHBV/9Cr9zChAdT+lUVenHyPtM4SBk4R7WFHN9YiF2IFf3WNuZP U7JVbVyivOeCwc8DrjTpiDsGGtbIWs3Baj5WY= 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=Pya6MC5far/FOfcushoRqmIT4FUPYgdqjyBKbeVxUoc=; b=i4uKUCBvJcKFZLC7RI+F67RnoWzxxuNnGTuC8QAJ418pqwNEUf2Y9UoLuS2qTCTXo/ 0p2C3aKvjuOCRnNF6sCDy6xI8RsdvuIXBXL7/H71wqFcD+7Pv20hjiVIgfSvZquWEAyY ZxPGNpLF8hpo4gwlzrB57chkspWbQ9XuCTTaL2a20Xu5v+Bp7XkdootLalZpXo22wzEH G6SxJx21pKf4oklVvuGNAcnPL/OQ7fOHiTD7MMh525mDQCe4sg7vyOCEYZo1WMIZCuuh WdkUi8f4nlCqzhu+PGbSUp73NXhSgGzO8fuxg9TIT8rsJfZ4xRz0TqUo5yeKGXt+TGJW mcyg== X-Gm-Message-State: ABuFfog7jqRoyKt0XOqOqJa28uzTZTcfb93VbhfgnjVN59xBKlljPUy1 Etsqp7WPG5p4PZt410KZUb0WwA== X-Received: by 2002:a62:c288:: with SMTP id w8-v6mr1024051pfk.92.1537835119907; Mon, 24 Sep 2018 17:25:19 -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 e123-v6sm635695pfg.3.2018.09.24.17.25.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Sep 2018 17:25:16 -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 24/29] LoadPin: Initialize as ordered LSM Date: Mon, 24 Sep 2018 17:18:27 -0700 Message-Id: <20180925001832.18322-25-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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This converts LoadPin from being a direct "minor" LSM into an ordered LSM. Signed-off-by: Kees Cook --- include/linux/lsm_hooks.h | 5 ----- security/Kconfig | 2 +- security/loadpin/loadpin.c | 7 ++++++- security/security.c | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index ab23f1bc6d77..9df08955f684 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h @@ -2097,10 +2097,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 7ec86dbdb6b8..e20c2a3143e7 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..7abdf4619b46 100644 --- a/security/loadpin/loadpin.c +++ b/security/loadpin/loadpin.c @@ -184,13 +184,18 @@ 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) + .init = loadpin_init, +END_LSM; + /* 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 f1c3581d870f..cb25f321e044 100644 --- a/security/security.c +++ b/security/security.c @@ -305,7 +305,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