linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serue@us.ibm.com>
To: Andreas Gruenbacher <agruen@suse.de>
Cc: Stephen Smalley <sds@tycho.nsa.gov>, Pavel Machek <pavel@ucw.cz>,
	jjohansen@suse.de, linux-kernel@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [AppArmor 38/45] AppArmor: Module and LSM hooks
Date: Mon, 11 Jun 2007 14:02:22 -0500	[thread overview]
Message-ID: <20070611190222.GB18276@sergelap.austin.ibm.com> (raw)
In-Reply-To: <200706111755.33162.agruen@suse.de>

Quoting Andreas Gruenbacher (agruen@suse.de):
> On Monday 11 June 2007 16:33, Stephen Smalley wrote:
> > On Mon, 2007-06-11 at 01:10 +0200, Andreas Gruenbacher wrote:
> > > On Wednesday 06 June 2007 15:09, Stephen Smalley wrote:
> > > > On Mon, 2007-06-04 at 16:30 +0200, Andreas Gruenbacher wrote:
> > > > > On Monday 04 June 2007 15:12, Pavel Machek wrote:
> > > > > > How will kernel work with very long paths? I'd suspect some
> > > > > > problems, if path is 1MB long and I attempt to print it in /proc
> > > > > > somewhere.
> > > > >
> > > > > Pathnames are only used for informational purposes in the kernel,
> > > > > except in AppArmor of course.
> > > >
> > > > I don't mean this as a flame, but isn't the above statement the very
> > > > crux of this discussion?
> > >
> > > I think the question at the core of it all is, shall a pathname based
> > > security mechanism be allowed. I was under the impression that this
> > > question had already been answered affirmatively. If the answer here was

That was the decision at ksummit last year, yes.

