Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp605265imu; Mon, 26 Nov 2018 15:41:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/V9HeNkS7pvdYd5PNP0u4Fy1v2cNmL4NjepRishGrzMwRh8MqZEzdTjdFVX03qzXxBWPohT X-Received: by 2002:a63:9041:: with SMTP id a62mr26437030pge.163.1543275688193; Mon, 26 Nov 2018 15:41:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543275688; cv=none; d=google.com; s=arc-20160816; b=DwyfQtO6bJlTFaIkQCFNcmYMKXfMnS49X4gH//PSHfoWu4fIUaVz3F1G47CrIjuhuu CoIB/eEohhHWFhPgJ9UOA4OgKhyP8wlsd58VprBI629hWtDrX4kY6TwzsWFJi999X+sf 2RgrMD1RTHVWVBamtNhY1M2eEW4n7lwHsRHm+r+1Fo/JjqUxsf6dm1LeN5oZyAEXZsmI HaHU5dCRPaFYH4CaE8XKG7XLRFcM8mp4YIJIK8THAxv1unK1cqsIAL4BK+Y2BK2nvqFM GqLRdzlkMeiyVwyGg9jFBsGIssG1lPRUT4IGFTwpKsXtTQX27kX5fDZU4sdutXvtU2rb 1p6g== 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=8TjNx2g1chY4n2IW/puLwgiMqt54Rjm+/U9l+waY/Xs=; b=DhuvzVPX91FCSMyc/7Heshwqb/k7lRrSLUqsz8GHczE8Gj2f1gyYsJKcvT43IXCwbj dwBkJ0vMTbbLv7L3vXrowRuQoJDGj2yfUMiCl1aKhx+UDOsNf1oXHNyZi/o7RSlXjlfV pd+RN1jt1RzPTOvhNpIejrbpgkcDyLAfbBV5KvOqprreumJm9G9uoL9uiRsE8EnvckgR a5GrM/Ep2TcCeUgZ+VhseR1RrHech5npBZ7OYcttJQjRmISi3CXXUH1vnKgv0piMWQgK tJejODcgYFkPafSCX3a03BATC57pUlhJbLzZm8JbTtPUxbnaWQuM597XitJCldfU+EXW sAcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=jKFj2j58; 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 x5-v6si1826965pfx.74.2018.11.26.15.41.12; Mon, 26 Nov 2018 15:41:28 -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=jKFj2j58; 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 S1727784AbeK0KgY (ORCPT + 99 others); Tue, 27 Nov 2018 05:36:24 -0500 Received: from sonic315-27.consmr.mail.ne1.yahoo.com ([66.163.190.153]:36365 "EHLO sonic315-27.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727661AbeK0KgX (ORCPT ); Tue, 27 Nov 2018 05:36:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1543275633; bh=8TjNx2g1chY4n2IW/puLwgiMqt54Rjm+/U9l+waY/Xs=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=jKFj2j5896laizVIi+a61tK4n/eScgFDr4YyxsQ1YVI4RDnDpdlQf2JvnSbnbw7FVmkagobLZunD+SMjmmT/q8LrJEfJWGvWlghmJAk9goaiQ9LJFuEu2JYX3QjK9DnzSXiEAMWXX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k.5mX75diSqkpSmlHJ2CaGc7PlITjaqyyhTIUoz T7we5ZvTgiDRi1kJS53731lRSmBFAccL4u1n23fR_.KjgUN2W_4_trGaoDH2573YUDRs6jmsXxtR ewT5yQ79GLCR.8RbJgKAcYHyRt1TSH_DM77IQOGMfpACiIsizwkaEJrqM2mLIaWpnBkr8X1mrNMI ADn1QqfD0YZPtN7BqtdpnH07BGLHBV8RORdoa5ii80TMGI1AJ.7wvJRCZbFCOCaWPvamc_rCKHbk 09zlykYP3qQZ942ZAKHfEVUfJ0bziVqPrgxcIdQ-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.ne1.yahoo.com with HTTP; Mon, 26 Nov 2018 23:40:33 +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 9f29ed8b68840928352cac47bd91d1b1; Mon, 26 Nov 2018 23:40:32 +0000 (UTC) Subject: [PATCH v5 18/38] LSM: Introduce enum lsm_order 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: <630a8aa4-67b3-4b83-7feb-ca0cbd15b3ac@schaufler-ca.com> Date: Mon, 26 Nov 2018 15:40:29 -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 In preparation for distinguishing the "capability" LSM from other LSMs, it must be ordered first. This introduces LSM_ORDER_MUTABLE for the general LSMs and LSM_ORDER_FIRST for capability. In the future LSM_ORDER_LAST for could be added for anything that must run last (e.g. Landlock may use this). Signed-off-by: Kees Cook --- include/linux/lsm_hooks.h | 6 ++++++ security/security.c | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index 6cfbd7d78a89..83858e3df9e5 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h @@ -2042,8 +2042,14 @@ extern void security_add_hooks(struct security_hook_list *hooks, int count, #define LSM_FLAG_LEGACY_MAJOR BIT(0) #define LSM_FLAG_EXCLUSIVE BIT(1) +enum lsm_order { + LSM_ORDER_FIRST = -1, /* This is only for capabilities. */ + LSM_ORDER_MUTABLE = 0, +}; + struct lsm_info { const char *name; /* Required. */ + enum lsm_order order; /* Optional: default is LSM_ORDER_MUTABLE */ unsigned long flags; /* Optional: flags describing LSM */ int *enabled; /* Optional: controlled by CONFIG_LSM */ int (*init)(void); /* Required. */ diff --git a/security/security.c b/security/security.c index 0c3c66dbf51c..701507174f40 100644 --- a/security/security.c +++ b/security/security.c @@ -174,6 +174,12 @@ static void __init ordered_lsm_parse(const char *order, const char *origin) struct lsm_info *lsm; char *sep, *name, *next; + /* LSM_ORDER_FIRST is always first. */ + for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) { + if (lsm->order == LSM_ORDER_FIRST) + append_ordered_lsm(lsm, "first"); + } + /* Process "security=", if given. */ if (chosen_major_lsm) { struct lsm_info *major; @@ -202,7 +208,8 @@ static void __init ordered_lsm_parse(const char *order, const char *origin) bool found = false; for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) { - if (strcmp(lsm->name, name) == 0) { + if (lsm->order == LSM_ORDER_MUTABLE && + strcmp(lsm->name, name) == 0) { append_ordered_lsm(lsm, origin); found = true; } -- 2.14.5