From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755490AbcC1Vij (ORCPT ); Mon, 28 Mar 2016 17:38:39 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57435 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751537AbcC1Vif (ORCPT ); Mon, 28 Mar 2016 17:38:35 -0400 Date: Mon, 28 Mar 2016 14:38:33 -0700 From: Andrew Morton To: Kees Cook Cc: James Morris , "Serge E. Hallyn" , Kalle Valo , Mauro Carvalho Chehab , Joe Perches , Guenter Roeck , Jiri Slaby , Paul Moore , Stephen Smalley , Mimi Zohar , Casey Schaufler , Andreas Gruenbacher , Andy Shevchenko , Rasmus Villemoes , Ulf Hansson , Vitaly Kuznetsov , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 5/5] LSM: LoadPin for kernel file loading restrictions Message-Id: <20160328143833.911097dc39990ebe7a40b23d@linux-foundation.org> In-Reply-To: <1459199662-16558-6-git-send-email-keescook@chromium.org> References: <1459199662-16558-1-git-send-email-keescook@chromium.org> <1459199662-16558-6-git-send-email-keescook@chromium.org> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 28 Mar 2016 14:14:22 -0700 Kees Cook wrote: > This LSM enforces that kernel-loaded files (modules, firmware, etc) > must all come from the same filesystem, with the expectation that > such a filesystem is backed by a read-only device such as dm-verity > or CDROM. This allows systems that have a verified and/or unchangeable > filesystem to enforce module and firmware loading restrictions without > needing to sign the files individually. Patchset generally looks good to me. It's regrettable that a load of stuff was added to lib/ for one obscure LSM but hopefully (doubtfully) someone else will find a use for some of it. I'll assume that James is handling all of this. > --- /dev/null > +++ b/security/loadpin/loadpin.c > @@ -0,0 +1,206 @@ > +/* > + * Module and Firmware Pinning Security Module > + * > + * Copyright 2011-2016 Google Inc. > + * > + * Author: Kees Cook > + * > + * This software is licensed under the terms of the GNU General Public > + * License version 2, as published by the Free Software Foundation, and > + * may be copied, distributed, and modified under those terms. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + */ > + > +#define pr_fmt(fmt) "LoadPin: " fmt > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include /* current */ > +#include > + > +static void report_load(const char *origin, struct file *file, char *operation) > +{ > + char *cmdline, *pathname; > + > + pathname = kstrdup_quotable_file(file); > + cmdline = kstrdup_quotable_cmdline(current); > + > + pr_notice("%s %s obj=%s%s%s pid=%d cmdline=%s%s%s\n", > + origin, operation, > + (pathname && pathname[0] != '<') ? "\"" : "", > + pathname, > + (pathname && pathname[0] != '<') ? "\"" : "", > + task_pid_nr(current), > + cmdline ? "\"" : "", cmdline, cmdline ? "\"" : ""); > + > + kfree(cmdline); > + kfree(pathname); > +} > + > +static int load_pinning = 1; > +static struct super_block *pinned_root; > +static DEFINE_SPINLOCK(pinned_root_spinlock); > + > +#ifdef CONFIG_SYSCTL > +static int zero; > +static int one = 1; > + > +static struct ctl_path loadpin_sysctl_path[] = { > + { .procname = "kernel", }, > + { } > +}; > + > +static struct ctl_table loadpin_sysctl_table[] = { > + { > + .procname = "load_pinning", > + .data = &load_pinning, > + .maxlen = sizeof(int), > + .mode = 0644, > + .proc_handler = proc_dointvec_minmax, > + .extra1 = &zero, > + .extra2 = &one, > + }, > + { } > +}; There should be somewhere to document the new sysctl?