> > > no, then we could stop the entire discussion right there.
> >
> > There is a difference between using the pathname at the kernel/userland
> > interface as part of configuring a security mechanism and using it as
> > the basis for the runtime checking itself.
> 
> Yes, there is a difference. When I say pathname based security mechanism, I 
> literally mean a pathname based security mechanism, meaning the pathnames 
> determine the outcome o the decision. This includes designs that are based on 
> different abstractions internally, but the bahavior observable from 
> user-space must be the same (or else, it's a different model).
> 
> Unfortunately, translating pathnames to labels destroys this fundamental 
> abstraction. We explained why this is so in the following postings:
> 
> 	http://lkml.org/lkml/2007/6/9/94
> 	http://lkml.org/lkml/2007/6/10/141
> 
> > Further, there is a difference between generating and matching full
> > pathnames on each access vs. caching information in the parent dentry and
> > making decisions based on that cached information and the last
> > component-name.
> 
> Wait, you are mixing two issues here: access checks on existing files, and the 
> creation of new files. For AppArmor as it stands today the two are the same, 
> but when looking at emulating AppArmor using labels, they are not. Let's look 
> at things one at a time.
> 
> Generating and matching full pathnames on each access takes time, no question 
> about that. (In fact we are not checking on each access but only when 
> pathnames are involved, such as on open. Filehandle based operations do not 
> require access checks, but that's not a very important difference at this 
> level of discussion.) That's a quantitative statement though, not a 
> qualitative one: retrieving xattrs and checking labels also takes time; 
> additional checks are never for free. We find that doing the pathname checks 
> is easily fast enough. You may disagree, but then you don't have to use 
> AppArmor, and we are not standing in your way.
> 
> As far as new files are concerned, basing decisions on the parent dentry and 
> component name requires that you know where in the filesystem hierarchy this 
> dentry is located: with bind mounts, the same dentry shows up in multiple 
> locations in a process's namespace, corresponding to different pathnames. In 
> other words, to make the right decision, the dentry alone is not enough; it 
> takes a <dentry, vfsmount> pair. So there we are again.
> 
> >From the point on where you have a <dentry, vfsmount> pair of objects, you can 
> do two things: you can compute the full pathname and base your decision on 
> that, or you can do some caching to hopefully cut some of that work short 
> frequently enough to set off the additional cost. The difference between the 
> two approaches is quantitative -- if there is a difference in results, then 
> that's obviously a bug. I believe that caching could speed up things 
> measurably, but up to this point, neither I nor anybody else had the time to 
> look into it, and so we are not doing it -- not yet, any perhaps never at 
> all. It may be counter to your intuition, but doing those checks is not a big 
> issue.

My approach in DTE, which used pathnames to assign TE labels in the
kernel, was to use a 'shadow tree' to the vfsmnt+dentry tree, filled out
at policy load time to the depth of the deepest policy rule.  For the
behavior I was after, bind mounts were handled by storing pointers from
the new mount to the original, but the behavior AA wants would be
different.  Namespace clones are easily handled this way by copying the
cached pointers to the shadow tree.  And it was pretty fast.

When I talked about this with Tony last year, the biggest shortcoming to
use this for AA was the wildcards.  For instance, if there is a rule for
/var/log/HOSTS/*/messages, then when /var/log/HOSTS/sergelap/ is
created, a new rule would have to be created on the fly to tag
/var/log/HOSTS/sergelap/messages if it is created.  How to represent
that when only /var/log or /var/log/HOSTS exists at policy load time
would be, well, a fun problem to solve actually  :)

-serge

> > The only question I saw being answered was the abstract one of "can a
> > pathname play a role in the security mechanism" not "should the kernel be
> > regenerating a full path on each open and glob matching it against a
> > list of file globs."
> 
> No glob matching involved, and no list of patterns. There is a single DFA per 
> profile (and each process is in at most one profile at any one time), and 
> each access check involves exactly one DFA traversal.
> 
> [cut here for lack of time right now -- will take another look later]
> 
> > > Without the vfsmounts propagated down you won't know the pathnames.
> > > Whether or not a different problem can be solved without the vfsmounts is
> > > not really relevant.
> >
> > Well, that presumes that your mechanism has to generate full pathnames
> > on each access check.  But even if so, you could be doing your checking
> > in the higher level code then where you have a vfsmount available.
> 
> The LSM hooks are pretty high-level, meant for being able to plug in different 
> access checks. That's the right level of abstraction. We just need the 
> vfsmounts passed down as well. That's what the bulk of common code patches 
> are there for.
> 
> Andreas
> -
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2007-06-11 19:02 UTC|newest]

Thread overview: 240+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-14 11:06 [AppArmor 00/45] AppArmor security module overview jjohansen
2007-05-14 11:06 ` [AppArmor 01/45] Pass struct vfsmount to the inode_create LSM hook jjohansen
2007-05-14 11:06 ` [AppArmor 02/45] Pass struct path down to remove_suid and children jjohansen
2007-05-14 11:06 ` [AppArmor 03/45] Add a vfsmount parameter to notify_change() jjohansen
2007-05-14 11:06 ` [AppArmor 04/45] Pass struct vfsmount to the inode_setattr LSM hook jjohansen
2007-05-14 11:06 ` [AppArmor 05/45] Add struct vfsmount parameter to vfs_mkdir() jjohansen
2007-05-14 11:06 ` [AppArmor 06/45] Pass struct vfsmount to the inode_mkdir LSM hook jjohansen
2007-05-14 11:06 ` [AppArmor 07/45] Add a struct vfsmount parameter to vfs_mknod() jjohansen
2007-05-14 11:06 ` [AppArmor 08/45] Pass struct vfsmount to the inode_mknod LSM hook jjohansen
2007-05-14 11:06 ` [AppArmor 09/45] Add a struct vfsmount parameter to vfs_symlink() jjohansen
2007-05-14 11:06 ` [AppArmor 10/45] Pass struct vfsmount to the inode_symlink LSM hook jjohansen
2007-05-14 11:06 ` [AppArmor 11/45] Pass struct vfsmount to the inode_readlink " jjohansen
2007-05-14 11:06 ` [AppArmor 12/45] Add struct vfsmount parameters to vfs_link() jjohansen
2007-05-14 11:06 ` [AppArmor 13/45] Pass the struct vfsmounts to the inode_link LSM hook jjohansen
2007-05-14 11:06 ` [AppArmor 14/45] Add a struct vfsmount parameter to vfs_rmdir() jjohansen
2007-05-14 11:06 ` [AppArmor 15/45] Pass struct vfsmount to the inode_rmdir LSM hook jjohansen
2007-05-14 11:06 ` [AppArmor 16/45] Call lsm hook before unhashing dentry in vfs_rmdir() jjohansen
2007-05-14 11:06 ` [AppArmor 17/45] Add a struct vfsmount parameter to vfs_unlink() jjohansen
2007-05-14 11:06 ` [AppArmor 18/45] Pass struct vfsmount to the inode_unlink LSM hook jjohansen
2007-05-14 11:06 ` [AppArmor 19/45] Add struct vfsmount parameters to vfs_rename() jjohansen
2007-05-14 11:06 ` [AppArmor 20/45] Pass struct vfsmount to the inode_rename LSM hook jjohansen
2007-05-14 11:06 ` [AppArmor 21/45] Add a struct vfsmount parameter to vfs_setxattr() jjohansen
2007-05-14 11:06 ` [AppArmor 22/45] Pass struct vfsmount to the inode_setxattr LSM hook jjohansen
2007-05-14 11:06 ` [AppArmor 23/45] Add a struct vfsmount parameter to vfs_getxattr() jjohansen
2007-05-14 11:06 ` [AppArmor 24/45] Pass struct vfsmount to the inode_getxattr LSM hook jjohansen
2007-05-14 11:06 ` [AppArmor 25/45] Add a struct vfsmount parameter to vfs_listxattr() jjohansen
2007-05-14 11:06 ` [AppArmor 26/45] Pass struct vfsmount to the inode_listxattr LSM hook jjohansen
2007-05-14 11:06 ` [AppArmor 27/45] Add a struct vfsmount parameter to vfs_removexattr() jjohansen
2007-05-14 11:06 ` [AppArmor 28/45] Pass struct vfsmount to the inode_removexattr LSM hook jjohansen
2007-05-14 11:06 ` [AppArmor 29/45] Fix __d_path() for lazy unmounts and make it unambiguous jjohansen
2007-05-14 11:06 ` [AppArmor 30/45] Make d_path() consistent across mount operations jjohansen
2007-05-14 11:06 ` [AppArmor 31/45] Add d_namespace_path() to compute namespace relative pathnames jjohansen
2007-05-14 11:06 ` [AppArmor 32/45] Enable LSM hooks to distinguish operations on file descriptors from operations on pathnames jjohansen
2007-05-14 11:06 ` [AppArmor 33/45] Pass struct file down the inode_*xattr security LSM hooks jjohansen
2007-05-14 11:06 ` [AppArmor 34/45] Factor out sysctl pathname code jjohansen
2007-05-14 11:06 ` [AppArmor 35/45] Allow permission functions to tell between parent and leaf checks jjohansen
2007-05-15  9:08   ` Pavel Machek
2007-05-14 11:06 ` [AppArmor 36/45] Export audit subsystem for use by modules jjohansen
2007-05-14 11:06 ` [AppArmor 37/45] AppArmor: Main Part jjohansen
2007-05-15  9:12   ` Pavel Machek
2007-05-14 11:06 ` [AppArmor 38/45] AppArmor: Module and LSM hooks jjohansen
2007-05-15  9:14   ` Pavel Machek
2007-05-23 16:16     ` Andreas Gruenbacher
2007-06-04 10:55       ` Pavel Machek
2007-06-04 11:25         ` Andreas Gruenbacher
2007-06-04 11:35           ` Pavel Machek
2007-06-04 11:42             ` Andreas Gruenbacher
2007-06-04 13:12               ` Pavel Machek
2007-06-04 14:30                 ` Andreas Gruenbacher
2007-06-06 13:09                   ` Stephen Smalley
2007-06-10 23:10                     ` Andreas Gruenbacher
2007-06-11 14:33                       ` Stephen Smalley
2007-06-11 15:55                         ` Andreas Gruenbacher
2007-06-11 19:02                           ` Serge E. Hallyn [this message]
2007-06-12 13:00                             ` Stephen Smalley
2007-06-12 15:34                               ` Serge E. Hallyn
2007-06-12  5:17                                 ` Karl MacMillan
2007-06-12 19:00                                   ` Serge E. Hallyn
2007-06-12 13:13                           ` Stephen Smalley
2007-06-12 23:50                         ` Andreas Gruenbacher
2007-06-09 12:58                   ` Pavel Machek
2007-06-09 13:44                     ` Andreas Gruenbacher
2007-06-12 13:06                       ` Pavel Machek
2007-05-14 11:06 ` [AppArmor 39/45] AppArmor: Profile loading and manipulation, pathname matching jjohansen
2007-05-15  9:20   ` Pavel Machek
2007-06-04 21:03     ` Andreas Gruenbacher
2007-06-06 13:26       ` Stephen Smalley
2007-06-06 17:32         ` Greg KH
2007-06-09 23:47           ` Pavel Machek
2007-06-08 22:03         ` Andreas Gruenbacher
2007-06-09  0:17           ` Greg KH
2007-06-09  1:06             ` david
2007-06-09  2:01               ` [AppArmor 39/45] AppArmor: Profile loading and manipulation,pathname matching Tetsuo Handa
2007-06-09  3:25                 ` Sean
2007-06-09  4:56                   ` david
2007-06-09  5:10                     ` Sean
2007-06-09  5:38                       ` david
2007-06-09  5:44                         ` Sean
2007-06-09  7:04                           ` david
2007-06-09  7:28                             ` Sean
2007-06-09  8:03                               ` david
2007-06-09  8:37                                 ` Sean
2007-06-14 17:01                                 ` Pavel Machek
2007-06-09 11:26                               ` [AppArmor 39/45] AppArmor: Profile loading andmanipulation,pathname matching Tetsuo Handa
2007-06-09 11:35                                 ` Sean
2007-06-09 13:41                                   ` david
2007-06-09 18:37                               ` [AppArmor 39/45] AppArmor: Profile loading and manipulation,pathname matching Casey Schaufler
2007-06-15 13:36                                 ` Pavel Machek
2007-06-10  8:34               ` [AppArmor 39/45] AppArmor: Profile loading and manipulation, pathname matching Pavel Machek
2007-06-10  9:04                 ` david
2007-06-10 20:04                   ` Casey Schaufler
2007-06-10 20:51                     ` Crispin Cowan
2007-06-11  6:45                       ` david
2007-06-11  8:29                         ` Sean
2007-06-11  9:33                           ` david
2007-06-11 11:34                             ` Sean
2007-06-11 11:00                         ` Pavel Machek
2007-06-10 21:05                   ` Pavel Machek
2007-06-11  6:27                     ` david
2007-06-14 19:16                       ` Jack Stone
2007-06-15  0:18                         ` david
2007-06-15 17:01                           ` Greg KH
2007-06-12 17:03                     ` Lars Marowsky-Bree
2007-06-09  5:18             ` david
2007-06-09  5:46               ` Sean
2007-06-09  7:13                 ` david
2007-06-09  7:36                   ` Sean
2007-06-09  8:06                     ` david
2007-06-09  8:10                       ` Sean
2007-06-09 15:17                         ` Andreas Gruenbacher
2007-06-09 16:36                           ` Sean
2007-06-09 15:33                   ` Joshua Brindle
2007-06-09 16:18               ` Kyle Moffett
2007-06-09 16:46                 ` david
2007-06-09 17:06                   ` Kyle Moffett
2007-06-09 17:32                     ` david
2007-06-09 19:50                       ` Kyle Moffett
2007-06-09 20:43                         ` david
2007-06-10 20:54               ` Crispin Cowan
2007-06-10 21:17                 ` Joshua Brindle
2007-06-09 15:05             ` Andreas Gruenbacher
2007-06-10 17:09             ` Crispin Cowan
2007-06-15 16:50               ` Greg KH
2007-06-15 18:01                 ` Casey Schaufler
2007-06-15 18:15                   ` Stephen Smalley
2007-06-15 20:43                     ` Casey Schaufler
2007-06-15 21:14                       ` Greg KH
2007-06-15 21:28                         ` Karl MacMillan
2007-06-15 21:44                           ` Greg KH
2007-06-15 22:24                             ` Karl MacMillan
2007-06-18 13:33                               ` Stephen Smalley
2007-06-21 15:54                                 ` Andreas Gruenbacher
2007-06-15 22:37                         ` Casey Schaufler
2007-06-18 12:47                       ` Stephen Smalley
2007-06-15 20:06                 ` Pavel Machek
2007-06-15 21:11                   ` Greg KH
2007-06-15 21:42                     ` James Morris
2007-06-15 23:50                       ` Greg KH
2007-06-16  1:21                         ` James Morris
2007-06-16  2:57                           ` Casey Schaufler
2007-06-16  3:39                             ` James Morris
2007-06-18  1:51                               ` Casey Schaufler
2007-06-18 11:29                                 ` Joshua Brindle
2007-06-16  4:23                           ` Greg KH
2007-06-15 23:30                     ` Crispin Cowan
2007-06-15 23:49                       ` Greg KH
2007-06-16  0:01                         ` david
2007-06-16  0:20                           ` Pavel Machek
2007-06-22  9:59                             ` Andreas Gruenbacher
2007-06-16  0:31                           ` Greg KH
2007-06-16  8:09                             ` david
2007-06-16 16:24                               ` Greg KH
2007-06-16  1:41                           ` James Morris
2007-06-16  0:18                         ` Seth Arnold
2007-06-16  0:29                           ` Greg KH
2007-06-16  1:46                           ` James Morris
2007-06-16  2:19                           ` James Morris
2007-06-18 18:48                         ` Crispin Cowan
2007-06-21 16:01                         ` Andreas Gruenbacher
2007-06-21 17:59                           ` Pavel Machek
2007-06-16  0:02                       ` Pavel Machek
2007-06-21 16:08                         ` Lars Marowsky-Bree
2007-06-21 18:33                           ` Pavel Machek
2007-06-21 19:24                             ` Lars Marowsky-Bree
2007-06-21 19:42                               ` James Morris
2007-06-21 19:54                                 ` Lars Marowsky-Bree
2007-06-21 20:59                                   ` Stephen Smalley
2007-06-21 21:17                                     ` Lars Marowsky-Bree
2007-06-22  0:16                                       ` Joshua Brindle
2007-06-22  0:19                                         ` Lars Marowsky-Bree
2007-06-22  0:28                                         ` david
2007-06-22  3:45                                           ` Joshua Brindle
2007-06-22  5:07                                             ` david
2007-06-22 10:49                                             ` Lars Marowsky-Bree
2007-06-22 11:19                                       ` Stephen Smalley
2007-06-22 11:34                                         ` Neil Brown
2007-06-22 11:48                                           ` Stephen Smalley
2007-06-22 11:37                                         ` Lars Marowsky-Bree
2007-06-22 12:41                                           ` Stephen Smalley
2007-06-22 12:54                                             ` Lars Marowsky-Bree
2007-06-22 13:22                                               ` Stephen Smalley
2007-06-22 14:49                                                 ` Stephen Smalley
2007-06-22 16:06                                             ` Casey Schaufler
2007-06-22  0:34                                     ` Chris Mason
2007-06-22  1:06                                       ` James Morris
2007-06-22  4:17                                         ` Crispin Cowan
2007-06-22 12:20                                           ` Stephen Smalley
2007-06-24 20:45                                             ` David Wagner
2007-06-22  7:40                                         ` John Johansen
2007-06-22 12:17                                         ` Chris Mason
2007-06-22 13:48                                           ` James Morris
2007-06-22 14:02                                             ` Chris Mason
2007-06-22 14:23                                               ` James Morris
2007-06-22 17:30                                                 ` Chris Mason
2007-06-23  0:11                                                   ` Chris Wright
2007-06-24  0:10                                                     ` Toshiharu Harada
2007-06-24  0:40                                                       ` Toshiharu Harada
2007-06-26 21:01                                                     ` Crispin Cowan
2007-06-24 20:43                                                   ` Pavel Machek
2007-06-22 18:12                                                 ` david
2007-06-25 15:14                                               ` Pavel Machek
2007-06-25 21:02                                                 ` david
2007-06-26  8:50                                                 ` Lars Marowsky-Bree
2007-06-24 21:16                                             ` David Wagner
2007-06-24 21:57                                               ` david
2007-06-28 18:13                                               ` Pavel Machek
2007-06-28 18:19                                               ` Pavel Machek
2007-06-24 21:45                                             ` David Wagner
2007-06-28 18:31                                               ` Pavel Machek
2007-06-24 21:20                                         ` David Wagner
2007-06-22  8:06                                     ` John Johansen
2007-06-22 11:53                                       ` Stephen Smalley
2007-06-22 12:42                                         ` Lars Marowsky-Bree
2007-06-22 12:46                                           ` Stephen Smalley
2007-06-22 18:35                                         ` david
2007-06-24 20:48                                         ` David Wagner
2007-06-24 20:35                                     ` David Wagner
2007-06-21 20:07                               ` Pavel Machek
2007-06-21 20:21                                 ` Lars Marowsky-Bree
2007-06-21 23:25                                   ` John Johansen
2007-06-21 19:30                             ` david
2007-06-21 19:35                               ` Lars Marowsky-Bree
2007-06-21 19:52                               ` Pavel Machek
2007-06-16  0:48                       ` [AppArmor 39/45] AppArmor: Profile loading and manipulation,pathname matching Tetsuo Handa
2007-06-19 15:25                         ` Pavel Machek
2007-06-15 23:33                   ` [AppArmor 39/45] AppArmor: Profile loading and manipulation, pathname matching Seth Arnold
2007-06-15 23:39                     ` Pavel Machek
2007-06-16  0:07                       ` Seth Arnold
2007-06-16 15:44                 ` [AppArmor 39/45] AppArmor: Profile loading and manipulation,pathname matching Tetsuo Handa
2007-06-16 16:26                   ` Greg KH
2007-06-16 16:45                     ` [AppArmor 39/45] AppArmor: Profile loading andmanipulation,pathname matching Tetsuo Handa
2007-06-11 15:16           ` [AppArmor 39/45] AppArmor: Profile loading and manipulation, pathname matching Stephen Smalley
2007-05-14 11:06 ` [AppArmor 40/45] AppArmor: all the rest jjohansen
2007-05-14 11:06 ` [AppArmor 41/45] Add AppArmor LSM to security/Makefile jjohansen
2007-05-14 11:06 ` [AppArmor 42/45] AppArmor: add lock subtyping so lockdep does not report false dependencies jjohansen
2007-05-14 11:06 ` [AppArmor 43/45] Switch to vfs_permission() in do_path_lookup() jjohansen
2007-05-14 11:06 ` [AppArmor 44/45] Switch to vfs_permission() in sys_fchdir() jjohansen
2007-05-14 11:06 ` [AppArmor 45/45] Fix file_permission() jjohansen
2007-05-14 13:50 ` [AppArmor 00/45] AppArmor security module overview John Johansen
2007-10-26  6:40 jjohansen
2007-10-26  6:41 ` [AppArmor 38/45] AppArmor: Module and LSM hooks jjohansen

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=20070611190222.GB18276@sergelap.austin.ibm.com \
    --to=serue@us.ibm.com \
    --cc=agruen@suse.de \
    --cc=jjohansen@suse.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).