All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [RFC 00/11] Inode security label invalidation
Date: Mon, 24 Aug 2015 13:42:34 -0400	[thread overview]
Message-ID: <55DB578A.3080108@tycho.nsa.gov> (raw)
In-Reply-To: <1440094798-1411-1-git-send-email-agruenba@redhat.com>

On 08/20/2015 02:19 PM, Andreas Gruenbacher wrote:
> Hello,
> 
> this patch queue adds an LSM hook for file systems to invalidate inode security
> labels.  To allow selinux to revalidate invalid labels, the generic xattr
> handlers are cleaned up a bit and a new igetxattr inode operation is
> introduced: the getxattr inode operation requires a dentry which selinux
> doesn't have in inode_has_perm(); igetxattr instead takes an inode.  Finally,
> gfs2 is patched to make use of this new mechanism.
> 
> The new igetxattr inode operation currently is *only* used for revalidating
> security labels in selinux; it may make sense to use it instead of getxattr
> when defined.
> 
> Is this approach useful?  An alternative would be to modify selinux so that it
> always has a dentry when checking inode security labels; I would guess that
> this won't work in all cases, though.
> 
> 
> BACKGROUND
> 
> Selinux currently assumes that, after initialization, inode->i_security always
> represents the current security label of the inode.  This assumption works for
> local file systems; any change of the label must go through setxattr (or
> removexattr) which updates inode->i_security.
> 
> On an nfs mount, other nodes can change the security label; there is no
> immediate notification mechanism.  Other nodes will eventually notice a label
> change because the label is transmitted as part of the reply of operations like
> open. (A timeout for cached labels would help too; I'm not sure if the code
> implements that.)
> 
> Other file systems have different consistency models. For example, gfs2 inodes
> go "invalid" when a node drops the inode's glocks. When such an invalid inode
> is accessed again, all the metadata must be read from disk again, including the
> security label.
> 
> For that case, the file system has no way of updating the security label before
> selinux next uses it.  Things also don't fix themselves over time; when selinux
> rejects access, the file system never notices.

The current NFSv4 model is to call security_inode_notifysecctx() to
notify the security module of the new label.  Does that not work for
gfs2 or others?  It is up to the filesystem client side code to actually
detect the change and fetch the new value, then push it to the security
module via the security_inode_notifysecctx() hook.

> 
> To fix that, this patch queue adds a mechanism for file systems to invalidate
> inode security labels, and for selinux to revalidate them; this is similar to
> how the inode acl cache works.



WARNING: multiple messages have this Message-ID (diff)
From: Stephen Smalley <sds@tycho.nsa.gov>
To: Andreas Gruenbacher <andreas.gruenbacher@gmail.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christoph Hellwig <hch@infradead.org>,
	Eric Paris <eparis@redhat.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
	linux-fsdevel@vger.kernel.org,
	David Quigley <dpquigl@davequigley.com>,
	"J. Bruce Fields" <bfields@fieldses.org>
Cc: linux-security-module@vger.kernel.org, cluster-devel@redhat.com
Subject: Re: [RFC 00/11] Inode security label invalidation
Date: Mon, 24 Aug 2015 13:42:34 -0400	[thread overview]
Message-ID: <55DB578A.3080108@tycho.nsa.gov> (raw)
In-Reply-To: <1440094798-1411-1-git-send-email-agruenba@redhat.com>

On 08/20/2015 02:19 PM, Andreas Gruenbacher wrote:
> Hello,
> 
> this patch queue adds an LSM hook for file systems to invalidate inode security
> labels.  To allow selinux to revalidate invalid labels, the generic xattr
> handlers are cleaned up a bit and a new igetxattr inode operation is
> introduced: the getxattr inode operation requires a dentry which selinux
> doesn't have in inode_has_perm(); igetxattr instead takes an inode.  Finally,
> gfs2 is patched to make use of this new mechanism.
> 
> The new igetxattr inode operation currently is *only* used for revalidating
> security labels in selinux; it may make sense to use it instead of getxattr
> when defined.
> 
> Is this approach useful?  An alternative would be to modify selinux so that it
> always has a dentry when checking inode security labels; I would guess that
> this won't work in all cases, though.
> 
> 
> BACKGROUND
> 
> Selinux currently assumes that, after initialization, inode->i_security always
> represents the current security label of the inode.  This assumption works for
> local file systems; any change of the label must go through setxattr (or
> removexattr) which updates inode->i_security.
> 
> On an nfs mount, other nodes can change the security label; there is no
> immediate notification mechanism.  Other nodes will eventually notice a label
> change because the label is transmitted as part of the reply of operations like
> open. (A timeout for cached labels would help too; I'm not sure if the code
> implements that.)
> 
> Other file systems have different consistency models. For example, gfs2 inodes
> go "invalid" when a node drops the inode's glocks. When such an invalid inode
> is accessed again, all the metadata must be read from disk again, including the
> security label.
> 
> For that case, the file system has no way of updating the security label before
> selinux next uses it.  Things also don't fix themselves over time; when selinux
> rejects access, the file system never notices.

