From patchwork Mon Nov 26 23:41:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Casey Schaufler X-Patchwork-Id: 10699421 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 84C5C109C for ; Mon, 26 Nov 2018 23:41:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EDB8290D8 for ; Mon, 26 Nov 2018 23:41:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F5642A660; Mon, 26 Nov 2018 23:41:21 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 06030290D8 for ; Mon, 26 Nov 2018 23:41:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727552AbeK0KhI (ORCPT ); Tue, 27 Nov 2018 05:37:08 -0500 Received: from sonic304-28.consmr.mail.ne1.yahoo.com ([66.163.191.154]:43089 "EHLO sonic304-28.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727655AbeK0KhI (ORCPT ); Tue, 27 Nov 2018 05:37:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1543275679; bh=fVRVzoVAGOfByb/OFixOZSHvg+YGRncLAzZbI7X+PB4=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b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v.K8MKq.BB6WWdyRoPVyE I9.SBZ1B_JDf2ajjz4YGmwqB0fK_b6OPu680CxEcQ3hQWU0HwMlXaFADbsqHC.ypcu24V8dc6Zl1 ecSlYpfZcFwV9Fo1V2aroNnTzGiuBsdNhL.Cvz7CMxATypjhaaMkNC692QdmCuVnZ2xZ.bRYrWo1 wfPHxlojYfbwqBTxD_GsAti.SUaWI1z7i2X6b.XD9nAM6fCyRO60bHAhOP2IifK9166vg1CtlCUz IBxT5JC35K5jQJI4gJsbruCkOCldXbSShRlmtksHv1hXJpicbRuL9MFEqDEI5muAdVakZ_00ndpf dP9rZ2g29IFjAsY7pHxrRIIuZVJGf0RlTozfyuK0uJZx1IwFQ2TstOUx_3C_mWuzbw7lcehwdJxm 85upxH55gnTSpz7R25.9uldv0pG_CyEHDACza4n.MA3A- Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.ne1.yahoo.com with HTTP; Mon, 26 Nov 2018 23:41:19 +0000 Received: from c-67-169-65-224.hsd1.ca.comcast.net (EHLO [192.168.0.105]) ([67.169.65.224]) by smtp417.mail.ne1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 3591437ae6288a942f86718ae111444e; Mon, 26 Nov 2018 23:41:14 +0000 (UTC) Subject: [PATCH v5 19/38] capability: Initialize as LSM_ORDER_FIRST To: James Morris , LSM , LKLM , SE Linux Cc: John Johansen , Kees Cook , Tetsuo Handa , Paul Moore , "linux-fsdevel@vger.kernel.org" , Stephen Smalley , Alexey Dobriyan , =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , Salvatore Mesoraca References: <50db058a-7dde-441b-a7f9-f6837fe8b69f@schaufler-ca.com> From: Casey Schaufler Message-ID: <147e1a0c-3d18-c467-8f5a-6559cfcf818c@schaufler-ca.com> Date: Mon, 26 Nov 2018 15:41:11 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <50db058a-7dde-441b-a7f9-f6837fe8b69f@schaufler-ca.com> Content-Language: en-US Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This converts capabilities to use the new LSM_ORDER_FIRST position. Signed-off-by: Kees Cook Reviewed-by: Casey Schaufler --- include/linux/lsm_hooks.h | 2 -- security/commoncap.c | 9 ++++++++- security/security.c | 5 ----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index 83858e3df9e5..15fc49ee41a1 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h @@ -2092,6 +2092,4 @@ static inline void security_delete_hooks(struct security_hook_list *hooks, #define __lsm_ro_after_init __ro_after_init #endif /* CONFIG_SECURITY_WRITABLE_HOOKS */ -extern void __init capability_add_hooks(void); - #endif /* ! __LINUX_LSM_HOOKS_H */ diff --git a/security/commoncap.c b/security/commoncap.c index 18a4fdf6f6eb..ec387535e597 100644 --- a/security/commoncap.c +++ b/security/commoncap.c @@ -1363,10 +1363,17 @@ struct security_hook_list capability_hooks[] __lsm_ro_after_init = { LSM_HOOK_INIT(vm_enough_memory, cap_vm_enough_memory), }; -void __init capability_add_hooks(void) +static int __init capability_init(void) { security_add_hooks(capability_hooks, ARRAY_SIZE(capability_hooks), "capability"); + return 0; } +DEFINE_LSM(capability) = { + .name = "capability", + .order = LSM_ORDER_FIRST, + .init = capability_init, +}; + #endif /* CONFIG_SECURITY */ diff --git a/security/security.c b/security/security.c index 701507174f40..eab64bdc60fb 100644 --- a/security/security.c +++ b/security/security.c @@ -277,11 +277,6 @@ int __init security_init(void) i++) INIT_HLIST_HEAD(&list[i]); - /* - * Load minor LSMs, with the capability module always first. - */ - capability_add_hooks(); - /* Load LSMs in specified order. */ ordered_lsm_init();