Inseob Kim | ff43be2 | 2021-06-07 16:56:56 +0900 | [diff] [blame] | 1 | ################################################# |
| 2 | # MLS policy constraints |
| 3 | # |
| 4 | |
| 5 | # |
| 6 | # Process constraints |
| 7 | # |
| 8 | |
| 9 | # Process transition: Require equivalence unless the subject is trusted. |
| 10 | mlsconstrain process { transition dyntransition } |
| 11 | ((h1 eq h2 and l1 eq l2) or t1 == mlstrustedsubject); |
| 12 | |
| 13 | # Process read operations: No read up unless trusted. |
| 14 | mlsconstrain process { getsched getsession getpgid getcap getattr ptrace share } |
| 15 | (l1 dom l2 or t1 == mlstrustedsubject); |
| 16 | |
| 17 | # Process write operations: Require equivalence unless trusted. |
| 18 | mlsconstrain process { sigkill sigstop signal setsched setpgid setcap setrlimit ptrace share } |
| 19 | (l1 eq l2 or t1 == mlstrustedsubject); |
| 20 | |
| 21 | # |
| 22 | # Socket constraints |
| 23 | # |
| 24 | |
| 25 | # Create/relabel operations: Subject must be equivalent to object unless |
| 26 | # the subject is trusted. Sockets inherit the range of their creator. |
| 27 | mlsconstrain socket_class_set { create relabelfrom relabelto } |
| 28 | ((h1 eq h2 and l1 eq l2) or t1 == mlstrustedsubject); |
| 29 | |
| 30 | # Datagram send: Sender must be equivalent to the receiver unless one of them |
| 31 | # is trusted. |
| 32 | mlsconstrain unix_dgram_socket { sendto } |
| 33 | (l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedsubject); |
| 34 | |
| 35 | # Stream connect: Client must be equivalent to server unless one of them |
| 36 | # is trusted. |
| 37 | mlsconstrain unix_stream_socket { connectto } |
| 38 | (l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedsubject); |
| 39 | |
| 40 | # |
| 41 | # Directory/file constraints |
| 42 | # |
| 43 | |
| 44 | # Create/relabel operations: Subject must be equivalent to object unless |
| 45 | # the subject is trusted. Also, files should always be single-level. |
| 46 | # Do NOT exempt mlstrustedobject types from this constraint. |
| 47 | mlsconstrain dir_file_class_set { create relabelfrom relabelto } |
| 48 | (l2 eq h2 and (l1 eq l2 or t1 == mlstrustedsubject)); |
| 49 | |
| 50 | # |
Inseob Kim | ff43be2 | 2021-06-07 16:56:56 +0900 | [diff] [blame] | 51 | # Constraints for file types other than app data files. |
| 52 | # |
| 53 | |
| 54 | # Read operations: Subject must dominate object unless the subject |
| 55 | # or the object is trusted. |
| 56 | mlsconstrain dir { read getattr search } |
Inseob Kim | 4eb5660 | 2021-07-09 15:51:12 +0900 | [diff] [blame^] | 57 | (l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject |
| 58 | or (t1 == mlsvendorcompat and t2 == system_data_file) ); |
Inseob Kim | ff43be2 | 2021-06-07 16:56:56 +0900 | [diff] [blame] | 59 | |
| 60 | mlsconstrain { file lnk_file sock_file chr_file blk_file } { read getattr execute } |
Inseob Kim | 4eb5660 | 2021-07-09 15:51:12 +0900 | [diff] [blame^] | 61 | (l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject); |
Inseob Kim | ff43be2 | 2021-06-07 16:56:56 +0900 | [diff] [blame] | 62 | |
| 63 | # Write operations: Subject must be equivalent to the object unless the |
| 64 | # subject or the object is trusted. |
| 65 | mlsconstrain dir { write setattr rename add_name remove_name reparent rmdir } |
Inseob Kim | 4eb5660 | 2021-07-09 15:51:12 +0900 | [diff] [blame^] | 66 | (l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject); |
Inseob Kim | ff43be2 | 2021-06-07 16:56:56 +0900 | [diff] [blame] | 67 | |
| 68 | mlsconstrain { file lnk_file sock_file chr_file blk_file } { write setattr append unlink link rename } |
Inseob Kim | 4eb5660 | 2021-07-09 15:51:12 +0900 | [diff] [blame^] | 69 | (l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject); |
Inseob Kim | ff43be2 | 2021-06-07 16:56:56 +0900 | [diff] [blame] | 70 | |
| 71 | # Special case for FIFOs. |
| 72 | # These can be unnamed pipes, in which case they will be labeled with the |
| 73 | # creating process' label. Thus we also have an exemption when the "object" |
| 74 | # is a domain type, so that processes can communicate via unnamed pipes |
| 75 | # passed by binder or local socket IPC. |
| 76 | mlsconstrain fifo_file { read getattr } |
| 77 | (l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject or t2 == domain); |
| 78 | |
| 79 | mlsconstrain fifo_file { write setattr append unlink link rename } |
| 80 | (l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject or t2 == domain); |
| 81 | |
| 82 | # |
| 83 | # Binder IPC constraints |
| 84 | # |
| 85 | # Presently commented out, as apps are expected to call one another. |
| 86 | # This would only make sense if apps were assigned categories |
| 87 | # based on allowable communications rather than per-app categories. |
| 88 | #mlsconstrain binder call |
| 89 | # (l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedsubject); |