Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp596040imu; Mon, 26 Nov 2018 15:32:38 -0800 (PST) X-Google-Smtp-Source: AJdET5fW8Q0WvAzudPnc03wq91W4SqFNfXmw2l0QMelnAm/SF7BqOMcQ+s0Q0ycV8TOvPGLRv8Uk X-Received: by 2002:a62:868b:: with SMTP id x133mr31837008pfd.252.1543275158844; Mon, 26 Nov 2018 15:32:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543275158; cv=none; d=google.com; s=arc-20160816; b=AKSNEBVDIXP9IfASismRoDM2uFMRGxFteuM5WQUnr2/5hPJYHBI5V2dNYHX4q+7i68 RN3JuA7YNBY8i3oW7kfFKPEMvXxy3m1/lCL3wf0ujwjsJVheDgnhVRMdmF4RPM+pljvS WupkpJz1edfILuE8VBnnKAijQycmmIQajnYf74dM3j17pCB496a7YdVI60/pKr46MC0d TTfCsVdvz8810DzaGQ7lyfea73GEZhFvdxAjo9DqRBmlDr+PBvNJ+aAnIdxxpNuKJpTJ IaEREirbFoh3ihmiUNvZs5Fo50E+Z89rihsqMFF4w44kEVABlNd18IA30Nv1q+Mbp07Q xSeQ== 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=TGi2qrqGS1NpUSr2tXr7yuOrqhaa8jqVNl/N6nC/ayc=; b=bZsvPjVD6VWnVlr9vNqk2v39GPXL+gDyJXujpPQ8XrO23y2uwkffEdxCf+MTDactm/ sYqFD94LQ7/gbHtxu0/F1k7fO3KCAOUdEyioR8Ml+cO69TKtYzxqQTjJS3dpywnxXWVj 3RSItZNkto5SD9YLeqE0glp0qEmjiHi4gySv5OZKCKIngS41ggMGcvJmYA8o933UqdTX rMOCPnhpIxjPv4yUhAphdbAEtTAZbIvWgM8kUDNWvHWcgRRCDbewkFElX6jRFLHbvgCJ 8dmTnLQJ+8Z2FYm/k41djlUgO+cJtVMZk5aan8HPAqNq1LkmmU8Qh7eMsWckp0vZ+Dy/ 8MFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=gf3FDKgH; 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 t4si1751772pgg.110.2018.11.26.15.32.24; Mon, 26 Nov 2018 15:32: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=gf3FDKgH; 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 S1727749AbeK0K04 (ORCPT + 99 others); Tue, 27 Nov 2018 05:26:56 -0500 Received: from sonic304-28.consmr.mail.ne1.yahoo.com ([66.163.191.154]:40920 "EHLO sonic304-28.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727456AbeK0K04 (ORCPT ); Tue, 27 Nov 2018 05:26:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1543275068; bh=TGi2qrqGS1NpUSr2tXr7yuOrqhaa8jqVNl/N6nC/ayc=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=gf3FDKgH9QW9LNUOfAmG1iWPvkTKKpO9jae9LDW6LSpRDazVcYpn+qQuW4Z9LrI/ftyXO0VLGyswvfByB7UBCQcpnWE/7rAhOdZUBwO6hGoSpGDP6Kc2l2Wi9uue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tmrZcNjOX2JHzDgyYBM7HgMIpFe8OpMG Y2eRIcG9RgCiOEq4LUZ9mUUjOru_QE774Bo32UKLZzYi5uJ57rlVjQjOJg56sxEAHzL5mkdzfqPT yHBPEJYxH3nQhmPbKc5Y8vyUPlTWb.VCsN86mCsU5mGn4johEVpmaUMstjk3p29arkJ.aFVaUQEB CiHM5HfiLe5Tq2YYi8NZVVgAZYFDvf3RkmZaW2p.kx7z421Li7oRDH0b6UK8A.gct2kxOl.Ug0Uk PLT2kmFrAqv0EoISHr4UAKaydar89Qd.95P4- Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.ne1.yahoo.com with HTTP; Mon, 26 Nov 2018 23:31:08 +0000 Received: from c-67-169-65-224.hsd1.ca.comcast.net (EHLO [192.168.0.105]) ([67.169.65.224]) by smtp406.mail.ne1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 51780166ccef8dfc214316ac59562bc0; Mon, 26 Nov 2018 23:31:06 +0000 (UTC) Subject: [PATCH v5 06/38] LSM: Introduce CONFIG_LSM 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: Date: Mon, 26 Nov 2018 15:31:04 -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 provides a way to declare LSM initialization order via the new CONFIG_LSM. Currently only non-major LSMs are recognized. This will be expanded in future patches. Signed-off-by: Kees Cook --- security/Kconfig | 9 +++++++++ security/security.c | 27 ++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/security/Kconfig b/security/Kconfig index d9aa521b5206..7de42bbacc28 100644 --- a/security/Kconfig +++ b/security/Kconfig @@ -276,5 +276,14 @@ config DEFAULT_SECURITY default "apparmor" if DEFAULT_SECURITY_APPARMOR default "" if DEFAULT_SECURITY_DAC +config LSM + string "Ordered list of enabled LSMs" + default "integrity" + help + A comma-separated list of LSMs, in initialization order. + Any LSMs left off this list will be ignored. + + If unsure, leave this as the default. + endmenu diff --git a/security/security.c b/security/security.c index 4c193aba4531..96e0b7d057b0 100644 --- a/security/security.c +++ b/security/security.c @@ -48,6 +48,8 @@ char *lsm_names; static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] = CONFIG_DEFAULT_SECURITY; +static __initconst const char * const builtin_lsm_order = CONFIG_LSM; + /* Ordered list of LSMs to initialize. */ static __initdata struct lsm_info **ordered_lsms; @@ -155,15 +157,30 @@ static void __init maybe_initialize_lsm(struct lsm_info *lsm) } } -/* Populate ordered LSMs list from single LSM name. */ +/* Populate ordered LSMs list from comma-separated LSM name list. */ static void __init ordered_lsm_parse(const char *order, const char *origin) { struct lsm_info *lsm; + char *sep, *name, *next; + + sep = kstrdup(order, GFP_KERNEL); + next = sep; + /* Walk the list, looking for matching LSMs. */ + while ((name = strsep(&next, ",")) != NULL) { + bool found = false; + + for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) { + if ((lsm->flags & LSM_FLAG_LEGACY_MAJOR) == 0 && + strcmp(lsm->name, name) == 0) { + append_ordered_lsm(lsm, origin); + found = true; + } + } - for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) { - if (strcmp(lsm->name, order) == 0) - append_ordered_lsm(lsm, origin); + if (!found) + init_debug("%s ignored: %s\n", origin, name); } + kfree(sep); } static void __init ordered_lsm_init(void) @@ -173,7 +190,7 @@ static void __init ordered_lsm_init(void) ordered_lsms = kcalloc(LSM_COUNT + 1, sizeof(*ordered_lsms), GFP_KERNEL); - ordered_lsm_parse("integrity", "builtin"); + ordered_lsm_parse(builtin_lsm_order, "builtin"); for (lsm = ordered_lsms; *lsm; lsm++) maybe_initialize_lsm(*lsm); -- 2.14.5