Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp606430imu; Mon, 26 Nov 2018 15:42:38 -0800 (PST) X-Google-Smtp-Source: AJdET5egaJXOzFNRLNQcJdire+DiU1By/JjOddr20lQo2orreFDTsPrzE6QdwmjA7exTmm/eM4Ue X-Received: by 2002:a62:1bd7:: with SMTP id b206mr30254395pfb.213.1543275758725; Mon, 26 Nov 2018 15:42:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543275758; cv=none; d=google.com; s=arc-20160816; b=OF1foukeWPI8gwaoRHIZVTeKEAKM2JDo+CLKyAKcCb7ONWl1n3GkeULYQ//pTARoA8 i57YkAlEpvynF5vvw6Oo5z+c4f+f64JmcdggU4duxc+RSeEcqspu7BAeZ5h0q54oRgE9 upqTJIWFYbc8+/pIlVM/tNnBmv0nQLX43vj9TPJL+8qN37QAYPaVSkwjA5v2a+H5GvUY F6+QmjYSKOymHvP3oocJCuEP8KJUXo0Ex8CTGrCa3W23JhT7eKoNloahnbR2g+pFvAiW OQLFuQXUs+NTVJL2kQfKLaFwt7iA4ra6tEYT/EHl6Bud5yGftK1BKrmr66wLnAFDo2/J S+Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=fVRVzoVAGOfByb/OFixOZSHvg+YGRncLAzZbI7X+PB4=; b=o8Y9tpQQxFp7BMXokOToKHZ9OTYhdfRtLLu+dc/nMJFImnAlbrZlM+IAz5C+YUWfqX QHIQfHaVPp7Bucq/oE7364+4RC0DqZcddg0JdpCMTeSh1OwDNtE6nYc/JhmCBhitFbjL MfqXSbEIjVQkq8gHWGpxq5VPtEHE3uGfIyU/mEjZA0tikDDd+/iEYkAojGpPc1P4kWYl ipYOmCnVleBTGxc/LVnOdsj2o7Zx3hG5jHCQUrMry0H7mn/lfQPfUKNwHAfOpX/1jRU9 wQS3D55vwSU40GrFWE6jblb+S27BiaA/jENA14ID1qBxVEmkK2VzNM5lQ5VZFechLlzf cfzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=aHaG5NTi; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b24si1749394pgg.288.2018.11.26.15.42.23; Mon, 26 Nov 2018 15:42:38 -0800 (PST) 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=@yahoo.com header.s=s2048 header.b=aHaG5NTi; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727804AbeK0KhJ (ORCPT + 99 others); Tue, 27 Nov 2018 05:37:09 -0500 Received: from sonic304-28.consmr.mail.ne1.yahoo.com ([66.163.191.154]:42007 "EHLO sonic304-28.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727646AbeK0KhJ (ORCPT ); Tue, 27 Nov 2018 05:37:09 -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=aHaG5NTite4g0yXIUuftVxSoRcpRH/V1A84lIWUk9Abtr3jaVXKzdV6lrzQemwLD5ktJwzEg51eYIFQ8iIkaZ+lKcf0ifhu/cctXUCFUEo+WYXi8/vMwwxCGD4k5Ny/g0s0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NhL.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-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(); -- 2.14.5