~ubuntu-branches/ubuntu/precise/apparmor/precise-security

« back to all changes in this revision

Viewing changes to debian/patches/0014-apparmor-lp979095.patch

  • 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
Origin: upstream, lp:apparmor
 
2
Subject  add mount rule syntax and usage.
 
3
revno: 2023 thorough 2026
 
4
committer: Jamie Strandboge <jamie@canonical.com>
 
5
branch nick: master
 
6
timestamp: Wed 2012-04-11 16:34:22 -0500
 
7
message:
 
8
  parser/apparmor.d.pod: add mount rule syntax and usage. Refinements and
 
9
  clarifications thanks to Steve Beattie.
 
10
  
 
11
  Acked-By: Jamie Strandboge <jamie@canonical.com>
 
12
  Acked-By: Steve Beattie <sbeattie@ubuntu.com>
 
13
 
 
14
also includes
 
15
 
 
16
  Attached is a patch to add --stderr to the common rules for generating
 
17
  manpages (and adjust it so that it's one rule instead of eight). It
 
18
  also fixes the above problem and a similar problem in the aa-exec
 
19
  manpage.
 
20
 
 
21
---
 
22
 common/Make.rules     |   25 ---
 
23
 parser/apparmor.d.pod |  332 +++++++++++++++++++++++++++++++++++++++++++++++++-
 
24
 utils/aa-exec.pod     |    2 
 
25
 3 files changed, 330 insertions(+), 29 deletions(-)
 
26
 
 
27
Index: b/common/Make.rules
 
28
===================================================================
 
29
--- a/common/Make.rules
 
30
+++ b/common/Make.rules
 
31
@@ -206,29 +206,8 @@ install_manpages: $(MANPAGES)
 
32
 
 
33
 MAN_RELEASE="AppArmor ${VERSION}"
 
34
 
 
35
-%.1: %.pod
 
36
-       $(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --section=1 > $@
 
37
-
 
38
-%.2: %.pod
 
39
-       $(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --section=2 > $@
 
40
-
 
41
-%.3: %.pod
 
42
-       $(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --section=3 > $@
 
43
-
 
44
-%.4: %.pod
 
45
-       $(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --section=4 > $@
 
46
-
 
47
-%.5: %.pod
 
48
-       $(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --section=5 > $@
 
49
-
 
50
-%.6: %.pod
 
51
-       $(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --section=6 > $@
 
52
-
 
53
-%.7: %.pod
 
54
-       $(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --section=7 > $@
 
55
-
 
56
-%.8: %.pod
 
57
-       $(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --section=8 > $@
 
58
+%.1 %.2 %.3 %.4 %.5 %.6 %.7 %.8: %.pod
 
59
+       $(POD2MAN) $< --release=$(MAN_RELEASE) --center=AppArmor --stderr --section=$(subst .,,$(suffix $@)) > $@
 
60
 
 
61
 %.1.html: %.pod
 
62
        $(POD2HTML) --header --css apparmor.css --infile=$< --outfile=$@
 
63
Index: b/parser/apparmor.d.pod
 
64
===================================================================
 
65
--- a/parser/apparmor.d.pod
 
66
+++ b/parser/apparmor.d.pod
 
67
@@ -54,7 +54,7 @@ B<COMMENT> = '#' I<TEXT>
 
68
 
 
69
 B<TEXT> = any characters
 
70
 
 
71
-B<PROFILE> = [ I<COMMENT> ... ] [ I<VARIABLE ASSIGNMENT> ... ] ( '"' I<PROGRAM> '"' | I<PROGRAM> ) [ 'flags=(complain)' ]'{' [ ( I<RESOURCE RULE> | I<COMMENT> | I<INCLUDE> | I<SUBPROFILE> | 'capability ' I<CAPABILITY> | I<NETWORK RULE> | 'change_profile -> ' I<PROGRAMCHILD> ) ... ] '}'
 
72
+B<PROFILE> = [ I<COMMENT> ... ] [ I<VARIABLE ASSIGNMENT> ... ] ( '"' I<PROGRAM> '"' | I<PROGRAM> ) [ 'flags=(complain)' ]'{' [ ( I<RESOURCE RULE> | I<COMMENT> | I<INCLUDE> | I<SUBPROFILE> | 'capability ' I<CAPABILITY> | I<NETWORK RULE> | I<MOUNT RULE> | I<FILE RULE> | 'change_profile -> ' I<PROGRAMCHILD> ) ... ] '}'
 
73
 
 
74
 B<SUBPROFILE> = [ I<COMMENT> ... ] ( I<PROGRAMHAT> | 'profile ' I<PROGRAMCHILD> ) '{' [ ( I<FILE RULE> | I<COMMENT> | I<INCLUDE> ) ... ] '}'
 
75
 
 
76
@@ -75,11 +75,37 @@ B<PROGRAMHAT> = '^'  (non-whitespace cha
 
77
 
 
78
 B<PROGRAMCHILD> = I<SUBPROFILE> name
 
79
 
 
80
+B<MOUNT RULE> = ( I<MOUNT> | I<REMOUNT> | I<UMOUNT> | I<PIVOT ROOT> )
 
81
+
 
82
+B<MOUNT> = [ 'audit' ] [ 'deny' ] 'mount' [ I<MOUNT CONDITIONS> ] [ I<SOURCE FILEGLOB> ] [ -> [ I<MOUNTPOINT FILEGLOB> ]
 
83
+
 
84
+B<REMOUNT> = [ 'audit' ] [ 'deny' ] 'remount' [ I<MOUNT CONDITIONS> ] I<MOUNTPOINT FILEGLOB>
 
85
+
 
86
+B<UMOUNT> = [ 'audit' ] [ 'deny' ] 'umount' [ I<MOUNT CONDITIONS> ] I<MOUNTPOINT FILEGLOB>
 
87
+
 
88
+B<PIVOT ROOT> = [ 'audit' ] [ 'deny' ] pivot_root [ I<OLD ABS PATH> ] [ I<MOUNTPOINT ABS PATH> ] [ -> I<PROGRAMCHILD> ]
 
89
+
 
90
+B<MOUNT CONDITIONS> = [ ( 'fstype' | 'vfstype' ) ( '=' | 'in' ) I<MOUNT FSTYPE EXPRESSION> ] [ 'options' ( '=' | 'in' ) I<MOUNT FLAGS EXPRESSION> ]
 
91
+
 
92
+B<MOUNT FSTYPE EXPRESSION> = ( I<MOUNT FSTYPE LIST> | I<MOUNT EXPRESSION> )
 
93
+
 
94
+B<MOUNT FSTYPE LIST> = Comma separated list of valid filesystem and virtual filesystem types (eg ext4, debugfs, devfs, etc)
 
95
+
 
96
+B<MOUNT FLAGS EXPRESSION> = ( I<MOUNT FLAGS LIST> | I<MOUNT EXPRESSION> )
 
97
+
 
98
+B<MOUNT FLAGS LIST> = Comma separated list of I<MOUNT FLAGS>.
 
99
+
 
100
+B<MOUNT FLAGS> = ( 'ro' | 'rw' | 'nosuid' | 'suid' | 'nodev' | 'dev' | 'noexec' | 'exec' | 'sync' | 'async' | 'remount' | 'mand' | 'nomand' | 'dirsync' | 'nodirsync' | 'noatime' | 'atime' | 'nodiratime' | 'diratime' | 'bind' | 'move' | 'rec' | 'verbose' | 'silent' | 'load' | 'acl' | 'noacl' | 'unbindable' | 'private' | 'slave' | 'shared' | 'relative' | 'norelative' | 'iversion' | 'noiversion' | 'strictatime' | 'nouser' | 'user' )
 
101
+
 
102
+B<MOUNT EXPRESSION> = ( I<ALPHANUMERIC> | I<AARE> ) ...
 
103
+
 
104
+B<AARE> = B<?*[]{}^> (see below for meanings)
 
105
+
 
106
 B<FILE RULE> = I<RULE QUALIFIER> ( '"' I<FILEGLOB> '"' | I<FILEGLOB> ) I<ACCESS> ','
 
107
 
 
108
 B<RULE QUALIFIER> = [ 'audit' ] [ 'deny' ] [ 'owner' ]
 
109
 
 
110
-B<FILEGLOB> = (must start with '/' (after variable expansion), B<?*[]{}^> have special meanings; see below. May include I<VARIABLE>. Rules with embedded spaces or tabs must be quoted. Rules must end with '/' to apply to directories.)
 
111
+B<FILEGLOB> = (must start with '/' (after variable expansion), B<AARE> have special meanings; see below. May include I<VARIABLE>. Rules with embedded spaces or tabs must be quoted. Rules must end with '/' to apply to directories.)
 
112
 
 
113
 B<ACCESS> = ( 'r' | 'w' | 'l' | 'ix' | 'ux' | 'Ux' | 'px' | 'Px' | 'cx -> ' I<PROGRAMCHILD> | 'Cx -> ' I<PROGRAMCHILD> | 'm' ) [ I<ACCESS> ... ]  (not all combinations are allowed; see below.)
 
114
 
 
115
@@ -303,10 +329,6 @@ access is not granted, some capabilities
 
116
 arbitrary access to IPC, ability to bypass discretionary access controls,
 
117
 and other operations that are typically reserved for the root user.
 
118
 
 
119
-The only operations that cannot be controlled in this manner are mount(2),
 
120
-umount(2), and loading new AppArmor policy into the kernel, which are
 
121
-always denied to confined processes.
 
122
-
 
123
 =head2 Network Rules
 
124
 
 
125
 AppArmor supports simple coarse grained network mediation.  The network
 
126
@@ -328,6 +350,281 @@ eg.
 
127
  network inet tcp,     #allow access to tcp only for inet4 addresses
 
128
  network inet6 tcp,    #allow access to tcp only for inet6 addresses
 
129
 
 
130
+=head2 Mount Rules
 
131
+
 
132
+AppArmor supports mount mediation and allows specifying filesystem types and
 
133
+mount flags. The syntax of mount rules in AppArmor is based on the mount(8)
 
134
+command syntax. Mount rules must contain one of the mount, remount, umount or
 
135
+pivot_root keywords, but all mount conditions are optional. Unspecified
 
136
+optional conditionals are assumed to match all entries (eg, not specifying
 
137
+fstype means all fstypes are matched). Due to the complexity of the mount
 
138
+command and how options may be specified, AppArmor allows specifying
 
139
+conditionals three different ways:
 
140
+
 
141
+=over 4
 
142
+
 
143
+=item 1.
 
144
+
 
145
+If a conditional is specified using '=', then the rule only grants permission
 
146
+for mounts matching the exactly specified options. For example, an AppArmor
 
147
+policy with the following rule:
 
148
+
 
149
+=over 4
 
150
+
 
151
+mount options=ro /dev/foo -> /mnt/,
 
152
+
 
153
+=back
 
154
+
 
155
+Would match:
 
156
+
 
157
+=over 4
 
158
+
 
159
+$ mount -o ro /dev/foo /mnt
 
160
+
 
161
+=back
 
162
+
 
163
+but not either of these:
 
164
+
 
165
+=over 4
 
166
+
 
167
+$ mount -o ro,atime /dev/foo /mnt
 
168
+
 
169
+$ mount -o rw /dev/foo /mnt
 
170
+
 
171
+=back
 
172
+
 
173
+=item 2.
 
174
+
 
175
+If a conditional is specified using 'in', then the rule grants permission for
 
176
+mounts matching any combination of the specified options. For example, if an
 
177
+AppArmor policy has the following rule:
 
178
+
 
179
+=over 4
 
180
+
 
181
+mount options in (ro,atime) /dev/foo -> /mnt/,
 
182
+
 
183
+=back
 
184
+
 
185
+all of these mount commands will match:
 
186
+
 
187
+=over 4
 
188
+
 
189
+$ mount -o ro /dev/foo /mnt
 
190
+
 
191
+$ mount -o ro,atime /dev/foo /mnt
 
192
+
 
193
+$ mount -o atime /dev/foo /mnt
 
194
+
 
195
+=back
 
196
+
 
197
+but none of these will:
 
198
+
 
199
+=over 4
 
200
+
 
201
+$ mount -o ro,sync /dev/foo /mnt
 
202
+
 
203
+$ mount -o ro,atime,sync /dev/foo /mnt
 
204
+
 
205
+$ mount -o rw /dev/foo /mnt
 
206
+
 
207
+$ mount -o rw,noatime /dev/foo /mnt
 
208
+
 
209
+$ mount /dev/foo /mnt
 
210
+
 
211
+=back
 
212
+
 
213
+=item 3.
 
214
+
 
215
+If multiple conditionals are specified in a single mount rule, then the rule
 
216
+grants permission for each set of options. This provides a shorthand when
 
217
+writing mount rules which might help to logically break up a conditional. For
 
218
+example, if an AppArmor policy has the following rule:
 
219
+
 
220
+=over 4
 
221
+
 
222
+mount options=ro options=atime
 
223
+
 
224
+=back
 
225
+
 
226
+both of these mount commands will match:
 
227
+
 
228
+=over 4
 
229
+
 
230
+$ mount -o ro /dev/foo /mnt
 
231
+
 
232
+$ mount -o atime /dev/foo /mnt
 
233
+
 
234
+=back
 
235
+
 
236
+but this one will not:
 
237
+
 
238
+=over 4
 
239
+
 
240
+$ mount -o ro,atime /dev/foo /mnt
 
241
+
 
242
+=back
 
243
+
 
244
+=back
 
245
+
 
246
+Note that separate mount rules are distinct and the options do not accumulate.
 
247
+For example, these AppArmor mount rules:
 
248
+
 
249
+=over 4
 
250
+
 
251
+mount options=ro,
 
252
+mount options=atime,
 
253
+
 
254
+=back
 
255
+
 
256
+are not equivalent to either of these mount rules:
 
257
+
 
258
+=over 4
 
259
+
 
260
+mount options=(ro,atime),
 
261
+
 
262
+mount options in (ro,atime),
 
263
+
 
264
+=back
 
265
+
 
266
+To help clarify the flexibility and complexity of mount rules, here are some
 
267
+example rules with accompanying matching commands:
 
268
+
 
269
+=over 4
 
270
+
 
271
+=item B<mount,>
 
272
+
 
273
+the 'mount' rule without any conditionals is the most generic and allows any
 
274
+mount. Equivalent to 'mount fstype=** options=** ** -> /**'.
 
275
+
 
276
+=item B<mount /dev/foo,>
 
277
+
 
278
+allow mounting of /dev/foo anywhere with any options. Some matching mount
 
279
+commands:
 
280
+
 
281
+=over 4
 
282
+
 
283
+$ mount /dev/foo /mnt
 
284
+
 
285
+$ mount -t ext3 /dev/foo /mnt
 
286
+
 
287
+$ mount -t vfat /dev/foo /mnt
 
288
+
 
289
+$ mount -o ro,atime,noexec,nodiratime /dev/foo /srv/some/mountpoint
 
290
+
 
291
+=back
 
292
+
 
293
+=item B<mount options=ro /dev/foo,>
 
294
+
 
295
+allow mounting of /dev/foo anywhere, as read only. Some matching mount
 
296
+commands:
 
297
+
 
298
+=over 4
 
299
+
 
300
+$ mount -o ro /dev/foo /mnt
 
301
+
 
302
+$ mount -o ro /dev/foo /some/where/else
 
303
+
 
304
+=back
 
305
+
 
306
+=item B<mount options=(ro,atime) /dev/foo,>
 
307
+
 
308
+allow mount of /dev/foo anywhere, as read only and using inode access times.
 
309
+Some matching mount commands:
 
310
+
 
311
+=over 4
 
312
+
 
313
+$ mount -o ro,atime /dev/foo /mnt
 
314
+
 
315
+$ mount -o ro,atime /dev/foo /some/where/else
 
316
+
 
317
+=back
 
318
+
 
319
+=item B<mount options in (ro,atime) /dev/foo,>
 
320
+
 
321
+allow mount of /dev/foo anywhere using some combination of 'ro' and 'atime'
 
322
+(see above). Some matching mount commands:
 
323
+
 
324
+=over 4
 
325
+
 
326
+$ mount -o ro /dev/foo /mnt
 
327
+
 
328
+$ mount -o atime /dev/foo /some/where/else
 
329
+
 
330
+$ mount -o ro,atime /dev/foo /some/other/place
 
331
+
 
332
+=back
 
333
+
 
334
+=item B<mount options=ro /dev/foo, mount options=atime /dev/foo,>
 
335
+
 
336
+allow mount of /dev/foo anywhere as read only, and allow mount of /dev/foo
 
337
+anywhere using inode access times. Note this is expressed as two different
 
338
+rules. Matches:
 
339
+
 
340
+=over 4
 
341
+
 
342
+$ mount -o ro /dev/foo /mnt/1
 
343
+
 
344
+$ mount -o atime /dev/foo /mnt/2
 
345
+
 
346
+=back
 
347
+
 
348
+=item B<< mount -> /mnt/**, >>
 
349
+
 
350
+allow mounting anything under a directory in /mnt/**. Some matching mount
 
351
+commands:
 
352
+
 
353
+=over 4
 
354
+
 
355
+$ mount /dev/foo1 /mnt/1
 
356
+
 
357
+$ mount -o ro,atime,noexec,nodiratime /dev/foo2 /mnt/deep/path/foo2
 
358
+
 
359
+=back
 
360
+
 
361
+=item B<< mount options=ro -> /mnt/**, >>
 
362
+
 
363
+allow mounting anything under /mnt/**, as read only. Some matching mount
 
364
+commands:
 
365
+
 
366
+=over 4
 
367
+
 
368
+$ mount -o ro /dev/foo1 /mnt/1
 
369
+
 
370
+$ mount -o ro /dev/foo2 /mnt/deep/path/foo2
 
371
+
 
372
+=back
 
373
+
 
374
+=item B<< mount fstype=ext3 options=(rw,atime) /dev/sdb1 -> /mnt/stick/, >>
 
375
+
 
376
+allow mounting an ext3 filesystem in /dev/sdb1 on /mnt/stick as read/write and
 
377
+using inode access times. Matches only:
 
378
+
 
379
+=over 4
 
380
+
 
381
+$ mount -o rw,atime /dev/sdb1 /mnt/stick
 
382
+
 
383
+=back
 
384
+
 
385
+=item B<< mount options=(ro, atime) options in (nodev, user) /dev/foo -> /mnt/, >>
 
386
+
 
387
+allow mounting /dev/foo on /mmt/ read only and using inode access times or
 
388
+allow mounting /dev/foo on /mnt/ with some combination of 'nodev' and 'user'.
 
389
+Matches only:
 
390
+
 
391
+=over 4
 
392
+
 
393
+$ mount -o ro,atime /dev/foo /mnt
 
394
+
 
395
+$ mount -o nodev /dev/foo /mnt
 
396
+
 
397
+$ mount -o user /dev/foo /mnt
 
398
+
 
399
+$ mount -o nodev,user /dev/foo /mnt
 
400
+
 
401
+=back
 
402
+
 
403
+=back
 
404
+
 
405
 =head2 Variables
 
406
 
 
407
 AppArmor's policy language allows embedding variables into file rules
 
408
@@ -605,6 +902,29 @@ An example AppArmor profile:
 
409
 
 
410
 =back
 
411
 
 
412
+=head1 KNOWN BUGS
 
413
+
 
414
+=over 4
 
415
+
 
416
+Mount options support the use of pattern matching but mount flags are not
 
417
+correctly intersected against specified patterns. Eg, 'mount options=**,'
 
418
+should be equivalent to 'mount,', but it is not. (LP: #965690)
 
419
+
 
420
+The fstype may not be matched against when certain mount command flags are
 
421
+used. Specifically fstype matching currently only works when creating a new
 
422
+mount and not remount, bind, etc.
 
423
+
 
424
+Mount rules with multiple 'options' conditionals are not applied as documented
 
425
+but instead merged such that 'options in (ro,nodev) options in (atime)' is
 
426
+equivalent to 'options in (ro,nodev,atime)'.
 
427
+
 
428
+When specifying mount options with the 'in' conditional, both the positive and
 
429
+negative values match when specifying one or the other. Eg, 'rw' matches when
 
430
+'ro' is specified and 'dev' matches when 'nodev' is specified such that
 
431
+'options in (ro,nodev)' is equivalent to 'options in (rw,dev)'.
 
432
+
 
433
+=back
 
434
+
 
435
 =head1 SEE ALSO
 
436
 
 
437
 apparmor(7), apparmor_parser(8), aa-complain(1),
 
438
Index: b/utils/aa-exec.pod
 
439
===================================================================
 
440
--- a/utils/aa-exec.pod
 
441
+++ b/utils/aa-exec.pod
 
442
@@ -82,6 +82,8 @@ arguments after the -- are treated as ar
 
443
 useful when passing arguments to the I<E<lt>commandE<gt>> being invoked by
 
444
 aa-exec.
 
445
 
 
446
+=back
 
447
+
 
448
 =head1 BUGS
 
449
 
 
450
 If you find any bugs, please report them at