From patchwork Tue Sep 25 00:18:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10613147 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 EB719112B for ; Tue, 25 Sep 2018 00:26:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D851429F00 for ; Tue, 25 Sep 2018 00:26:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CCA5929F85; Tue, 25 Sep 2018 00:26:09 +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 7498029F00 for ; Tue, 25 Sep 2018 00:26:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727453AbeIYGa4 (ORCPT ); Tue, 25 Sep 2018 02:30:56 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:45828 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbeIYGaF (ORCPT ); Tue, 25 Sep 2018 02:30:05 -0400 Received: by mail-pg1-f195.google.com with SMTP id t70-v6so5318458pgd.12 for ; Mon, 24 Sep 2018 17:25:17 -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=26HwrhgbY9cvM6kiZxqXmx96X44xA2LItbJkK19GtUc=; b=jEHfLEEmvCHoHpdkX18SYepWqOJD5LRyua7XSGQhGp2ygtqjv/oHu8rVpid8kjPMBY L1R3EvDuejeJXG60ENlSUInWBdp0v0wvMJpEPpDd5zVtE/X8nJgieCMqIcZ0ast6c1vQ BXIzX1Wxjs2z5WzbNhL6qkL/wytvy11EK7NB4= 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=26HwrhgbY9cvM6kiZxqXmx96X44xA2LItbJkK19GtUc=; b=dM5TN2lLTh6wRbPBvMpFgNEXMxCz5NhERr4/HXJ0/BSh9pjp6yNZZldXcLK3w9w0t5 KKHZFKIHUnrgh/vhUt/Og1CdR6NONU1ec+LhrcgjbjxCFsdy/IdwXAzJds7mezQmeTOc KVNGJqQvrbKImf+4LFRmvAsT3j1ixdGXJ25+8Am0vNtgVScrYZixdK1HSirakT6Aepse OWkXR7luyjGmBrklyCCY+WEZMmvRDw8/mpi4CGK4SzFUlgc9jZq2vZctOtuXamJgGxzI 2Akddwtrz5tBiXMViQXz2DsPGohu9MpqqSCfEoew7e1H70OG0Jz2fPHh8MCy7QEbG4I6 79Mg== X-Gm-Message-State: ABuFfogHptI2k8AexRf/DdaAkIwWlUYaGHrC4IyE9cMtKvgE2dHZDosz +t/6feRGeQ90ar4RQf1ZxnJCxg== X-Google-Smtp-Source: ACcGV63ugphL4k+l4lCbKf1vYeL+nBWs/NoSCC1/5e65OIcYkG38MwZn7jzbPEayozc7XA4wdDAgfQ== X-Received: by 2002:a63:c912:: with SMTP id o18-v6mr885994pgg.331.1537835117337; Mon, 24 Sep 2018 17:25:17 -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 3-v6sm683002pfq.10.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 25/29] Yama: Initialize as ordered LSM Date: Mon, 24 Sep 2018 17:18:28 -0700 Message-Id: <20180925001832.18322-26-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 This converts Yama 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/security.c | 1 - security/yama/yama_lsm.c | 7 ++++++- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index 9df08955f684..5be95c6155b4 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h @@ -2092,10 +2092,5 @@ static inline void security_delete_hooks(struct security_hook_list *hooks, #endif /* CONFIG_SECURITY_WRITABLE_HOOKS */ extern void __init capability_add_hooks(void); -#ifdef CONFIG_SECURITY_YAMA -extern void __init yama_add_hooks(void); -#else -static inline void __init yama_add_hooks(void) { } -#endif #endif /* ! __LINUX_LSM_HOOKS_H */ diff --git a/security/Kconfig b/security/Kconfig index e20c2a3143e7..e37de9a44747 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 "loadpin,integrity" + default "yama,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/security.c b/security/security.c index cb25f321e044..c4ba5832ef2f 100644 --- a/security/security.c +++ b/security/security.c @@ -304,7 +304,6 @@ int __init security_init(void) * Load minor LSMs, with the capability module always first. */ capability_add_hooks(); - yama_add_hooks(); /* Load LSMs in specified order. */ prepare_lsm_order(); diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c index ffda91a4a1aa..f2b1f47f98e8 100644 --- a/security/yama/yama_lsm.c +++ b/security/yama/yama_lsm.c @@ -477,9 +477,14 @@ static void __init yama_init_sysctl(void) static inline void yama_init_sysctl(void) { } #endif /* CONFIG_SYSCTL */ -void __init yama_add_hooks(void) +static int __init yama_init(void) { pr_info("Yama: becoming mindful.\n"); security_add_hooks(yama_hooks, ARRAY_SIZE(yama_hooks), "yama"); yama_init_sysctl(); + return 0; } + +DEFINE_LSM(yama) + .init = yama_init, +END_LSM;