~ubuntu-branches/ubuntu/quantal/apparmor/quantal-updates

« back to all changes in this revision

Viewing changes to .pc/0008-apparmor-lp963756.patch/parser/immunix.h

  • Committer: Package Import Robot
  • Author(s): Steve Beattie, Jamie Strandboge, Serge Hallyn, Steve Beattie
  • Date: 2012-04-12 06:17:42 UTC
  • Revision ID: package-import@ubuntu.com-20120412061742-9v75hjko2mjtbewv
Tags: 2.7.102-0ubuntu3
[ Jamie Strandboge ]
* debian/patches/0007-ubuntu-manpage-updates.patch: update apparmor(5)
  to describe Ubuntu's two-stage policy load and how to add utilize it
  when developing policy (LP: #974089)

[ Serge Hallyn ]
* debian/apparmor.init: do nothing in a container.  This can be
  removed once stacked profiles are supported and used by lxc.
  (LP: #978297)

[ Steve Beattie ]
* debian/patches/0008-apparmor-lp963756.patch: Fix permission mapping
  for change_profile onexec (LP: #963756)
* debian/patches/0009-apparmor-lp959560-part1.patch,
  debian/patches/0010-apparmor-lp959560-part2.patch: Update the parser
  to support the 'in' keyword for value lists, and make mount
  operations aware of 'in' keyword so they can affect the flags build
  list (LP: #959560)
* debian/patches/0011-apparmor-lp872446.patch: fix logprof missing
  exec events in complain mode (LP: #872446)
* debian/patches/0012-apparmor-lp978584.patch: allow inet6 access in
  dovecot imap-login profile (LP: #978584)
* debian/patches/0013-apparmor-lp800826.patch: fix libapparmor
  log parsing library from dropping apparmor network events that
  contain ip addresses or ports in them (LP: #800826)
* debian/patches/0014-apparmor-lp979095.patch: document new mount rule
  syntax and usage in apparmor.d(5) manpage (LP: #979095)
* debian/patches/0015-apparmor-lp963756.patch: Fix change_onexec
  for profiles without attachment specification (LP: #963756,
  LP: #978038)
* debian/patches/0016-apparmor-lp968956.patch: Fix protocol error when
  loading policy to kernels without compat patches (LP: #968956)
* debian/patches/0017-apparmor-lp979135.patch: Fix change_profile to
  grant access to /proc/attr api (LP: #979135)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *      Copyright (c) 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007
 
3
 *      NOVELL (All rights reserved)
 
4
 *
 
5
 *      Immunix AppArmor LSM
 
6
 *
 
7
 *      This program is free software; you can redistribute it and/or
 
8
 *      modify it under the terms of the GNU General Public License as
 
9
 *      published by the Free Software Foundation, version 2 of the
 
10
 *      License.
 
11
 *
 
12
 *      This program is distributed in the hope that it will be useful,
 
13
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 *      GNU General Public License for more details.
 
16
 *
 
17
 *      You should have received a copy of the GNU General Public License
 
18
 *      along with this program; if not, contact Novell, Inc.
 
19
 */
 
20
 
 
21
#ifndef _IMMUNIX_H
 
22
#define _IMMUNIX_H
 
23
 
 
24
/*
 
25
 * Modeled after MAY_READ, MAY_WRITE, MAY_EXEC in the kernel. The value of
 
26
 * AA_MAY_EXEC must be identical to MAY_EXEC, etc.
 
27
 */
 
28
#define AA_MAY_EXEC                     (1 << 0)
 
29
#define AA_MAY_WRITE                    (1 << 1)
 
30
#define AA_MAY_READ                     (1 << 2)
 
31
#define AA_MAY_APPEND                   (1 << 3)
 
32
#define AA_MAY_LINK                     (1 << 4)
 
33
#define AA_MAY_LOCK                     (1 << 5)
 
34
#define AA_EXEC_MMAP                    (1 << 6)
 
35
#define AA_EXEC_PUX                     (1 << 7)
 
36
#define AA_EXEC_UNSAFE                  (1 << 8)
 
37
#define AA_EXEC_INHERIT                 (1 << 9)
 
38
#define AA_EXEC_MOD_0                   (1 << 10)
 
39
#define AA_EXEC_MOD_1                   (1 << 11)
 
40
#define AA_EXEC_MOD_2                   (1 << 12)
 
41
#define AA_EXEC_MOD_3                   (1 << 13)
 
42
 
 
43
#define AA_BASE_PERMS                   (AA_MAY_EXEC | AA_MAY_WRITE | \
 
44
                                         AA_MAY_READ | AA_MAY_APPEND | \
 
45
                                         AA_MAY_LINK | AA_MAY_LOCK | \
 
46
                                         AA_EXEC_PUX | AA_EXEC_MMAP | \
 
47
                                         AA_EXEC_UNSAFE | AA_EXEC_INHERIT | \
 
48
                                         AA_EXEC_MOD_0 | AA_EXEC_MOD_1 | \
 
49
                                         AA_EXEC_MOD_2 | AA_EXEC_MOD_3)
 
50
 
 
51
#define AA_USER_SHIFT                   0
 
52
#define AA_OTHER_SHIFT                  14
 
53
 
 
54
#define AA_USER_PERMS                   (AA_BASE_PERMS << AA_USER_SHIFT)
 
55
#define AA_OTHER_PERMS                  (AA_BASE_PERMS << AA_OTHER_SHIFT)
 
56
 
 
57
#define AA_FILE_PERMS                   (AA_USER_PERMS | AA_OTHER_PERMS )
 
58
 
 
59
#define AA_USER_PTRACE                  (1 << 28)
 
60
#define AA_OTHER_PTRACE                 (1 << 29)
 
61
#define AA_PTRACE_PERMS                 (AA_USER_PTRACE | AA_OTHER_PTRACE)
 
62
 
 
63
#define AA_CHANGE_HAT                   (1 << 30)
 
64
#define AA_CHANGE_PROFILE               (1 << 31)
 
65
#define AA_SHARED_PERMS                 (AA_CHANGE_HAT | AA_CHANGE_PROFILE)
 
66
 
 
67
#define AA_EXEC_MODIFIERS               (AA_EXEC_MOD_0 | AA_EXEC_MOD_1 | \
 
68
                                         AA_EXEC_MOD_2 | AA_EXEC_MOD_3)
 
69
#define AA_EXEC_COUNT                   16
 
70
 
 
71
#define AA_USER_EXEC_MODIFIERS          (AA_EXEC_MODIFIERS << AA_USER_SHIFT)
 
72
#define AA_OTHER_EXEC_MODIFIERS         (AA_EXEC_MODIFIERS << AA_OTHER_SHIFT)
 
73
#define AA_ALL_EXEC_MODIFIERS           (AA_USER_EXEC_MODIFIERS | \
 
74
                                         AA_OTHER_EXEC_MODIFIERS)
 
75
 
 
76
#define AA_EXEC_TYPE                    (AA_EXEC_UNSAFE | AA_EXEC_INHERIT | \
 
77
                                         AA_EXEC_PUX | AA_EXEC_MODIFIERS)
 
78
 
 
79
#define AA_EXEC_UNCONFINED              (AA_EXEC_MOD_0)
 
80
#define AA_EXEC_PROFILE                 (AA_EXEC_MOD_1)
 
81
#define AA_EXEC_LOCAL                   (AA_EXEC_MOD_0 | AA_EXEC_MOD_1)
 
82
 
 
83
#define AA_VALID_PERMS                  (AA_FILE_PERMS | AA_PTRACE_PERMS | \
 
84
                                         AA_OTHER_PERMS)
 
85
 
 
86
#define AA_USER_EXEC                    (AA_MAY_EXEC << AA_USER_SHIFT)
 
87
#define AA_OTHER_EXEC                   (AA_MAY_EXEC << AA_OTHER_SHIFT)
 
88
 
 
89
#define AA_EXEC_BITS                    (AA_USER_EXEC | AA_OTHER_EXEC)
 
90
 
 
91
#define ALL_AA_EXEC_UNSAFE              ((AA_EXEC_UNSAFE << AA_USER_SHIFT) | \
 
92
                                         (AA_EXEC_UNSAFE << AA_OTHER_SHIFT))
 
93
 
 
94
#define AA_USER_EXEC_TYPE               (AA_EXEC_TYPE << AA_USER_SHIFT)
 
95
#define AA_OTHER_EXEC_TYPE              (AA_EXEC_TYPE << AA_OTHER_SHIFT)
 
96
 
 
97
#define ALL_AA_EXEC_TYPE                (AA_USER_EXEC_TYPE | AA_OTHER_EXEC_TYPE)
 
98
 
 
99
#define ALL_USER_EXEC                   (AA_USER_EXEC | AA_USER_EXEC_TYPE)
 
100
#define ALL_OTHER_EXEC                  (AA_OTHER_EXEC | AA_OTHER_EXEC_TYPE)
 
101
 
 
102
#define AA_LINK_BITS                    ((AA_MAY_LINK << AA_USER_SHIFT) | \
 
103
                                         (AA_MAY_LINK << AA_OTHER_SHIFT))
 
104
 
 
105
#define SHIFT_MODE(MODE, SHIFT)         ((((MODE) & AA_BASE_PERMS) << (SHIFT))\
 
106
                                         | ((MODE) & ~AA_FILE_PERMS))
 
107
#define SHIFT_TO_BASE(MODE, SHIFT)      ((((MODE) & AA_FILE_PERMS) >> (SHIFT))\
 
108
                                         | ((MODE) & ~AA_FILE_PERMS))
 
109
 
 
110
 
 
111
#define AA_LINK_SUBSET_TEST             (AA_MAY_LINK << 1)
 
112
#define LINK_SUBSET_BITS        ((AA_LINK_SUBSET_TEST << AA_USER_SHIFT) | \
 
113
                                 (AA_LINK_SUBSET_TEST << AA_OTHER_SHIFT))
 
114
#define LINK_TO_LINK_SUBSET(X)          (((X) << 1) & AA_LINK_SUBSET_TEST)
 
115
 
 
116
 
 
117
/* Pack the audit, and quiet masks into a single 28 bit field in the
 
118
 * format oq:oa:uq:ua
 
119
 */
 
120
#define PACK_AUDIT_CTL(audit, quiet)    (((audit) & 0x1fc07f) | \
 
121
                                         (((quiet) & 0x1fc07f) << 7))
 
122
 
 
123
#define AA_HAT_SIZE     975     /* Maximum size of a subdomain
 
124
                                         * ident (hat) */
 
125
#define AA_IP_TCP                       0x0001
 
126
#define AA_IP_UDP                       0x0002
 
127
#define AA_IP_RDP                       0x0004
 
128
#define AA_IP_RAW                       0x0008
 
129
#define AA_IPV6_TCP                     0x0010
 
130
#define AA_IPV6_UDP                     0x0020
 
131
#define AA_NETLINK                      0x0040
 
132
 
 
133
enum pattern_t {
 
134
        ePatternBasic,
 
135
        ePatternTailGlob,
 
136
        ePatternRegex,
 
137
        ePatternInvalid,
 
138
};
 
139
 
 
140
#define HAS_MAY_READ(mode)              ((mode) & AA_MAY_READ)
 
141
#define HAS_MAY_WRITE(mode)             ((mode) & AA_MAY_WRITE)
 
142
#define HAS_MAY_APPEND(mode)            ((mode) & AA_MAY_APPEND)
 
143
#define HAS_MAY_EXEC(mode)              ((mode) & AA_MAY_EXEC)
 
144
#define HAS_MAY_LINK(mode)              ((mode) & AA_MAY_LINK)
 
145
#define HAS_MAY_LOCK(mode)              ((mode) & AA_MAY_LOCK)
 
146
#define HAS_EXEC_MMAP(mode)             ((mode) & AA_EXEC_MMAP)
 
147
 
 
148
#define HAS_EXEC_UNSAFE(mode)           ((mode) & AA_EXEC_UNSAFE)
 
149
#define HAS_CHANGE_PROFILE(mode)        ((mode) & AA_CHANGE_PROFILE)
 
150
 
 
151
#include <stdio.h>
 
152
static inline int is_merged_x_consistent(int a, int b)
 
153
{
 
154
        if ((a & AA_USER_EXEC) && (b & AA_USER_EXEC) &&
 
155
            ((a & AA_USER_EXEC_TYPE) != (b & AA_USER_EXEC_TYPE)))
 
156
          { //fprintf(stderr, "failed user merge 0x%x 0x%x\n", a, b);
 
157
                return 0;
 
158
}
 
159
        if ((a & AA_OTHER_EXEC) && (b & AA_OTHER_EXEC) &&
 
160
            ((a & AA_OTHER_EXEC_TYPE) != (b & AA_OTHER_EXEC_TYPE)))
 
161
          { //fprintf(stderr, "failed other merge 0x%x 0x%x\n", a, b);
 
162
                return 0;
 
163
}
 
164
        return 1;
 
165
}
 
166
 
 
167
#endif                          /* ! _IMMUNIX_H */