Skip to content

AppArmor security module overview

[email protected] linux-fsdevel lkml 1 version NAK

Status from this message: NACK.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest41 patches 109 repliesNAK

Patches in v1

#Subject and filesSizeRepliesApplied
1/41Pass struct vfsmount to the inode_create LSM hookfs/namei.c include/linux/security.h security/dummy.c +1 more+10 -691 replies
2/41Remove redundant check from proc_setattr()fs/proc/base.c+2 -50 replies
3/41Remove redundant check from proc_sys_setattr()fs/proc/proc_sysctl.c+2 -51 reply
4/41Pass struct file down to remove_suid and childrenfs/ntfs/file.c fs/ocfs2/file.c fs/reiserfs/file.c +6 more+24 -240 replies
5/41Add a vfsmount parameter to notify_change()fs/attr.c fs/ecryptfs/inode.c fs/exec.c +11 more+41 -340 replies
6/41Pass struct vfsmount to the inode_setattr LSM hookfs/attr.c include/linux/security.h security/dummy.c +1 more+13 -70 replies
7/41Add struct vfsmount parameter to vfs_mkdir()fs/ecryptfs/inode.c fs/namei.c fs/nfsd/nfs4recover.c +2 more+12 -60 replies
8/41Pass struct vfsmount to the inode_mkdir LSM hookfs/namei.c include/linux/security.h security/dummy.c +1 more+10 -50 replies
9/41Add a struct vfsmount parameter to vfs_mknod()fs/ecryptfs/inode.c fs/namei.c fs/nfsd/vfs.c +2 more+14 -80 replies
10/41Pass struct vfsmount to the inode_mknod LSM hookfs/namei.c include/linux/security.h security/dummy.c +1 more+10 -60 replies
11/41Add a struct vfsmount parameter to vfs_symlink()fs/ecryptfs/inode.c fs/namei.c fs/nfsd/vfs.c +1 more+13 -60 replies
12/41Pass struct vfsmount to the inode_symlink LSM hookfs/namei.c include/linux/security.h security/dummy.c +1 more+10 -60 replies
13/41Pass struct vfsmount to the inode_readlink LSM hookfs/stat.c include/linux/security.h security/dummy.c +1 more+10 -70 replies
14/41Add struct vfsmount parameters to vfs_link()fs/ecryptfs/inode.c fs/namei.c fs/nfsd/vfs.c +1 more+13 -60 replies
15/41Pass the struct vfsmounts to the inode_link LSM hookfs/namei.c include/linux/security.h security/dummy.c +1 more+26 -100 replies
16/41Add a struct vfsmount parameter to vfs_rmdir()fs/ecryptfs/inode.c fs/namei.c fs/nfsd/nfs4recover.c +3 more+9 -70 replies
17/41Pass struct vfsmount to the inode_rmdir LSM hookfs/namei.c include/linux/security.h security/dummy.c +1 more+13 -70 replies
18/41call lsm hook before unhashing dentry in vfs_rmdir()fs/namei.c+7 -60 replies
19/41Add a struct vfsmount parameter to vfs_unlink()fs/ecryptfs/inode.c fs/namei.c fs/nfsd/nfs4recover.c +3 more+8 -70 replies
20/41Pass struct vfsmount to the inode_unlink LSM hookfs/namei.c include/linux/security.h security/dummy.c +1 more+14 -80 replies
21/41Add struct vfsmount parameters to vfs_rename()fs/ecryptfs/inode.c fs/namei.c fs/nfsd/vfs.c +1 more+21 -100 replies
22/41Pass struct vfsmount to the inode_rename LSM hookfs/namei.c include/linux/security.h security/dummy.c +1 more+26 -100 replies
23/41Add a struct vfsmount parameter to vfs_setxattr()fs/nfsd/vfs.c fs/xattr.c include/linux/xattr.h+21 -140 replies
24/41Pass struct vfsmount to the inode_setxattr LSM hookfs/xattr.c include/linux/security.h security/commoncap.c +2 more+41 -240 replies
25/41Add a struct vfsmount parameter to vfs_getxattr()fs/nfsd/nfs4xdr.c fs/nfsd/vfs.c fs/xattr.c +2 more+25 -180 replies
26/41Pass struct vfsmount to the inode_getxattr LSM hookfs/xattr.c include/linux/security.h security/dummy.c +1 more+13 -80 replies
27/41Add a struct vfsmount parameter to vfs_listxattr()fs/xattr.c include/linux/xattr.h+16 -120 replies
28/41Pass struct vfsmount to the inode_listxattr LSM hookfs/xattr.c include/linux/security.h security/dummy.c +1 more+10 -80 replies
29/41Add a struct vfsmount parameter to vfs_removexattr()fs/nfsd/vfs.c fs/xattr.c include/linux/xattr.h+9 -80 replies
30/41Pass struct vfsmount to the inode_removexattr LSM hookfs/xattr.c include/linux/security.h security/commoncap.c +2 more+16 -100 replies
31/41Fix __d_path() for lazy unmounts and make it unambiguous; exclude unreachable mount points from /proc/mountsfs/dcache.c fs/namespace.c fs/proc/base.c+131 -10130 replies
32/41Make d_path() consistent across mount operationsfs/dcache.c+8 -60 replies
33/41Add d_namespace_path() to obtain namespace relative pathnamesfs/dcache.c fs/namespace.c include/linux/dcache.h +1 more+29 -31 reply
34/41Enable LSM hooks to distinguish operations on file descriptors from operations on pathnames.fs/nfsd/vfs.c fs/open.c include/linux/fs.h+20 -100 replies
35/41Pass struct file down the inode_*xattr security LSM hooksfs/xattr.c include/linux/security.h include/linux/xattr.h +3 more+70 -570 replies
36/41Export audit subsystem for use by modulesinclude/linux/audit.h kernel/audit.c+9 -20 replies
37/41AppArmor: Main Partsecurity/apparmor/main.c+1322 -04 replies
38/41AppArmor: Module and LSM hookssecurity/apparmor/lsm.c+829 -02 replies
39/41AppArmor: Profile loading and manipulation, pathname matchingsecurity/apparmor/match.c security/apparmor/match.h security/apparmor/module_interface.c+956 -08 replies
40/41AppArmor: all the restsecurity/apparmor/Kconfig security/apparmor/Makefile security/apparmor/apparmor.h +5 more+1067 -02 replies
41/41Add AppArmor LSM to security/Makefilesecurity/Kconfig security/Makefile+2 -00 replies

Reviews trailers per patch

2 of 41 patches have a Reviewed-by or Acked-by.

PatchJohn JohansenNeilBrownAlan Cox
1/41
2/41
3/41
4/41
5/41
6/41
7/41
8/41
9/41
10/41
11/41
12/41
13/41
14/41
15/41
16/41
17/41
18/41
19/41
20/41
21/41
22/41
23/41
24/41
25/41
26/41
27/41
28/41
29/41
30/41
31/41R-b R-b A-b
32/41
33/41R-b
34/41
35/41
36/41
37/41
38/41
39/41
40/41
41/41

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [AppArmor 00/41] AppArmor security module overview

This post contains patches to include the AppArmor application security framework, with request for inclusion.

The patch series consists of four areas:

(1) Pass struct vfsmount through to LSM hooks.

Tony Jones has posted almost all of these patches here before on February 5; the feedback given has been incorporated.

(2) Fixes and improvements to d_path:

(a) make it unambiguous and exclude unreachable paths from /proc/mounts,

(b) make its result consistent in the face of remounts,

(c) introduce d_namespace_path(), a variant of d_path that goes up to the namespace root instead of the chroot.

Part (a) has been in the -mm tree for more than a month; this series includes a copy of the -mm patch. Parts (b) and (c) shouldn't be too controversial.

(3) Be able to distinguish file descriptor access from access by name in LSM hooks.

Applications expect different behavior from file descriptor accesses and accesses by name in some cases. We need to pass this information down the LSM hooks to allow AppArmor to tell which is which.

(4) The AppArmor LSM itself.

(See below.)

A tarball of the kernel patches, base user-space utilities, example profiles, and technical documentation (including a walk-through) are available at:

http://forgeftp.novell.com//apparmor/LKML_Submission-April_07/

The rest of this introduction gives a brief overview of AppArmor's overall design. We will try to address the concerns people had when AppArmor was previously posted here in April 06 in a follow-up post.

AppArmor's Overall Design
=========================

AppArmor protects systems from vulnerable software by confining processes, giving them "least privilege" access to the system's
resources: with least privilege, processes are allowed exactly what they need, nothing more, and nothing less. Systems are thus protected from bugs in applications that would lead to privilege escalation, such as remote system access because of a buffer overflow in a web server, etc.

AppArmor does this by defining application profiles which list allowed accesses, and assigning those profiles to processes. AppArmor does *not* require the user to confine all processes on the system. Rather, you need to provide AppArmor profiles for every process that is potentially subject to manipulation by the attacker. For instance, to defend against network attack, confine all process that access the network.

The corollary to this is that attacks against AppArmor that start with "assume some unconfined process does ..." are outside the AppArmor threat model. Any process that might do something malicious to an AppArmor system should be confined by an AppArmor profile.

The kernel manages many different kinds of resources. AppArmor currently controls access to two key resources among them: files, and POSIX Capabilities. (Additional protection for things like rlimits, interprocess communication, and network access are being worked on, and are expected to become available in a future version.)

File Access Control
-------------------

Application profiles control file access by pathname: each profile contains a list of fully qualified pathnames (potentially containing globbing) and associated access modes: read (r), write (w), different kinds of execute (ix, Px, px, Ux, ux), create hard-link (l), and memory map for execution (m).

For example, the following two rules permit read access to any file below /srv/www/htdocs/**.html, and memory map for execution (m), execute inheriting the current profile (ix), and read (r) access to /usr/sbin/suexec2:

    /srv/www/htdocs/**.html r,
    /usr/sbin/suexec2 mixr,

POSIX Capabilities
------------------

Application profiles enumerate the POSIX capabilites that a process may use. (A process must have a capability both in its effective capabilities set and in its profile in order to use it. See the capabilities(7) manual page for details on capabilities.)

For example, the following rule allows processes to chroot(2):

capability sys_chroot,

An Example Profile
------------------

Here is an example profile for ntpd:

    /usr/sbin/ntpd {
      #include <abstractions/base>
      #include <abstractions/nameservice>

      capability ipc_lock,
      capability net_bind_service,
      capability setgid,
      capability setuid,
      capability sys_chroot,
      capability sys_resource,
      capability sys_time,

      /drift/ntp.drift rwl,
      /drift/ntp.drift.TEMP rwl,
      /etc/ntp.conf r,
      /etc/ntp/drift* rwl,
      /etc/ntp/keys r,
      /etc/ntp/step-tickers r,
      /tmp/ntp* rwl,
      /usr/sbin/ntpd rmix,
      /var/lib/ntp/etc/ntp.conf.iburst  r,
      /var/lib/ntp/drift rwl,
      /var/lib/ntp/drift.TEMP rwl,
      /var/lib/ntp/drift/ntp.drift r,
      /var/lib/ntp/var/run/ntp/ntpd.pid w,
      /var/log/ntp w,
      /var/log/ntp.log w,
      /var/run/ntpd.pid w,
    }

Briefly, the /usr/sbin/ntpd in line 1 tells AppArmor to use this profile for /usr/sbin/ntpd. The include lines pull in some predefined abstractions containing frequently used access patterns which allow to keep profiles short, and the capability and file access rules have been explained above.

Explaining the AppArmor design in detail would take by far too much space here, so let me refer you to the technical documentation for that. Included is a low-level walk-through of the system and basic tools, and some examples. The manual pages included in the apparmor-parser package are worth a read as well.