The current NFSv4 model is to call security_inode_notifysecctx() to
notify the security module of the new label.  Does that not work for
gfs2 or others?  It is up to the filesystem client side code to actually
detect the change and fetch the new value, then push it to the security
module via the security_inode_notifysecctx() hook.

> 
> To fix that, this patch queue adds a mechanism for file systems to invalidate
> inode security labels, and for selinux to revalidate them; this is similar to
> how the inode acl cache works.


  parent reply	other threads:[~2015-08-24 17:42 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-20 18:19 [Cluster-devel] [RFC 00/11] Inode security label invalidation Andreas Gruenbacher
2015-08-20 18:19 ` Andreas Gruenbacher
2015-08-20 18:19 ` [Cluster-devel] [RFC 01/11] ubifs: Remove unused "security.*" xattr handler Andreas Gruenbacher
2015-08-20 18:19   ` Andreas Gruenbacher
2015-08-20 18:19 ` [Cluster-devel] [RFC 02/11] hfsplus: Remove unused xattr handler list operations Andreas Gruenbacher
2015-08-20 18:19   ` Andreas Gruenbacher
2015-08-20 18:19 ` [Cluster-devel] [RFC 03/11] 9p: Simplify the xattr handlers Andreas Gruenbacher
2015-08-20 18:19   ` Andreas Gruenbacher
2015-08-20 18:19 ` [Cluster-devel] [RFC 04/11] xattr handlers: Pass handler to operations instead of flags Andreas Gruenbacher
2015-08-20 18:19   ` Andreas Gruenbacher
2015-08-20 18:19 ` [Cluster-devel] [RFC 05/11] xattr handlers: Some simplifications Andreas Gruenbacher
2015-08-20 18:19   ` Andreas Gruenbacher
2015-08-20 18:19 ` [Cluster-devel] [RFC 06/11] lib: Move strcmp_prefix into string.c Andreas Gruenbacher
2015-08-20 18:19   ` Andreas Gruenbacher
2015-08-20 18:19 ` [Cluster-devel] [RFC 07/11] 9p: Stop using the generic xattr_handler infrastructure Andreas Gruenbacher
2015-08-20 18:19   ` Andreas Gruenbacher
2015-08-21  6:46   ` [Cluster-devel] " Christoph Hellwig
2015-08-21  6:46     ` Christoph Hellwig
2015-08-21  8:35     ` [Cluster-devel] " Steven Whitehouse
2015-08-21  8:35       ` Steven Whitehouse
2015-08-20 18:19 ` [Cluster-devel] [RFC 08/11] xattr: Pass inodes to xattr handlers instead of dentries Andreas Gruenbacher
2015-08-20 18:19   ` Andreas Gruenbacher
2015-08-20 18:19 ` [Cluster-devel] [RFC 09/11] vfs: Add igetxattr inode operation Andreas Gruenbacher
2015-08-20 18:19   ` Andreas Gruenbacher
2015-08-21  6:48   ` [Cluster-devel] " Christoph Hellwig
2015-08-21  6:48     ` Christoph Hellwig
2015-08-20 18:19 ` [Cluster-devel] [RFC 10/11] selinux: Allow to invalidate an inode's security label Andreas Gruenbacher
2015-08-20 18:19   ` Andreas Gruenbacher
2015-08-20 18:19 ` [Cluster-devel] [RFC 11/11] gfs2: Invalide security labels of inodes that go invalid Andreas Gruenbacher
2015-08-20 18:19   ` Andreas Gruenbacher
2015-08-21  6:49   ` [Cluster-devel] " Christoph Hellwig
2015-08-21  6:49     ` Christoph Hellwig
2015-08-21  9:25     ` [Cluster-devel] " Andreas Gruenbacher
2015-08-21  9:25       ` Andreas Gruenbacher
2015-08-24 17:42 ` Stephen Smalley [this message]
2015-08-24 17:42   ` [RFC 00/11] Inode security label invalidation Stephen Smalley
2015-08-24 19:13   ` [Cluster-devel] " Andreas Grünbacher
2015-08-24 19:13     ` Andreas Grünbacher
2015-08-24 20:47   ` [Cluster-devel] " Eric Paris
2015-08-24 20:47     ` Eric Paris

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=55DB578A.3080108@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    /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.