blob: 421b04628b6f0860202167e93dfc149f25f3bf59 [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.
Jeff Vander Stoep3aa7ca52018-04-03 11:22:38 -070056# Subject must dominate object unless the subject is trusted.
dcashman60cfe792015-03-04 09:50:34 -080057mlsconstrain dir { open search setattr rename add_name remove_name reparent rmdir }
Nick Kralevich23c9d912018-08-02 15:54:23 -070058 ( (t2 != app_data_file and t2 != privapp_data_file ) or l1 dom l2 or t1 == mlstrustedsubject);
Jeff Vander Stoepbed2e162019-01-24 09:48:57 -080059mlsconstrain { file sock_file } { open setattr unlink link rename }
ji, zhenlong zfdfa42b2018-10-19 13:21:52 +080060 ( (t2 != app_data_file and t2 != privapp_data_file and t2 != priv_app_tmpfs) or l1 dom l2 or t1 == mlstrustedsubject);
Jeff Vander Stoepbed2e162019-01-24 09:48:57 -080061# For symlinks in app_data_file, require equivalence in order to manipulate or follow (read).
62mlsconstrain { lnk_file } { open setattr unlink link rename read }
63 ( (t2 != app_data_file) or l1 eq l2 or t1 == mlstrustedsubject);
64# For priv_app_data_file, continue to use dominance for symlinks because dynamite relies on this.
65# TODO: Migrate to equivalence when it's no longer needed.
66mlsconstrain { lnk_file } { open setattr unlink link rename read }
67 ( (t2 != privapp_data_file and t2 != priv_app_tmpfs) or l1 dom l2 or t1 == mlstrustedsubject);
dcashman60cfe792015-03-04 09:50:34 -080068
69#
70# Constraints for file types other than app data files.
71#
72
Stephen Smalley2dd4e512012-01-04 12:33:27 -050073# Read operations: Subject must dominate object unless the subject
74# or the object is trusted.
75mlsconstrain dir { read getattr search }
Nick Kralevich23c9d912018-08-02 15:54:23 -070076 (t2 == app_data_file or t2 == privapp_data_file or l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050077
dcashman60cfe792015-03-04 09:50:34 -080078mlsconstrain { file lnk_file sock_file chr_file blk_file } { read getattr execute }
ji, zhenlong zfdfa42b2018-10-19 13:21:52 +080079 (t2 == app_data_file or t2 == privapp_data_file or t2 == priv_app_tmpfs or l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050080
Stephen Smalley025b7df2015-03-13 17:07:39 -040081# Write operations: Subject must be equivalent to the object unless the
Stephen Smalley2dd4e512012-01-04 12:33:27 -050082# subject or the object is trusted.
83mlsconstrain dir { write setattr rename add_name remove_name reparent rmdir }
Nick Kralevich23c9d912018-08-02 15:54:23 -070084 (t2 == app_data_file or t2 == privapp_data_file or l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050085
86mlsconstrain { file lnk_file sock_file chr_file blk_file } { write setattr append unlink link rename }
ji, zhenlong zfdfa42b2018-10-19 13:21:52 +080087 (t2 == app_data_file or t2 == privapp_data_file or t2 == priv_app_tmpfs or l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050088
89# Special case for FIFOs.
90# These can be unnamed pipes, in which case they will be labeled with the
91# creating process' label. Thus we also have an exemption when the "object"
Stephen Smalley7d1b6c82015-02-20 12:30:31 -050092# is a domain type, so that processes can communicate via unnamed pipes
93# passed by binder or local socket IPC.
Stephen Smalley2dd4e512012-01-04 12:33:27 -050094mlsconstrain fifo_file { read getattr }
Stephen Smalley7d1b6c82015-02-20 12:30:31 -050095 (l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject or t2 == domain);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050096
97mlsconstrain fifo_file { write setattr append unlink link rename }
Stephen Smalley025b7df2015-03-13 17:07:39 -040098 (l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject or t2 == domain);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050099
100#
101# Binder IPC constraints
102#
103# Presently commented out, as apps are expected to call one another.
104# This would only make sense if apps were assigned categories
105# based on allowable communications rather than per-app categories.
106#mlsconstrain binder call
107# (l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedsubject);