blob: a561de1f01e96d5d4e4e5d6f3f104f25640fa148 [file] [log] [blame]
Stephen Smalley2dd4e512012-01-04 12:33:27 -05001#################################################
2# MLS policy constraints
3#
4
5#
6# Process constraints
7#
8
9# Process transition: Require equivalence unless the subject is trusted.
10mlsconstrain process { transition dyntransition }
11 ((h1 eq h2 and l1 eq l2) or t1 == mlstrustedsubject);
12
13# Process read operations: No read up unless trusted.
14mlsconstrain process { getsched getsession getpgid getcap getattr ptrace share }
15 (l1 dom l2 or t1 == mlstrustedsubject);
16
Stephen Smalley025b7df2015-03-13 17:07:39 -040017# Process write operations: Require equivalence unless trusted.
Stephen Smalley2dd4e512012-01-04 12:33:27 -050018mlsconstrain process { sigkill sigstop signal setsched setpgid setcap setrlimit ptrace share }
Stephen Smalley025b7df2015-03-13 17:07:39 -040019 (l1 eq l2 or t1 == mlstrustedsubject);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050020
21#
22# Socket constraints
23#
24
Stephen Smalleye8848722012-11-13 13:00:05 -050025# Create/relabel operations: Subject must be equivalent to object unless
26# the subject is trusted. Sockets inherit the range of their creator.
27mlsconstrain socket_class_set { create relabelfrom relabelto }
28 ((h1 eq h2 and l1 eq l2) or t1 == mlstrustedsubject);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050029
Stephen Smalley025b7df2015-03-13 17:07:39 -040030# Datagram send: Sender must be equivalent to the receiver unless one of them
31# is trusted.
Stephen Smalley2dd4e512012-01-04 12:33:27 -050032mlsconstrain unix_dgram_socket { sendto }
Stephen Smalley025b7df2015-03-13 17:07:39 -040033 (l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedsubject);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050034
35# Stream connect: Client must be equivalent to server unless one of them
36# is trusted.
37mlsconstrain 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.
47mlsconstrain dir_file_class_set { create relabelfrom relabelto }
48 (l2 eq h2 and (l1 eq l2 or t1 == mlstrustedsubject));
49
dcashman60cfe792015-03-04 09:50:34 -080050#
51# Constraints for app data files only.
52#
53
54# Only constrain open, not read/write.
55# Also constrain other forms of manipulation, e.g. chmod/chown, unlink, rename, etc.
56# Subject must be equivalent to object unless the subject is trusted.
57mlsconstrain dir { open search setattr rename add_name remove_name reparent rmdir }
58 (t2 != app_data_file or l1 eq l2 or t1 == mlstrustedsubject);
59mlsconstrain { file lnk_file sock_file } { open setattr unlink link rename }
60 (t2 != app_data_file or l1 eq l2 or t1 == mlstrustedsubject);
61
62#
63# Constraints for file types other than app data files.
64#
65
Stephen Smalley2dd4e512012-01-04 12:33:27 -050066# Read operations: Subject must dominate object unless the subject
67# or the object is trusted.
68mlsconstrain dir { read getattr search }
dcashman60cfe792015-03-04 09:50:34 -080069 (t2 == app_data_file or l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050070
dcashman60cfe792015-03-04 09:50:34 -080071mlsconstrain { file lnk_file sock_file chr_file blk_file } { read getattr execute }
72 (t2 == app_data_file or l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050073
Stephen Smalley025b7df2015-03-13 17:07:39 -040074# Write operations: Subject must be equivalent to the object unless the
Stephen Smalley2dd4e512012-01-04 12:33:27 -050075# subject or the object is trusted.
76mlsconstrain dir { write setattr rename add_name remove_name reparent rmdir }
Stephen Smalley025b7df2015-03-13 17:07:39 -040077 (t2 == app_data_file or l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050078
79mlsconstrain { file lnk_file sock_file chr_file blk_file } { write setattr append unlink link rename }
Stephen Smalley025b7df2015-03-13 17:07:39 -040080 (t2 == app_data_file or l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050081
82# Special case for FIFOs.
83# These can be unnamed pipes, in which case they will be labeled with the
84# creating process' label. Thus we also have an exemption when the "object"
Stephen Smalley7d1b6c82015-02-20 12:30:31 -050085# is a domain type, so that processes can communicate via unnamed pipes
86# passed by binder or local socket IPC.
Stephen Smalley2dd4e512012-01-04 12:33:27 -050087mlsconstrain fifo_file { read getattr }
Stephen Smalley7d1b6c82015-02-20 12:30:31 -050088 (l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject or t2 == domain);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050089
90mlsconstrain fifo_file { write setattr append unlink link rename }
Stephen Smalley025b7df2015-03-13 17:07:39 -040091 (l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject or t2 == domain);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050092
93#
94# Binder IPC constraints
95#
96# Presently commented out, as apps are expected to call one another.
97# This would only make sense if apps were assigned categories
98# based on allowable communications rather than per-app categories.
99#mlsconstrain binder call
100# (l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedsubject);