Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp874618imm; Mon, 1 Oct 2018 21:48:32 -0700 (PDT) X-Google-Smtp-Source: ACcGV62EEW6xFZiKg0aOivR+zg6IT9Ib1TXFipEJUH7FyqxpJodU6cbtfnnRbkgapSlo+BYiLxWt X-Received: by 2002:a62:9b9a:: with SMTP id e26-v6mr14841161pfk.181.1538455712517; Mon, 01 Oct 2018 21:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538455712; cv=none; d=google.com; s=arc-20160816; b=Hrg/0oQsY3GfJl3zHT+wRmhdW2gIhjyhOzv+FsBdar6wxrsHFwOaqKorJnsEkOazub 7wQiK8TEbrMi48mWe4m5hhxM8YzEjp6xEQ9CpwjCEptAm6IAuz3rWTVSadExthnlUnSB BB/bwK2OEWIRJu5j2owpz5YUFQdyBLyeKWEWEA6jHKouQBmeLLwlAritN9uTHWeVOFRT MqQ0w+ITS6hJ1x9LZsxtMy9nfrH5Sn+O36/HpOk5rOz1Jd6WcQEpvQTj9NXGX/GLGPvz zgDsbak4wK/sgxZGVWHoIXCTFR/iubFKp5xzYefL8rJ/CpGN5tb2RseRq5c3/E+jNUf5 C8Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=Cpxv9Irzh5aDs0QGpKP7cNXs2u6/amX9TqmHjX6gKyU=; b=uwmLFQKaOyARa6kO9OT8nFOs4lUuKSX/FLBU6EQa6tAchP+kh3FrxuqjwLBq4fXUCe A9QrTyKn2GDWUdsmHQaoJ0Jq/pU7DsoZDesaLMpRI+3fX/BfLWWhlu2p9ac0VXeS5jtZ 2imaPXTyTNzCCLMeVJxomY6T6z/WJOQjUdy93mjKji0YnIO+mx0DjZDtnSnE6wMdwP7t 6Fs/8ZgsE3tDn0gghICsn2LZaK8s5qNIhmX5EHc02FwxepZ3RyL5BySHVBqQvjkgyPzL z2Jm7k+O6oXcswDjsHm4R2ev5eMlXjo/KXi+M8rw2+EipXfv3v/kgq+8h6lp0InGCJHe xKbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Q4hUwcKU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w16-v6si10657685pge.9.2018.10.01.21.48.18; Mon, 01 Oct 2018 21:48:32 -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=@chromium.org header.s=google header.b=Q4hUwcKU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726892AbeJBL27 (ORCPT + 99 others); Tue, 2 Oct 2018 07:28:59 -0400 Received: from mail-yb1-f193.google.com ([209.85.219.193]:32847 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726814AbeJBL27 (ORCPT ); Tue, 2 Oct 2018 07:28:59 -0400 Received: by mail-yb1-f193.google.com with SMTP id u88-v6so294127ybi.0 for ; Mon, 01 Oct 2018 21:47:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Cpxv9Irzh5aDs0QGpKP7cNXs2u6/amX9TqmHjX6gKyU=; b=Q4hUwcKUWLe6OAegh5LekwopNJDP3KItLdEIlUooMI7FhelnmlTg0yAeXderwxn9Ru rOas1qDRMp+cjcnuplYzNeWaliK98coqpeWFmaXZDjxrhSbI5nW+lPrVu78OcE9B+pfq 0EtjiyCbV8Ed5o7kYejZsaDides859g/5NDDQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Cpxv9Irzh5aDs0QGpKP7cNXs2u6/amX9TqmHjX6gKyU=; b=sqGCP7lo0K4QI2zMnVjaTJVlrbTOevlpUTk7br3bluvP8zz0CoZkTIRALcSmOesYw0 i/C5ZQQ0J8Ht7rax5iERNNbJQW5NsLdy+P3dAaZE6yWjEgGtN0qa1rTKGN4YjE1VwtfD q/wCUrIOUxYxOTANFyq/Ae9h7jy/S3VDIPAA/iiQT6y89CFgR9YiOBUl3fyqnQQqIbXW Xcmwu+9aujDHvbEbYbJwsE1Xmu7HxDqE9i29TmS0uT4DEnz5G6VmoE7czzi5qVv9jkNv VGA5gIqbrvWpEzMBRYF1NX4yZqQEa8ePhWlTKd+8exPpPfOa2jK6F4wVPF+NRzwNrJGg 0m+w== X-Gm-Message-State: ABuFfojxeAOcAnHTSq/JS3GhACEZN1oUfeY9J8LP+c1X3fl0rx1gZuPf Fuulo/M480p3QhFR8h6HSWjo0nC7fs0= X-Received: by 2002:a25:d2d6:: with SMTP id j205-v6mr7530244ybg.470.1538455662698; Mon, 01 Oct 2018 21:47:42 -0700 (PDT) Received: from mail-yw1-f52.google.com (mail-yw1-f52.google.com. [209.85.161.52]) by smtp.gmail.com with ESMTPSA id p185-v6sm2746071ywc.14.2018.10.01.21.47.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Oct 2018 21:47:41 -0700 (PDT) Received: by mail-yw1-f52.google.com with SMTP id a197-v6so262330ywh.9 for ; Mon, 01 Oct 2018 21:47:40 -0700 (PDT) X-Received: by 2002:a0d:fec6:: with SMTP id o189-v6mr7732638ywf.237.1538455660237; Mon, 01 Oct 2018 21:47:40 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:d116:0:0:0:0:0 with HTTP; Mon, 1 Oct 2018 21:47:39 -0700 (PDT) In-Reply-To: <0d76adea-93b9-9512-a57b-8605b7928bc2@infradead.org> References: <20181002005505.6112-1-keescook@chromium.org> <20181002005505.6112-14-keescook@chromium.org> <0d76adea-93b9-9512-a57b-8605b7928bc2@infradead.org> From: Kees Cook Date: Mon, 1 Oct 2018 21:47:39 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH security-next v4 13/32] LoadPin: Rename "enable" to "enforce" To: Randy Dunlap Cc: James Morris , Casey Schaufler , John Johansen , Tetsuo Handa , Paul Moore , Stephen Smalley , "Schaufler, Casey" , LSM , Jonathan Corbet , "open list:DOCUMENTATION" , linux-arch , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 1, 2018 at 6:06 PM, Randy Dunlap wrote: > On 10/1/18 5:54 PM, Kees Cook wrote: >> LoadPin's "enable" setting is really about enforcement, not whether >> or not the LSM is using LSM hooks. Instead, split this out so that LSM >> enabling can be logically distinct from whether enforcement is happening >> (for example, the pinning happens when the LSM is enabled, but the pin >> is only checked when "enforce" is set). This allows LoadPin to continue > > ISTB: when "enforcing" is set). ?? Whoops, thanks. And I need to do s/enable/enabled/ in the log. I'll fix this up. -Kees > >> to operate sanely in test environments once LSM enable/disable is >> centrally handled (i.e. we want LoadPin to be enabled separately from >> its enforcement). >> >> Signed-off-by: Kees Cook >> Reviewed-by: Casey Schaufler >> Reviewed-by: John Johansen >> --- >> security/loadpin/Kconfig | 4 ++-- >> security/loadpin/loadpin.c | 21 +++++++++++---------- >> 2 files changed, 13 insertions(+), 12 deletions(-) >> >> diff --git a/security/loadpin/Kconfig b/security/loadpin/Kconfig >> index dd01aa91e521..8653608a3693 100644 >> --- a/security/loadpin/Kconfig >> +++ b/security/loadpin/Kconfig >> @@ -10,10 +10,10 @@ config SECURITY_LOADPIN >> have a root filesystem backed by a read-only device such as >> dm-verity or a CDROM. >> >> -config SECURITY_LOADPIN_ENABLED >> +config SECURITY_LOADPIN_ENFORCING >> bool "Enforce LoadPin at boot" >> depends on SECURITY_LOADPIN >> help >> If selected, LoadPin will enforce pinning at boot. If not >> selected, it can be enabled at boot with the kernel parameter >> - "loadpin.enabled=1". >> + "loadpin.enforcing=1". >> diff --git a/security/loadpin/loadpin.c b/security/loadpin/loadpin.c >> index 0716af28808a..d8a68a6f6fef 100644 >> --- a/security/loadpin/loadpin.c >> +++ b/security/loadpin/loadpin.c >> @@ -44,7 +44,7 @@ static void report_load(const char *origin, struct file *file, char *operation) >> kfree(pathname); >> } >> >> -static int enabled = IS_ENABLED(CONFIG_SECURITY_LOADPIN_ENABLED); >> +static int enforcing = IS_ENABLED(CONFIG_SECURITY_LOADPIN_ENFORCING); >> static struct super_block *pinned_root; >> static DEFINE_SPINLOCK(pinned_root_spinlock); >> >> @@ -60,8 +60,8 @@ static struct ctl_path loadpin_sysctl_path[] = { >> >> static struct ctl_table loadpin_sysctl_table[] = { >> { >> - .procname = "enabled", >> - .data = &enabled, >> + .procname = "enforcing", >> + .data = &enforcing, >> .maxlen = sizeof(int), >> .mode = 0644, >> .proc_handler = proc_dointvec_minmax, >> @@ -97,7 +97,7 @@ static void check_pinning_enforcement(struct super_block *mnt_sb) >> loadpin_sysctl_table)) >> pr_notice("sysctl registration failed!\n"); >> else >> - pr_info("load pinning can be disabled.\n"); >> + pr_info("enforcement can be disabled.\n"); >> } else >> pr_info("load pinning engaged.\n"); >> } >> @@ -128,7 +128,7 @@ static int loadpin_read_file(struct file *file, enum kernel_read_file_id id) >> >> /* This handles the older init_module API that has a NULL file. */ >> if (!file) { >> - if (!enabled) { >> + if (!enforcing) { >> report_load(origin, NULL, "old-api-pinning-ignored"); >> return 0; >> } >> @@ -151,7 +151,7 @@ static int loadpin_read_file(struct file *file, enum kernel_read_file_id id) >> * Unlock now since it's only pinned_root we care about. >> * In the worst case, we will (correctly) report pinning >> * failures before we have announced that pinning is >> - * enabled. This would be purely cosmetic. >> + * enforcing. This would be purely cosmetic. >> */ >> spin_unlock(&pinned_root_spinlock); >> check_pinning_enforcement(pinned_root); >> @@ -161,7 +161,7 @@ static int loadpin_read_file(struct file *file, enum kernel_read_file_id id) >> } >> >> if (IS_ERR_OR_NULL(pinned_root) || load_root != pinned_root) { >> - if (unlikely(!enabled)) { >> + if (unlikely(!enforcing)) { >> report_load(origin, file, "pinning-ignored"); >> return 0; >> } >> @@ -186,10 +186,11 @@ static struct security_hook_list loadpin_hooks[] __lsm_ro_after_init = { >> >> void __init loadpin_add_hooks(void) >> { >> - pr_info("ready to pin (currently %sabled)", enabled ? "en" : "dis"); >> + pr_info("ready to pin (currently %senforcing)\n", >> + enforcing ? "" : "not "); >> security_add_hooks(loadpin_hooks, ARRAY_SIZE(loadpin_hooks), "loadpin"); >> } >> >> /* Should not be mutable after boot, so not listed in sysfs (perm == 0). */ >> -module_param(enabled, int, 0); >> -MODULE_PARM_DESC(enabled, "Pin module/firmware loading (default: true)"); >> +module_param(enforcing, int, 0); >> +MODULE_PARM_DESC(enforcing, "Enforce module/firmware pinning"); >> > > > -- > ~Randy -- Kees Cook Pixel Security