blob: 593b3162dd953631d13cb1be7cf6170b387034fb [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
Alan Stokesc5773a92020-11-09 16:53:01 +000054# Only constrain open, not read/write, so already open fds can be used.
dcashman60cfe792015-03-04 09:50:34 -080055# 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 }
Alan Stokesc5773a92020-11-09 16:53:01 +000058 (t2 != app_data_file_type or l1 dom l2 or t1 == mlstrustedsubject);
Jeff Vander Stoepbed2e162019-01-24 09:48:57 -080059mlsconstrain { file sock_file } { open setattr unlink link rename }
Alan Stokesc5773a92020-11-09 16:53:01 +000060 ( (t2 != app_data_file_type and t2 != appdomain_tmpfs) or l1 dom l2 or t1 == mlstrustedsubject);
61
62# For symlinks in app data files, require equivalence in order to manipulate or follow (read).
Jeff Vander Stoepbed2e162019-01-24 09:48:57 -080063mlsconstrain { lnk_file } { open setattr unlink link rename read }
Alan Stokesc5773a92020-11-09 16:53:01 +000064 ( (t2 != app_data_file_type or t2 == privapp_data_file) or l1 eq l2 or t1 == mlstrustedsubject);
65# But for priv_app_data_file, continue to use dominance for symlinks because dynamite relies on this.
Jeff Vander Stoepbed2e162019-01-24 09:48:57 -080066# TODO: Migrate to equivalence when it's no longer needed.
67mlsconstrain { lnk_file } { open setattr unlink link rename read }
Jeff Vander Stoep9f5d0d92019-01-29 14:43:45 -080068 ( (t2 != privapp_data_file and t2 != appdomain_tmpfs) or l1 dom l2 or t1 == mlstrustedsubject);
dcashman60cfe792015-03-04 09:50:34 -080069
70#
71# Constraints for file types other than app data files.
72#
73
Stephen Smalley2dd4e512012-01-04 12:33:27 -050074# Read operations: Subject must dominate object unless the subject
75# or the object is trusted.
76mlsconstrain dir { read getattr search }
Alan Stokesc5773a92020-11-09 16:53:01 +000077 (t2 == app_data_file_type or l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050078
dcashman60cfe792015-03-04 09:50:34 -080079mlsconstrain { file lnk_file sock_file chr_file blk_file } { read getattr execute }
Alan Stokesc5773a92020-11-09 16:53:01 +000080 (t2 == app_data_file_type or t2 == appdomain_tmpfs or l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050081
Stephen Smalley025b7df2015-03-13 17:07:39 -040082# Write operations: Subject must be equivalent to the object unless the
Stephen Smalley2dd4e512012-01-04 12:33:27 -050083# subject or the object is trusted.
84mlsconstrain dir { write setattr rename add_name remove_name reparent rmdir }
Alan Stokesc5773a92020-11-09 16:53:01 +000085 (t2 == app_data_file_type or l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050086
87mlsconstrain { file lnk_file sock_file chr_file blk_file } { write setattr append unlink link rename }
Alan Stokesc5773a92020-11-09 16:53:01 +000088 (t2 == app_data_file_type or t2 == appdomain_tmpfs or l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050089
90# Special case for FIFOs.
91# These can be unnamed pipes, in which case they will be labeled with the
92# creating process' label. Thus we also have an exemption when the "object"
Stephen Smalley7d1b6c82015-02-20 12:30:31 -050093# is a domain type, so that processes can communicate via unnamed pipes
94# passed by binder or local socket IPC.
Stephen Smalley2dd4e512012-01-04 12:33:27 -050095mlsconstrain fifo_file { read getattr }
Stephen Smalley7d1b6c82015-02-20 12:30:31 -050096 (l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject or t2 == domain);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050097
98mlsconstrain fifo_file { write setattr append unlink link rename }
Stephen Smalley025b7df2015-03-13 17:07:39 -040099 (l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject or t2 == domain);
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500100
101#
102# Binder IPC constraints
103#
104# Presently commented out, as apps are expected to call one another.
105# This would only make sense if apps were assigned categories
106# based on allowable communications rather than per-app categories.
107#mlsconstrain binder call
108# (l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedsubject);