blob: 1588a13e4d12dbd6d21e345f6fadc5f21b19bee4 [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.
Alan Stokes9443b2e2020-07-16 10:42:58 +010057mlsconstrain dir { open search getattr 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 Stokes8bf8a262020-11-16 18:10:33 +000077 (t2 == app_data_file_type or l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject
Alan Stokes7aa40412020-12-04 14:07:52 +000078 or (t1 == mlsvendorcompat and (t2 == system_data_file or t2 == user_profile_root_file) ) );
Stephen Smalley2dd4e512012-01-04 12:33:27 -050079
dcashman60cfe792015-03-04 09:50:34 -080080mlsconstrain { file lnk_file sock_file chr_file blk_file } { read getattr execute }
Alan Stokesc5773a92020-11-09 16:53:01 +000081 (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 -050082
Stephen Smalley025b7df2015-03-13 17:07:39 -040083# Write operations: Subject must be equivalent to the object unless the
Stephen Smalley2dd4e512012-01-04 12:33:27 -050084# subject or the object is trusted.
85mlsconstrain dir { write setattr rename add_name remove_name reparent rmdir }
Alan Stokesc5773a92020-11-09 16:53:01 +000086 (t2 == app_data_file_type or l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050087
88mlsconstrain { file lnk_file sock_file chr_file blk_file } { write setattr append unlink link rename }
Alan Stokesc5773a92020-11-09 16:53:01 +000089 (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 -050090
91# Special case for FIFOs.
92# These can be unnamed pipes, in which case they will be labeled with the
93# creating process' label. Thus we also have an exemption when the "object"
Stephen Smalley7d1b6c82015-02-20 12:30:31 -050094# is a domain type, so that processes can communicate via unnamed pipes
95# passed by binder or local socket IPC.
Stephen Smalley2dd4e512012-01-04 12:33:27 -050096mlsconstrain fifo_file { read getattr }
Stephen Smalley7d1b6c82015-02-20 12:30:31 -050097 (l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject or t2 == domain);
Stephen Smalley2dd4e512012-01-04 12:33:27 -050098
99mlsconstrain fifo_file { write setattr append unlink link rename }
Stephen Smalley025b7df2015-03-13 17:07:39 -0400100 (l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject or t2 == domain);
Stephen Smalley2dd4e512012-01-04 12:33:27 -0500101
102#
103# Binder IPC constraints
104#
105# Presently commented out, as apps are expected to call one another.
106# This would only make sense if apps were assigned categories
107# based on allowable communications rather than per-app categories.
108#mlsconstrain binder call
109# (l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedsubject);