aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/security/Smack.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/security/Smack.txt')
-rw-r--r--Documentation/security/Smack.txt129
1 files changed, 79 insertions, 50 deletions
diff --git a/Documentation/security/Smack.txt b/Documentation/security/Smack.txt
index b6ef7e9dba30..abc82f85215b 100644
--- a/Documentation/security/Smack.txt
+++ b/Documentation/security/Smack.txt
@@ -33,11 +33,18 @@ The current git repository for Smack user space is:
33 git://github.com/smack-team/smack.git 33 git://github.com/smack-team/smack.git
34 34
35This should make and install on most modern distributions. 35This should make and install on most modern distributions.
36There are three commands included in smackutil: 36There are five commands included in smackutil:
37 37
38smackload - properly formats data for writing to /smack/load
39smackcipso - properly formats data for writing to /smack/cipso
40chsmack - display or set Smack extended attribute values 38chsmack - display or set Smack extended attribute values
39smackctl - load the Smack access rules
40smackaccess - report if a process with one label has access
41 to an object with another
42
43These two commands are obsolete with the introduction of
44the smackfs/load2 and smackfs/cipso2 interfaces.
45
46smackload - properly formats data for writing to smackfs/load
47smackcipso - properly formats data for writing to smackfs/cipso
41 48
42In keeping with the intent of Smack, configuration data is 49In keeping with the intent of Smack, configuration data is
43minimal and not strictly required. The most important 50minimal and not strictly required. The most important
@@ -47,9 +54,9 @@ of this, but it can be manually as well.
47 54
48Add this line to /etc/fstab: 55Add this line to /etc/fstab:
49 56
50 smackfs /smack smackfs smackfsdef=* 0 0 57 smackfs /sys/fs/smackfs smackfs defaults 0 0
51 58
52and create the /smack directory for mounting. 59The /sys/fs/smackfs directory is created by the kernel.
53 60
54Smack uses extended attributes (xattrs) to store labels on filesystem 61Smack uses extended attributes (xattrs) to store labels on filesystem
55objects. The attributes are stored in the extended attribute security 62objects. The attributes are stored in the extended attribute security
@@ -92,13 +99,13 @@ There are multiple ways to set a Smack label on a file:
92 # attr -S -s SMACK64 -V "value" path 99 # attr -S -s SMACK64 -V "value" path
93 # chsmack -a value path 100 # chsmack -a value path
94 101
95A process can see the smack label it is running with by 102A process can see the Smack label it is running with by
96reading /proc/self/attr/current. A process with CAP_MAC_ADMIN 103reading /proc/self/attr/current. A process with CAP_MAC_ADMIN
97can set the process smack by writing there. 104can set the process Smack by writing there.
98 105
99Most Smack configuration is accomplished by writing to files 106Most Smack configuration is accomplished by writing to files
100in the smackfs filesystem. This pseudo-filesystem is usually 107in the smackfs filesystem. This pseudo-filesystem is mounted
101mounted on /smack. 108on /sys/fs/smackfs.
102 109
103access 110access
104 This interface reports whether a subject with the specified 111 This interface reports whether a subject with the specified
@@ -206,23 +213,30 @@ onlycap
206 file or cleared by writing "-" to the file. 213 file or cleared by writing "-" to the file.
207ptrace 214ptrace
208 This is used to define the current ptrace policy 215 This is used to define the current ptrace policy
209 0 - default: this is the policy that relies on smack access rules. 216 0 - default: this is the policy that relies on Smack access rules.
210 For the PTRACE_READ a subject needs to have a read access on 217 For the PTRACE_READ a subject needs to have a read access on
211 object. For the PTRACE_ATTACH a read-write access is required. 218 object. For the PTRACE_ATTACH a read-write access is required.
212 1 - exact: this is the policy that limits PTRACE_ATTACH. Attach is 219 1 - exact: this is the policy that limits PTRACE_ATTACH. Attach is
213 only allowed when subject's and object's labels are equal. 220 only allowed when subject's and object's labels are equal.
214 PTRACE_READ is not affected. Can be overriden with CAP_SYS_PTRACE. 221 PTRACE_READ is not affected. Can be overridden with CAP_SYS_PTRACE.
215 2 - draconian: this policy behaves like the 'exact' above with an 222 2 - draconian: this policy behaves like the 'exact' above with an
216 exception that it can't be overriden with CAP_SYS_PTRACE. 223 exception that it can't be overridden with CAP_SYS_PTRACE.
217revoke-subject 224revoke-subject
218 Writing a Smack label here sets the access to '-' for all access 225 Writing a Smack label here sets the access to '-' for all access
219 rules with that subject label. 226 rules with that subject label.
227unconfined
228 If the kernel is configured with CONFIG_SECURITY_SMACK_BRINGUP
229 a process with CAP_MAC_ADMIN can write a label into this interface.
230 Thereafter, accesses that involve that label will be logged and
231 the access permitted if it wouldn't be otherwise. Note that this
232 is dangerous and can ruin the proper labeling of your system.
233 It should never be used in production.
220 234
221You can add access rules in /etc/smack/accesses. They take the form: 235You can add access rules in /etc/smack/accesses. They take the form:
222 236
223 subjectlabel objectlabel access 237 subjectlabel objectlabel access
224 238
225access is a combination of the letters rwxa which specify the 239access is a combination of the letters rwxatb which specify the
226kind of access permitted a subject with subjectlabel on an 240kind of access permitted a subject with subjectlabel on an
227object with objectlabel. If there is no rule no access is allowed. 241object with objectlabel. If there is no rule no access is allowed.
228 242
@@ -318,8 +332,9 @@ each of the subject and the object.
318 332
319Labels 333Labels
320 334
321Smack labels are ASCII character strings, one to twenty-three characters in 335Smack labels are ASCII character strings. They can be up to 255 characters
322length. Single character labels using special characters, that being anything 336long, but keeping them to twenty-three characters is recommended.
337Single character labels using special characters, that being anything
323other than a letter or digit, are reserved for use by the Smack development 338other than a letter or digit, are reserved for use by the Smack development
324team. Smack labels are unstructured, case sensitive, and the only operation 339team. Smack labels are unstructured, case sensitive, and the only operation
325ever performed on them is comparison for equality. Smack labels cannot 340ever performed on them is comparison for equality. Smack labels cannot
@@ -335,10 +350,9 @@ There are some predefined labels:
335 ? Pronounced "huh", a single question mark character. 350 ? Pronounced "huh", a single question mark character.
336 @ Pronounced "web", a single at sign character. 351 @ Pronounced "web", a single at sign character.
337 352
338Every task on a Smack system is assigned a label. System tasks, such as 353Every task on a Smack system is assigned a label. The Smack label
339init(8) and systems daemons, are run with the floor ("_") label. User tasks 354of a process will usually be assigned by the system initialization
340are assigned labels according to the specification found in the 355mechanism.
341/etc/smack/user configuration file.
342 356
343Access Rules 357Access Rules
344 358
@@ -393,6 +407,7 @@ describe access modes:
393 w: indicates that write access should be granted. 407 w: indicates that write access should be granted.
394 x: indicates that execute access should be granted. 408 x: indicates that execute access should be granted.
395 t: indicates that the rule requests transmutation. 409 t: indicates that the rule requests transmutation.
410 b: indicates that the rule should be reported for bring-up.
396 411
397Uppercase values for the specification letters are allowed as well. 412Uppercase values for the specification letters are allowed as well.
398Access mode specifications can be in any order. Examples of acceptable rules 413Access mode specifications can be in any order. Examples of acceptable rules
@@ -402,6 +417,7 @@ are:
402 Secret Unclass R 417 Secret Unclass R
403 Manager Game x 418 Manager Game x
404 User HR w 419 User HR w
420 Snap Crackle rwxatb
405 New Old rRrRr 421 New Old rRrRr
406 Closed Off - 422 Closed Off -
407 423
@@ -413,7 +429,7 @@ Examples of unacceptable rules are:
413 429
414Spaces are not allowed in labels. Since a subject always has access to files 430Spaces are not allowed in labels. Since a subject always has access to files
415with the same label specifying a rule for that case is pointless. Only 431with the same label specifying a rule for that case is pointless. Only
416valid letters (rwxatRWXAT) and the dash ('-') character are allowed in 432valid letters (rwxatbRWXATB) and the dash ('-') character are allowed in
417access specifications. The dash is a placeholder, so "a-r" is the same 433access specifications. The dash is a placeholder, so "a-r" is the same
418as "ar". A lone dash is used to specify that no access should be allowed. 434as "ar". A lone dash is used to specify that no access should be allowed.
419 435
@@ -462,16 +478,11 @@ receiver. The receiver is not required to have read access to the sender.
462Setting Access Rules 478Setting Access Rules
463 479
464The configuration file /etc/smack/accesses contains the rules to be set at 480The configuration file /etc/smack/accesses contains the rules to be set at
465system startup. The contents are written to the special file /smack/load. 481system startup. The contents are written to the special file
466Rules can be written to /smack/load at any time and take effect immediately. 482/sys/fs/smackfs/load2. Rules can be added at any time and take effect
467For any pair of subject and object labels there can be only one rule, with the 483immediately. For any pair of subject and object labels there can be only
468most recently specified overriding any earlier specification. 484one rule, with the most recently specified overriding any earlier
469 485specification.
470The program smackload is provided to ensure data is formatted
471properly when written to /smack/load. This program reads lines
472of the form
473
474 subjectlabel objectlabel mode.
475 486
476Task Attribute 487Task Attribute
477 488
@@ -488,7 +499,10 @@ only be changed by a process with privilege.
488 499
489Privilege 500Privilege
490 501
491A process with CAP_MAC_OVERRIDE is privileged. 502A process with CAP_MAC_OVERRIDE or CAP_MAC_ADMIN is privileged.
503CAP_MAC_OVERRIDE allows the process access to objects it would
504be denied otherwise. CAP_MAC_ADMIN allows a process to change
505Smack data, including rules and attributes.
492 506
493Smack Networking 507Smack Networking
494 508
@@ -510,14 +524,14 @@ intervention. Unlabeled packets that come into the system will be given the
510ambient label. 524ambient label.
511 525
512Smack requires configuration in the case where packets from a system that is 526Smack requires configuration in the case where packets from a system that is
513not smack that speaks CIPSO may be encountered. Usually this will be a Trusted 527not Smack that speaks CIPSO may be encountered. Usually this will be a Trusted
514Solaris system, but there are other, less widely deployed systems out there. 528Solaris system, but there are other, less widely deployed systems out there.
515CIPSO provides 3 important values, a Domain Of Interpretation (DOI), a level, 529CIPSO provides 3 important values, a Domain Of Interpretation (DOI), a level,
516and a category set with each packet. The DOI is intended to identify a group 530and a category set with each packet. The DOI is intended to identify a group
517of systems that use compatible labeling schemes, and the DOI specified on the 531of systems that use compatible labeling schemes, and the DOI specified on the
518smack system must match that of the remote system or packets will be 532Smack system must match that of the remote system or packets will be
519discarded. The DOI is 3 by default. The value can be read from /smack/doi and 533discarded. The DOI is 3 by default. The value can be read from
520can be changed by writing to /smack/doi. 534/sys/fs/smackfs/doi and can be changed by writing to /sys/fs/smackfs/doi.
521 535
522The label and category set are mapped to a Smack label as defined in 536The label and category set are mapped to a Smack label as defined in
523/etc/smack/cipso. 537/etc/smack/cipso.
@@ -539,15 +553,13 @@ The ":" and "," characters are permitted in a Smack label but have no special
539meaning. 553meaning.
540 554
541The mapping of Smack labels to CIPSO values is defined by writing to 555The mapping of Smack labels to CIPSO values is defined by writing to
542/smack/cipso. Again, the format of data written to this special file 556/sys/fs/smackfs/cipso2.
543is highly restrictive, so the program smackcipso is provided to
544ensure the writes are done properly. This program takes mappings
545on the standard input and sends them to /smack/cipso properly.
546 557
547In addition to explicit mappings Smack supports direct CIPSO mappings. One 558In addition to explicit mappings Smack supports direct CIPSO mappings. One
548CIPSO level is used to indicate that the category set passed in the packet is 559CIPSO level is used to indicate that the category set passed in the packet is
549in fact an encoding of the Smack label. The level used is 250 by default. The 560in fact an encoding of the Smack label. The level used is 250 by default. The
550value can be read from /smack/direct and changed by writing to /smack/direct. 561value can be read from /sys/fs/smackfs/direct and changed by writing to
562/sys/fs/smackfs/direct.
551 563
552Socket Attributes 564Socket Attributes
553 565
@@ -565,8 +577,8 @@ sockets.
565Smack Netlabel Exceptions 577Smack Netlabel Exceptions
566 578
567You will often find that your labeled application has to talk to the outside, 579You will often find that your labeled application has to talk to the outside,
568unlabeled world. To do this there's a special file /smack/netlabel where you can 580unlabeled world. To do this there's a special file /sys/fs/smackfs/netlabel
569add some exceptions in the form of : 581where you can add some exceptions in the form of :
570@IP1 LABEL1 or 582@IP1 LABEL1 or
571@IP2/MASK LABEL2 583@IP2/MASK LABEL2
572 584
@@ -574,22 +586,22 @@ It means that your application will have unlabeled access to @IP1 if it has
574write access on LABEL1, and access to the subnet @IP2/MASK if it has write 586write access on LABEL1, and access to the subnet @IP2/MASK if it has write
575access on LABEL2. 587access on LABEL2.
576 588
577Entries in the /smack/netlabel file are matched by longest mask first, like in 589Entries in the /sys/fs/smackfs/netlabel file are matched by longest mask
578classless IPv4 routing. 590first, like in classless IPv4 routing.
579 591
580A special label '@' and an option '-CIPSO' can be used there : 592A special label '@' and an option '-CIPSO' can be used there :
581@ means Internet, any application with any label has access to it 593@ means Internet, any application with any label has access to it
582-CIPSO means standard CIPSO networking 594-CIPSO means standard CIPSO networking
583 595
584If you don't know what CIPSO is and don't plan to use it, you can just do : 596If you don't know what CIPSO is and don't plan to use it, you can just do :
585echo 127.0.0.1 -CIPSO > /smack/netlabel 597echo 127.0.0.1 -CIPSO > /sys/fs/smackfs/netlabel
586echo 0.0.0.0/0 @ > /smack/netlabel 598echo 0.0.0.0/0 @ > /sys/fs/smackfs/netlabel
587 599
588If you use CIPSO on your 192.168.0.0/16 local network and need also unlabeled 600If you use CIPSO on your 192.168.0.0/16 local network and need also unlabeled
589Internet access, you can have : 601Internet access, you can have :
590echo 127.0.0.1 -CIPSO > /smack/netlabel 602echo 127.0.0.1 -CIPSO > /sys/fs/smackfs/netlabel
591echo 192.168.0.0/16 -CIPSO > /smack/netlabel 603echo 192.168.0.0/16 -CIPSO > /sys/fs/smackfs/netlabel
592echo 0.0.0.0/0 @ > /smack/netlabel 604echo 0.0.0.0/0 @ > /sys/fs/smackfs/netlabel
593 605
594 606
595Writing Applications for Smack 607Writing Applications for Smack
@@ -676,7 +688,7 @@ Smack auditing
676If you want Smack auditing of security events, you need to set CONFIG_AUDIT 688If you want Smack auditing of security events, you need to set CONFIG_AUDIT
677in your kernel configuration. 689in your kernel configuration.
678By default, all denied events will be audited. You can change this behavior by 690By default, all denied events will be audited. You can change this behavior by
679writing a single character to the /smack/logging file : 691writing a single character to the /sys/fs/smackfs/logging file :
6800 : no logging 6920 : no logging
6811 : log denied (default) 6931 : log denied (default)
6822 : log accepted 6942 : log accepted
@@ -686,3 +698,20 @@ Events are logged as 'key=value' pairs, for each event you at least will get
686the subject, the object, the rights requested, the action, the kernel function 698the subject, the object, the rights requested, the action, the kernel function
687that triggered the event, plus other pairs depending on the type of event 699that triggered the event, plus other pairs depending on the type of event
688audited. 700audited.
701
702Bringup Mode
703
704Bringup mode provides logging features that can make application
705configuration and system bringup easier. Configure the kernel with
706CONFIG_SECURITY_SMACK_BRINGUP to enable these features. When bringup
707mode is enabled accesses that succeed due to rules marked with the "b"
708access mode will logged. When a new label is introduced for processes
709rules can be added aggressively, marked with the "b". The logging allows
710tracking of which rules actual get used for that label.
711
712Another feature of bringup mode is the "unconfined" option. Writing
713a label to /sys/fs/smackfs/unconfined makes subjects with that label
714able to access any object, and objects with that label accessible to
715all subjects. Any access that is granted because a label is unconfined
716is logged. This feature is dangerous, as files and directories may
717be created in places they couldn't if the policy were being enforced.