All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Mimi Zohar <zohar@linux.ibm.com>,
	James Bottomley <James.Bottomley@hansenpartnership.com>,
	Nayna Jain <nayna@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org, linux-fsdevel@vger.kernel.org,
	linux-efi@vger.kernel.org,
	linux-security-module <linux-security-module@vger.kernel.org>,
	linux-kernel@vger.kernel.org,
	Michael Ellerman <mpe@ellerman.id.au>,
	Dov Murik <dovmurik@linux.ibm.com>,
	George Wilson <gcwilson@linux.ibm.com>,
	gjoyce@ibm.com, Matthew Garrett <mjg59@srcf.ucam.org>,
	Dave Hansen <dave.hansen@intel.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>
Subject: Re: [RFC PATCH v2 2/3] fs: define a firmware security filesystem named fwsecurityfs
Date: Tue, 28 Jun 2022 15:25:52 +0200	[thread overview]
Message-ID: <20220628132552.ryjlz2dou52sghhr@wittgenstein> (raw)
In-Reply-To: <YrleOHmEbpLPZ1n8@kroah.com>

On Mon, Jun 27, 2022 at 09:37:28AM +0200, Greg Kroah-Hartman wrote:
> On Sun, Jun 26, 2022 at 11:48:06AM -0400, Mimi Zohar wrote:
> > On Thu, 2022-06-23 at 09:23 -0400, James Bottomley wrote:
> > > On Thu, 2022-06-23 at 10:54 +0200, Greg Kroah-Hartman wrote:
> > > [...]
> > > > > diff --git a/fs/fwsecurityfs/inode.c b/fs/fwsecurityfs/inode.c
> > > > > new file mode 100644
> > > > > index 000000000000..5d06dc0de059
> > > > > --- /dev/null
> > > > > +++ b/fs/fwsecurityfs/inode.c
> > > > > @@ -0,0 +1,159 @@
> > > > > +// SPDX-License-Identifier: GPL-2.0-only
> > > > > +/*
> > > > > + * Copyright (C) 2022 IBM Corporation
> > > > > + * Author: Nayna Jain <nayna@linux.ibm.com>
> > > > > + */
> > > > > +
> > > > > +#include <linux/sysfs.h>
> > > > > +#include <linux/kobject.h>
> > > > > +#include <linux/fs.h>
> > > > > +#include <linux/fs_context.h>
> > > > > +#include <linux/mount.h>
> > > > > +#include <linux/pagemap.h>
> > > > > +#include <linux/init.h>
> > > > > +#include <linux/namei.h>
> > > > > +#include <linux/security.h>
> > > > > +#include <linux/lsm_hooks.h>
> > > > > +#include <linux/magic.h>
> > > > > +#include <linux/ctype.h>
> > > > > +#include <linux/fwsecurityfs.h>
> > > > > +
> > > > > +#include "internal.h"
> > > > > +
> > > > > +int fwsecurityfs_remove_file(struct dentry *dentry)
> > > > > +{
> > > > > +	drop_nlink(d_inode(dentry));
> > > > > +	dput(dentry);
> > > > > +	return 0;
> > > > > +};
> > > > > +EXPORT_SYMBOL_GPL(fwsecurityfs_remove_file);
> > > > > +
> > > > > +int fwsecurityfs_create_file(const char *name, umode_t mode,
> > > > > +					u16 filesize, struct dentry
> > > > > *parent,
> > > > > +					struct dentry *dentry,
> > > > > +					const struct file_operations
> > > > > *fops)
> > > > > +{
> > > > > +	struct inode *inode;
> > > > > +	int error;
> > > > > +	struct inode *dir;
> > > > > +
> > > > > +	if (!parent)
> > > > > +		return -EINVAL;
> > > > > +
> > > > > +	dir = d_inode(parent);
> > > > > +	pr_debug("securityfs: creating file '%s'\n", name);
> > > > 
> > > > Did you forget to call simple_pin_fs() here or anywhere else?
> > > > 
> > > > And this can be just one function with the directory creation file,
> > > > just check the mode and you will be fine.  Look at securityfs as an
> > > > example of how to make this simpler.
> > > 
> > > Actually, before you go down this route can you consider the namespace
> > > ramifications.  In fact we're just having to rework securityfs to pull
> > > out all the simple_pin_... calls because simple_pin_... is completely
> > > inimical to namespaces.

I described this at length in the securityfs namespacing thread at
various points. simple_pin_*() should be avoided if possible. Ideally
the filesystem will just be cleaned up on umount. There might be a
reason to make it survive umounts if you have state that stays around
and somehow is intimately tied to that filesystem.

> > > 
> > > The first thing to consider is if you simply use securityfs you'll
> > > inherit all the simple_pin_... removal work and be namespace ready.  It
> > > could be that creating a new filesystem that can't be namespaced is the
> > > right thing to do here, but at least ask the question: would we ever
> > > want any of these files to be presented selectively inside containers? 
> > > If the answer is "yes" then simple_pin_... is the wrong interface.
> > 
> > Greg, the securityfs changes James is referring to are part of the IMA
> > namespacing patch set:
> > https://lore.kernel.org/linux-integrity/20220420140633.753772-1-stefanb@linux.ibm.com/
> > 
> > I'd really appreciate your reviewing the first two patches:
> > [PATCH v12 01/26] securityfs: rework dentry creation
> > [PATCH v12 02/26] securityfs: Extend securityfs with namespacing
> > support
> 
> Looks like others have already reviewed them, they seem sane to me if
> they past testing.

Thanks for taking a look.

WARNING: multiple messages have this Message-ID (diff)
From: Christian Brauner <brauner@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Dov Murik <dovmurik@linux.ibm.com>,
	linux-efi@vger.kernel.org, Matthew Garrett <mjg59@srcf.ucam.org>,
	Nayna Jain <nayna@linux.ibm.com>,
	linux-kernel@vger.kernel.org, Mimi Zohar <zohar@linux.ibm.com>,
	James Bottomley <James.Bottomley@hansenpartnership.com>,
	Dave Hansen <dave.hansen@intel.com>,
	linux-security-module <linux-security-module@vger.kernel.org>,
	Paul Mackerras <paulus@samba.org>,
	linux-fsdevel@vger.kernel.org,
	George Wilson <gcwilson@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org, gjoyce@ibm.com
Subject: Re: [RFC PATCH v2 2/3] fs: define a firmware security filesystem named fwsecurityfs
Date: Tue, 28 Jun 2022 15:25:52 +0200	[thread overview]
Message-ID: <20220628132552.ryjlz2dou52sghhr@wittgenstein> (raw)
In-Reply-To: <YrleOHmEbpLPZ1n8@kroah.com>

On Mon, Jun 27, 2022 at 09:37:28AM +0200, Greg Kroah-Hartman wrote:
> On Sun, Jun 26, 2022 at 11:48:06AM -0400, Mimi Zohar wrote:
> > On Thu, 2022-06-23 at 09:23 -0400, James Bottomley wrote:
> > > On Thu, 2022-06-23 at 10:54 +0200, Greg Kroah-Hartman wrote:
> > > [...]
> > > > > diff --git a/fs/fwsecurityfs/inode.c b/fs/fwsecurityfs/inode.c
> > > > > new file mode 100644
> > > > > index 000000000000..5d06dc0de059
> > > > > --- /dev/null
> > > > > +++ b/fs/fwsecurityfs/inode.c
> > > > > @@ -0,0 +1,159 @@
> > > > > +// SPDX-License-Identifier: GPL-2.0-only
> > > > > +/*
> > > > > + * Copyright (C) 2022 IBM Corporation
> > > > > + * Author: Nayna Jain <nayna@linux.ibm.com>
> > > > > + */
> > > > > +
> > > > > +#include <linux/sysfs.h>
> > > > > +#include <linux/kobject.h>
> > > > > +#include <linux/fs.h>
> > > > > +#include <linux/fs_context.h>
> > > > > +#include <linux/mount.h>
> > > > > +#include <linux/pagemap.h>
> > > > > +#include <linux/init.h>
> > > > > +#include <linux/namei.h>
> > > > > +#include <linux/security.h>
> > > > > +#include <linux/lsm_hooks.h>
> > > > > +#include <linux/magic.h>
> > > > > +#include <linux/ctype.h>
> > > > > +#include <linux/fwsecurityfs.h>
> > > > > +
> > > > > +#include "internal.h"
> > > > > +
> > > > > +int fwsecurityfs_remove_file(struct dentry *dentry)
> > > > > +{
> > > > > +	drop_nlink(d_inode(dentry));
> > > > > +	dput(dentry);
> > > > > +	return 0;
> > > > > +};
> > > > > +EXPORT_SYMBOL_GPL(fwsecurityfs_remove_file);
> > > > > +
> > > > > +int fwsecurityfs_create_file(const char *name, umode_t mode,
> > > > > +					u16 filesize, struct dentry
> > > > > *parent,
> > > > > +					struct dentry *dentry,
> > > > > +					const struct file_operations
> > > > > *fops)
> > > > > +{
> > > > > +	struct inode *inode;
> > > > > +	int error;
> > > > > +	struct inode *dir;
> > > > > +
> > > > > +	if (!parent)
> > > > > +		return -EINVAL;
> > > > > +
> > > > > +	dir = d_inode(parent);
> > > > > +	pr_debug("securityfs: creating file '%s'\n", name);
> > > > 
> > > > Did you forget to call simple_pin_fs() here or anywhere else?
> > > > 
> > > > And this can be just one function with the directory creation file,
> > > > just check the mode and you will be fine.  Look at securityfs as an
> > > > example of how to make this simpler.
> > > 
> > > Actually, before you go down this route can you consider the namespace
> > > ramifications.  In fact we're just having to rework securityfs to pull
> > > out all the simple_pin_... calls because simple_pin_... is completely
> > > inimical to namespaces.

I described this at length in the securityfs namespacing thread at
various points. simple_pin_*() should be avoided if possible. Ideally
the filesystem will just be cleaned up on umount. There might be a
reason to make it survive umounts if you have state that stays around
and somehow is intimately tied to that filesystem.

> > > 
> > > The first thing to consider is if you simply use securityfs you'll
> > > inherit all the simple_pin_... removal work and be namespace ready.  It
> > > could be that creating a new filesystem that can't be namespaced is the
> > > right thing to do here, but at least ask the question: would we ever
> > > want any of these files to be presented selectively inside containers? 
> > > If the answer is "yes" then simple_pin_... is the wrong interface.
> > 
> > Greg, the securityfs changes James is referring to are part of the IMA
> > namespacing patch set:
> > https://lore.kernel.org/linux-integrity/20220420140633.753772-1-stefanb@linux.ibm.com/
> > 
> > I'd really appreciate your reviewing the first two patches:
> > [PATCH v12 01/26] securityfs: rework dentry creation
> > [PATCH v12 02/26] securityfs: Extend securityfs with namespacing
> > support
> 
> Looks like others have already reviewed them, they seem sane to me if
> they past testing.

Thanks for taking a look.

  reply	other threads:[~2022-06-28 13:28 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-22 21:56 [RFC PATCH v2 0/3] powerpc/pseries: add support for local secure storage called Platform KeyStore(PKS) Nayna Jain
2022-06-22 21:56 ` Nayna Jain
2022-06-22 21:56 ` [RFC PATCH v2 1/3] powerpc/pseries: define driver for Platform KeyStore Nayna Jain
2022-06-22 21:56   ` Nayna Jain
2022-06-22 21:56 ` [RFC PATCH v2 2/3] fs: define a firmware security filesystem named fwsecurityfs Nayna Jain
2022-06-22 21:56   ` Nayna Jain
2022-06-22 22:29   ` Casey Schaufler
2022-06-22 22:29     ` Casey Schaufler
2022-06-23  1:50     ` Nayna
2022-06-23  1:50       ` Nayna
2022-06-23  8:54   ` Greg Kroah-Hartman
2022-06-23  8:54     ` Greg Kroah-Hartman
2022-06-23 13:23     ` James Bottomley
2022-06-23 13:23       ` James Bottomley
2022-06-26 15:48       ` Mimi Zohar
2022-06-26 15:48         ` Mimi Zohar
2022-06-27  7:37         ` Greg Kroah-Hartman
2022-06-27  7:37           ` Greg Kroah-Hartman
2022-06-28 13:25           ` Christian Brauner [this message]
2022-06-28 13:25             ` Christian Brauner
2022-06-23 22:18   ` kernel test robot
2022-06-22 21:56 ` [RFC PATCH v2 3/3] powerpc/pseries: expose authenticated variables stored in LPAR PKS Nayna Jain
2022-06-22 21:56   ` Nayna Jain
2022-06-23  2:36   ` Randy Dunlap
2022-06-23  2:36     ` Randy Dunlap
2022-06-27 21:10 ` [RFC PATCH v2 0/3] powerpc/pseries: add support for local secure storage called Platform KeyStore(PKS) Dave Hansen
2022-06-27 21:10   ` Dave Hansen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220628132552.ryjlz2dou52sghhr@wittgenstein \
    --to=brauner@kernel.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=benh@kernel.crashing.org \
    --cc=dave.hansen@intel.com \
    --cc=dovmurik@linux.ibm.com \
    --cc=gcwilson@linux.ibm.com \
    --cc=gjoyce@ibm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=mpe@ellerman.id.au \
    --cc=nayna@linux.ibm.com \
    --cc=paulus@samba.org \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.