Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp15034imm; Thu, 20 Sep 2018 17:13:08 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY3OFgQPY5nnR0i3IjJm36Hgt+Lpe1FiU4NVEejYw1trlPqsz2UvONhnpSHb1Zs/m/k3uI/ X-Received: by 2002:a63:d048:: with SMTP id s8-v6mr1481169pgi.311.1537488788165; Thu, 20 Sep 2018 17:13:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537488788; cv=none; d=google.com; s=arc-20160816; b=cKQ8AIYTBWNdV9QzgynbQ6uVqUHZ96UiSqyffLd5cwOWXB2M0JeiSlLVslzUMwtemK y7+Lkkqwe0VBnK38uJGEymXv1S49wavS1NZk/06+qgMAfarkgW+Td98mhX18lzGqZ8hQ nZd6PVtYCd84DeIC7rN2DJkuJc78OCoMMjHTvluYnXey1jfo37+XRtjKMiLjrEqbfvsa 64WADMdT2utHfeGuMx5zH3wIJ3/1g0KiPFHBnQv1Sm5lgnUaxSkja6gKl+jKw2ywmH7T Z4BbIeIJlPm1pQXbBXN8ZLArSba0gkx/YrINI/+EwobscHSzgt8sPRHmWNFZCF2gpUop f2aw== 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=82peLjBhSiHNgFYaidybAqoaUyeQ0Ys2x10pG6UkUss=; b=wlWcGhTeWRf8WBsS8qJuGVUMKvMDJflDukNMA8L3k7FvGGX40SIIyqCo6lC7bwysg9 P20SGCzWeo/rXQQjAcJWEpgxCfLDDeRZWPCBM/ovWvmaWsPdJRghfrDT+xlFTddmAIZ2 kLcFA9Dazmm71wGlVjPdLuyL48lRVOl9gJjpktmNTA3aCA3ajyRk23q5wdSdZ+GBHwwE kcQEOqQx4DyFu9OFYNPcI3UDK6+2d6k4+Bl47Jl2BJrZu3DhsbKX88kaoaTBSxr0u1kU 9oQGlIEKFrLI7xmn3D5mYT8rAvwXBHogMp5P3o4+LvftLzX98MSUOP9cWBkzE4GF9w7k BlFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=Ln+qk8qc; 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 e22-v6si24519381pgi.111.2018.09.20.17.12.51; Thu, 20 Sep 2018 17:13:08 -0700 (PDT) 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=Ln+qk8qc; 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 S2388718AbeIUF4p (ORCPT + 99 others); Fri, 21 Sep 2018 01:56:45 -0400 Received: from sonic305-10.consmr.mail.bf2.yahoo.com ([74.6.133.49]:45327 "EHLO sonic305-10.consmr.mail.bf2.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725780AbeIUF4p (ORCPT ); Fri, 21 Sep 2018 01:56:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1537488639; bh=82peLjBhSiHNgFYaidybAqoaUyeQ0Ys2x10pG6UkUss=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=Ln+qk8qcmUkjJsrY9MoT7xeuibAVP0Pcefxwew7rhhq2i3W9MQVMJKNVYcbc4r2ftHRNJ5K+bUUSTay/4Nc/8dTJ5VYK9LwDDhovvxOm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HxA7p zwjGl1EgQbUfdpcAqMLXc93cDjog46eseZclXDbzb9SJvArfYVNPMEGhn7qpQCfoV5pyBfh0yTwY pujnbVgVBFA4AMrexB6ODK2Y.uwr05Gk9Pekife57YY9cD_28p_vohhvALVCYT5Ce50sfmcI357Z 5VV6Jd7JxHi_nWFMgfjSeTpamp7ic8ipIyU3q8_QjrNEcjNWqiRSjhzTmBCdDWEb8tqIvvvfvHvE xZ6zuIelZ5msFyC93A8.t8uapNJE2wmZUdPBlAw-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.bf2.yahoo.com with HTTP; Fri, 21 Sep 2018 00:10:39 +0000 Received: from c-67-169-65-224.hsd1.ca.comcast.net (EHLO [192.168.0.102]) ([67.169.65.224]) by smtp429.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 4df4822910f7438fc6d2591add0b14ad; Fri, 21 Sep 2018 00:10:37 +0000 (UTC) Subject: Re: [PATCH security-next v2 19/26] LSM: Introduce CONFIG_LSM_ORDER To: Kees Cook , James Morris Cc: 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 References: <20180920162338.21060-1-keescook@chromium.org> <20180920162338.21060-20-keescook@chromium.org> From: Casey Schaufler Message-ID: <25825681-a465-684d-d48e-79473bca7606@schaufler-ca.com> Date: Thu, 20 Sep 2018 17:10:33 -0700 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: <20180920162338.21060-20-keescook@chromium.org> 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 On 9/20/2018 9:23 AM, Kees Cook wrote: > This provides a way to declare LSM initialization order via Kconfig. > > Signed-off-by: Kees Cook > --- > security/Kconfig | 11 +++++++++++ > security/security.c | 38 +++++++++++++++++++++++++++++++++++--- > 2 files changed, 46 insertions(+), 3 deletions(-) > > diff --git a/security/Kconfig b/security/Kconfig > index 27d8b2688f75..de8202886c1d 100644 > --- a/security/Kconfig > +++ b/security/Kconfig > @@ -276,5 +276,16 @@ config DEFAULT_SECURITY > default "apparmor" if DEFAULT_SECURITY_APPARMOR > default "" if DEFAULT_SECURITY_DAC > > +config LSM_ORDER > + string "Default initialization order of builtin LSMs" > + default "integrity" I would like to see the default spelled out rather than provided implicitly. + default "integrity,yama,loadpin,selinux,smack,apparmor,tomoyo" > + help > + A comma-separated list of LSMs, in initialization order. > + Any LSMs left off this list will be link-order initialized > + after any listed LSMs. Any LSMs listed here but not built in > + the kernel will be ignored. This should also describe what will happen if you include multiple major modules in the list. > + > + If unsure, leave this as the default. > + > endmenu > > diff --git a/security/security.c b/security/security.c > index 2541a512a0f7..063ee2466e58 100644 > --- a/security/security.c > +++ b/security/security.c > @@ -44,6 +44,8 @@ char *lsm_names; > /* Boot-time LSM user choice */ > static __initdata const char *chosen_major_lsm; > > +static __initconst const char * const builtin_lsm_order = CONFIG_LSM_ORDER; > + > /* Ordered list of LSMs to initialize. */ > static __initdata struct lsm_info **ordered_lsms; > > @@ -108,14 +110,44 @@ static void __init append_ordered_lsm(struct lsm_info *lsm, const char *from) > (!lsm->enabled || *lsm->enabled) ? "en" : "dis"); > } > > -/* Populate ordered LSMs list from hard-coded list of LSMs. */ > +/* Populate ordered LSMs list from given string. */ > +static void __init parse_lsm_order(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; > + } > + } > + > + if (!found) > + init_debug("%s ignored: %s\n", origin, name); > + } > + kfree(sep); > +} > + > +/* Populate ordered LSMs list from builtin list of LSMs. */ > static void __init prepare_lsm_order(void) > { > struct lsm_info *lsm; > > + /* Parse order from builtin list. */ > + parse_lsm_order(builtin_lsm_order, "builtin"); > + > + /* Add any missing LSMs, in link order. */ > for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) { > - if (strcmp(lsm->name, "integrity") == 0) > - append_ordered_lsm(lsm, "builtin"); > + if ((lsm->flags & LSM_FLAG_LEGACY_MAJOR) == 0) > + append_ordered_lsm(lsm, "link-time"); > } > } >