diff options
Diffstat (limited to 'Documentation/security/Smack.txt')
-rw-r--r-- | Documentation/security/Smack.txt | 129 |
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 | ||
35 | This should make and install on most modern distributions. | 35 | This should make and install on most modern distributions. |
36 | There are three commands included in smackutil: | 36 | There are five commands included in smackutil: |
37 | 37 | ||
38 | smackload - properly formats data for writing to /smack/load | ||
39 | smackcipso - properly formats data for writing to /smack/cipso | ||
40 | chsmack - display or set Smack extended attribute values | 38 | chsmack - display or set Smack extended attribute values |
39 | smackctl - load the Smack access rules | ||
40 | smackaccess - report if a process with one label has access | ||
41 | to an object with another | ||
42 | |||
43 | These two commands are obsolete with the introduction of | ||
44 | the smackfs/load2 and smackfs/cipso2 interfaces. | ||
45 | |||
46 | smackload - properly formats data for writing to smackfs/load | ||
47 | smackcipso - properly formats data for writing to smackfs/cipso | ||
41 | 48 | ||
42 | In keeping with the intent of Smack, configuration data is | 49 | In keeping with the intent of Smack, configuration data is |
43 | minimal and not strictly required. The most important | 50 | minimal and not strictly required. The most important |
@@ -47,9 +54,9 @@ of this, but it can be manually as well. | |||
47 | 54 | ||
48 | Add this line to /etc/fstab: | 55 | Add 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 | ||
52 | and create the /smack directory for mounting. | 59 | The /sys/fs/smackfs directory is created by the kernel. |
53 | 60 | ||
54 | Smack uses extended attributes (xattrs) to store labels on filesystem | 61 | Smack uses extended attributes (xattrs) to store labels on filesystem |
55 | objects. The attributes are stored in the extended attribute security | 62 | objects. 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 | ||
95 | A process can see the smack label it is running with by | 102 | A process can see the Smack label it is running with by |
96 | reading /proc/self/attr/current. A process with CAP_MAC_ADMIN | 103 | reading /proc/self/attr/current. A process with CAP_MAC_ADMIN |
97 | can set the process smack by writing there. | 104 | can set the process Smack by writing there. |
98 | 105 | ||
99 | Most Smack configuration is accomplished by writing to files | 106 | Most Smack configuration is accomplished by writing to files |
100 | in the smackfs filesystem. This pseudo-filesystem is usually | 107 | in the smackfs filesystem. This pseudo-filesystem is mounted |
101 | mounted on /smack. | 108 | on /sys/fs/smackfs. |
102 | 109 | ||
103 | access | 110 | access |
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. |
207 | ptrace | 214 | ptrace |
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. |
217 | revoke-subject | 224 | revoke-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. |
227 | unconfined | ||
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 | ||
221 | You can add access rules in /etc/smack/accesses. They take the form: | 235 | You can add access rules in /etc/smack/accesses. They take the form: |
222 | 236 | ||
223 | subjectlabel objectlabel access | 237 | subjectlabel objectlabel access |
224 | 238 | ||
225 | access is a combination of the letters rwxa which specify the | 239 | access is a combination of the letters rwxatb which specify the |
226 | kind of access permitted a subject with subjectlabel on an | 240 | kind of access permitted a subject with subjectlabel on an |
227 | object with objectlabel. If there is no rule no access is allowed. | 241 | object 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 | ||
319 | Labels | 333 | Labels |
320 | 334 | ||
321 | Smack labels are ASCII character strings, one to twenty-three characters in | 335 | Smack labels are ASCII character strings. They can be up to 255 characters |
322 | length. Single character labels using special characters, that being anything | 336 | long, but keeping them to twenty-three characters is recommended. |
337 | Single character labels using special characters, that being anything | ||
323 | other than a letter or digit, are reserved for use by the Smack development | 338 | other than a letter or digit, are reserved for use by the Smack development |
324 | team. Smack labels are unstructured, case sensitive, and the only operation | 339 | team. Smack labels are unstructured, case sensitive, and the only operation |
325 | ever performed on them is comparison for equality. Smack labels cannot | 340 | ever 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 | ||
338 | Every task on a Smack system is assigned a label. System tasks, such as | 353 | Every task on a Smack system is assigned a label. The Smack label |
339 | init(8) and systems daemons, are run with the floor ("_") label. User tasks | 354 | of a process will usually be assigned by the system initialization |
340 | are assigned labels according to the specification found in the | 355 | mechanism. |
341 | /etc/smack/user configuration file. | ||
342 | 356 | ||
343 | Access Rules | 357 | Access 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 | ||
397 | Uppercase values for the specification letters are allowed as well. | 412 | Uppercase values for the specification letters are allowed as well. |
398 | Access mode specifications can be in any order. Examples of acceptable rules | 413 | Access 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 | ||
414 | Spaces are not allowed in labels. Since a subject always has access to files | 430 | Spaces are not allowed in labels. Since a subject always has access to files |
415 | with the same label specifying a rule for that case is pointless. Only | 431 | with the same label specifying a rule for that case is pointless. Only |
416 | valid letters (rwxatRWXAT) and the dash ('-') character are allowed in | 432 | valid letters (rwxatbRWXATB) and the dash ('-') character are allowed in |
417 | access specifications. The dash is a placeholder, so "a-r" is the same | 433 | access specifications. The dash is a placeholder, so "a-r" is the same |
418 | as "ar". A lone dash is used to specify that no access should be allowed. | 434 | as "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. | |||
462 | Setting Access Rules | 478 | Setting Access Rules |
463 | 479 | ||
464 | The configuration file /etc/smack/accesses contains the rules to be set at | 480 | The configuration file /etc/smack/accesses contains the rules to be set at |
465 | system startup. The contents are written to the special file /smack/load. | 481 | system startup. The contents are written to the special file |
466 | Rules 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 |
467 | For any pair of subject and object labels there can be only one rule, with the | 483 | immediately. For any pair of subject and object labels there can be only |
468 | most recently specified overriding any earlier specification. | 484 | one rule, with the most recently specified overriding any earlier |
469 | 485 | specification. | |
470 | The program smackload is provided to ensure data is formatted | ||
471 | properly when written to /smack/load. This program reads lines | ||
472 | of the form | ||
473 | |||
474 | subjectlabel objectlabel mode. | ||
475 | 486 | ||
476 | Task Attribute | 487 | Task Attribute |
477 | 488 | ||
@@ -488,7 +499,10 @@ only be changed by a process with privilege. | |||
488 | 499 | ||
489 | Privilege | 500 | Privilege |
490 | 501 | ||
491 | A process with CAP_MAC_OVERRIDE is privileged. | 502 | A process with CAP_MAC_OVERRIDE or CAP_MAC_ADMIN is privileged. |
503 | CAP_MAC_OVERRIDE allows the process access to objects it would | ||
504 | be denied otherwise. CAP_MAC_ADMIN allows a process to change | ||
505 | Smack data, including rules and attributes. | ||
492 | 506 | ||
493 | Smack Networking | 507 | Smack Networking |
494 | 508 | ||
@@ -510,14 +524,14 @@ intervention. Unlabeled packets that come into the system will be given the | |||
510 | ambient label. | 524 | ambient label. |
511 | 525 | ||
512 | Smack requires configuration in the case where packets from a system that is | 526 | Smack requires configuration in the case where packets from a system that is |
513 | not smack that speaks CIPSO may be encountered. Usually this will be a Trusted | 527 | not Smack that speaks CIPSO may be encountered. Usually this will be a Trusted |
514 | Solaris system, but there are other, less widely deployed systems out there. | 528 | Solaris system, but there are other, less widely deployed systems out there. |
515 | CIPSO provides 3 important values, a Domain Of Interpretation (DOI), a level, | 529 | CIPSO provides 3 important values, a Domain Of Interpretation (DOI), a level, |
516 | and a category set with each packet. The DOI is intended to identify a group | 530 | and a category set with each packet. The DOI is intended to identify a group |
517 | of systems that use compatible labeling schemes, and the DOI specified on the | 531 | of systems that use compatible labeling schemes, and the DOI specified on the |
518 | smack system must match that of the remote system or packets will be | 532 | Smack system must match that of the remote system or packets will be |
519 | discarded. The DOI is 3 by default. The value can be read from /smack/doi and | 533 | discarded. The DOI is 3 by default. The value can be read from |
520 | can 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 | ||
522 | The label and category set are mapped to a Smack label as defined in | 536 | The 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 | |||
539 | meaning. | 553 | meaning. |
540 | 554 | ||
541 | The mapping of Smack labels to CIPSO values is defined by writing to | 555 | The 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. |
543 | is highly restrictive, so the program smackcipso is provided to | ||
544 | ensure the writes are done properly. This program takes mappings | ||
545 | on the standard input and sends them to /smack/cipso properly. | ||
546 | 557 | ||
547 | In addition to explicit mappings Smack supports direct CIPSO mappings. One | 558 | In addition to explicit mappings Smack supports direct CIPSO mappings. One |
548 | CIPSO level is used to indicate that the category set passed in the packet is | 559 | CIPSO level is used to indicate that the category set passed in the packet is |
549 | in fact an encoding of the Smack label. The level used is 250 by default. The | 560 | in fact an encoding of the Smack label. The level used is 250 by default. The |
550 | value can be read from /smack/direct and changed by writing to /smack/direct. | 561 | value can be read from /sys/fs/smackfs/direct and changed by writing to |
562 | /sys/fs/smackfs/direct. | ||
551 | 563 | ||
552 | Socket Attributes | 564 | Socket Attributes |
553 | 565 | ||
@@ -565,8 +577,8 @@ sockets. | |||
565 | Smack Netlabel Exceptions | 577 | Smack Netlabel Exceptions |
566 | 578 | ||
567 | You will often find that your labeled application has to talk to the outside, | 579 | You will often find that your labeled application has to talk to the outside, |
568 | unlabeled world. To do this there's a special file /smack/netlabel where you can | 580 | unlabeled world. To do this there's a special file /sys/fs/smackfs/netlabel |
569 | add some exceptions in the form of : | 581 | where 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 | |||
574 | write access on LABEL1, and access to the subnet @IP2/MASK if it has write | 586 | write access on LABEL1, and access to the subnet @IP2/MASK if it has write |
575 | access on LABEL2. | 587 | access on LABEL2. |
576 | 588 | ||
577 | Entries in the /smack/netlabel file are matched by longest mask first, like in | 589 | Entries in the /sys/fs/smackfs/netlabel file are matched by longest mask |
578 | classless IPv4 routing. | 590 | first, like in classless IPv4 routing. |
579 | 591 | ||
580 | A special label '@' and an option '-CIPSO' can be used there : | 592 | A 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 | ||
584 | If you don't know what CIPSO is and don't plan to use it, you can just do : | 596 | If you don't know what CIPSO is and don't plan to use it, you can just do : |
585 | echo 127.0.0.1 -CIPSO > /smack/netlabel | 597 | echo 127.0.0.1 -CIPSO > /sys/fs/smackfs/netlabel |
586 | echo 0.0.0.0/0 @ > /smack/netlabel | 598 | echo 0.0.0.0/0 @ > /sys/fs/smackfs/netlabel |
587 | 599 | ||
588 | If you use CIPSO on your 192.168.0.0/16 local network and need also unlabeled | 600 | If you use CIPSO on your 192.168.0.0/16 local network and need also unlabeled |
589 | Internet access, you can have : | 601 | Internet access, you can have : |
590 | echo 127.0.0.1 -CIPSO > /smack/netlabel | 602 | echo 127.0.0.1 -CIPSO > /sys/fs/smackfs/netlabel |
591 | echo 192.168.0.0/16 -CIPSO > /smack/netlabel | 603 | echo 192.168.0.0/16 -CIPSO > /sys/fs/smackfs/netlabel |
592 | echo 0.0.0.0/0 @ > /smack/netlabel | 604 | echo 0.0.0.0/0 @ > /sys/fs/smackfs/netlabel |
593 | 605 | ||
594 | 606 | ||
595 | Writing Applications for Smack | 607 | Writing Applications for Smack |
@@ -676,7 +688,7 @@ Smack auditing | |||
676 | If you want Smack auditing of security events, you need to set CONFIG_AUDIT | 688 | If you want Smack auditing of security events, you need to set CONFIG_AUDIT |
677 | in your kernel configuration. | 689 | in your kernel configuration. |
678 | By default, all denied events will be audited. You can change this behavior by | 690 | By default, all denied events will be audited. You can change this behavior by |
679 | writing a single character to the /smack/logging file : | 691 | writing a single character to the /sys/fs/smackfs/logging file : |
680 | 0 : no logging | 692 | 0 : no logging |
681 | 1 : log denied (default) | 693 | 1 : log denied (default) |
682 | 2 : log accepted | 694 | 2 : log accepted |
@@ -686,3 +698,20 @@ Events are logged as 'key=value' pairs, for each event you at least will get | |||
686 | the subject, the object, the rights requested, the action, the kernel function | 698 | the subject, the object, the rights requested, the action, the kernel function |
687 | that triggered the event, plus other pairs depending on the type of event | 699 | that triggered the event, plus other pairs depending on the type of event |
688 | audited. | 700 | audited. |
701 | |||
702 | Bringup Mode | ||
703 | |||
704 | Bringup mode provides logging features that can make application | ||
705 | configuration and system bringup easier. Configure the kernel with | ||
706 | CONFIG_SECURITY_SMACK_BRINGUP to enable these features. When bringup | ||
707 | mode is enabled accesses that succeed due to rules marked with the "b" | ||
708 | access mode will logged. When a new label is introduced for processes | ||
709 | rules can be added aggressively, marked with the "b". The logging allows | ||
710 | tracking of which rules actual get used for that label. | ||
711 | |||
712 | Another feature of bringup mode is the "unconfined" option. Writing | ||
713 | a label to /sys/fs/smackfs/unconfined makes subjects with that label | ||
714 | able to access any object, and objects with that label accessible to | ||
715 | all subjects. Any access that is granted because a label is unconfined | ||
716 | is logged. This feature is dangerous, as files and directories may | ||
717 | be created in places they couldn't if the policy were being enforced. | ||