2012-01-04 18:33:27 +01:00
|
|
|
#################################################
|
|
|
|
# MLS policy constraints
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# Process constraints
|
|
|
|
#
|
|
|
|
|
|
|
|
# Process transition: Require equivalence unless the subject is trusted.
|
|
|
|
mlsconstrain process { transition dyntransition }
|
|
|
|
((h1 eq h2 and l1 eq l2) or t1 == mlstrustedsubject);
|
|
|
|
|
|
|
|
# Process read operations: No read up unless trusted.
|
|
|
|
mlsconstrain process { getsched getsession getpgid getcap getattr ptrace share }
|
|
|
|
(l1 dom l2 or t1 == mlstrustedsubject);
|
|
|
|
|
2015-03-13 22:07:39 +01:00
|
|
|
# Process write operations: Require equivalence unless trusted.
|
2012-01-04 18:33:27 +01:00
|
|
|
mlsconstrain process { sigkill sigstop signal setsched setpgid setcap setrlimit ptrace share }
|
2015-03-13 22:07:39 +01:00
|
|
|
(l1 eq l2 or t1 == mlstrustedsubject);
|
2012-01-04 18:33:27 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Socket constraints
|
|
|
|
#
|
|
|
|
|
2012-11-13 19:00:05 +01:00
|
|
|
# Create/relabel operations: Subject must be equivalent to object unless
|
|
|
|
# the subject is trusted. Sockets inherit the range of their creator.
|
|
|
|
mlsconstrain socket_class_set { create relabelfrom relabelto }
|
|
|
|
((h1 eq h2 and l1 eq l2) or t1 == mlstrustedsubject);
|
2012-01-04 18:33:27 +01:00
|
|
|
|
2015-03-13 22:07:39 +01:00
|
|
|
# Datagram send: Sender must be equivalent to the receiver unless one of them
|
|
|
|
# is trusted.
|
2012-01-04 18:33:27 +01:00
|
|
|
mlsconstrain unix_dgram_socket { sendto }
|
2015-03-13 22:07:39 +01:00
|
|
|
(l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedsubject);
|
2012-01-04 18:33:27 +01:00
|
|
|
|
|
|
|
# Stream connect: Client must be equivalent to server unless one of them
|
|
|
|
# is trusted.
|
|
|
|
mlsconstrain unix_stream_socket { connectto }
|
|
|
|
(l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedsubject);
|
|
|
|
|
|
|
|
#
|
|
|
|
# Directory/file constraints
|
|
|
|
#
|
|
|
|
|
|
|
|
# Create/relabel operations: Subject must be equivalent to object unless
|
|
|
|
# the subject is trusted. Also, files should always be single-level.
|
|
|
|
# Do NOT exempt mlstrustedobject types from this constraint.
|
|
|
|
mlsconstrain dir_file_class_set { create relabelfrom relabelto }
|
|
|
|
(l2 eq h2 and (l1 eq l2 or t1 == mlstrustedsubject));
|
|
|
|
|
2015-03-04 18:50:34 +01:00
|
|
|
#
|
|
|
|
# Constraints for app data files only.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Only constrain open, not read/write.
|
|
|
|
# Also constrain other forms of manipulation, e.g. chmod/chown, unlink, rename, etc.
|
Enforce per-app data protections for targetSdk 28+
Adds per-app categories to untrusted app domains and their
app data types. Per-app categories are in addition to the
existing per-user categories.
Apps targeting sdk version 28+ will now have the following
characteristics:
Domain: u:r:untrusted_app:s0:c[0-9]+,c[0-9]+,c[0-9],c[0-9]
Data context: u:object_r:app_data_file:s0:c[0-9]+,c[0-9]+,c[0-9],c[0-9]
Whereas apps targeting 27- will look like:
Domain: u:r:untrusted_app_27:s0:c[0-9]+,c[0-9]+
Data context: u:object_r:app_data_file:s0:c[0-9]+,c[0-9]+
To ensure backwards compatibility with previous SDK versions,
the levelFrom=all now enforces categories by dominance instead of
equality. Apps with per-app and per-user categories will continue
to have selinux permissions (but not necessarily unix permissions)
to access app data with only per-user categories, but apps with only
per-user categories will not be able to access the data of apps with
both per-app and per-user categories.
Bug: 63897054
Test: Boot sailfish, run apps, verify no new selinux denials.
Test: cts-tradefed run cts -m CtsSelinuxTargetSdkCurrentTestCases
Test: cts-tradefed run cts -m CtsSelinuxTargetSdk27TestCases
Test: cts-tradefed run cts -m CtsSelinuxTargetSdk25TestCases
Test: adb sideload an OTA and verify that files are correctly labeled.
Change-Id: I64b013874fe87b55f47e817a1279e76ecf86b7c0
2017-12-18 05:55:12 +01:00
|
|
|
# Subject must dominate object unless the subject is trusted.
|
2015-03-04 18:50:34 +01:00
|
|
|
mlsconstrain dir { open search setattr rename add_name remove_name reparent rmdir }
|
Enforce per-app data protections for targetSdk 28+
Adds per-app categories to untrusted app domains and their
app data types. Per-app categories are in addition to the
existing per-user categories.
Apps targeting sdk version 28+ will now have the following
characteristics:
Domain: u:r:untrusted_app:s0:c[0-9]+,c[0-9]+,c[0-9],c[0-9]
Data context: u:object_r:app_data_file:s0:c[0-9]+,c[0-9]+,c[0-9],c[0-9]
Whereas apps targeting 27- will look like:
Domain: u:r:untrusted_app_27:s0:c[0-9]+,c[0-9]+
Data context: u:object_r:app_data_file:s0:c[0-9]+,c[0-9]+
To ensure backwards compatibility with previous SDK versions,
the levelFrom=all now enforces categories by dominance instead of
equality. Apps with per-app and per-user categories will continue
to have selinux permissions (but not necessarily unix permissions)
to access app data with only per-user categories, but apps with only
per-user categories will not be able to access the data of apps with
both per-app and per-user categories.
Bug: 63897054
Test: Boot sailfish, run apps, verify no new selinux denials.
Test: cts-tradefed run cts -m CtsSelinuxTargetSdkCurrentTestCases
Test: cts-tradefed run cts -m CtsSelinuxTargetSdk27TestCases
Test: cts-tradefed run cts -m CtsSelinuxTargetSdk25TestCases
Test: adb sideload an OTA and verify that files are correctly labeled.
Change-Id: I64b013874fe87b55f47e817a1279e76ecf86b7c0
2017-12-18 05:55:12 +01:00
|
|
|
(t2 != app_data_file or l1 dom l2 or t1 == mlstrustedsubject);
|
2015-03-04 18:50:34 +01:00
|
|
|
mlsconstrain { file lnk_file sock_file } { open setattr unlink link rename }
|
Enforce per-app data protections for targetSdk 28+
Adds per-app categories to untrusted app domains and their
app data types. Per-app categories are in addition to the
existing per-user categories.
Apps targeting sdk version 28+ will now have the following
characteristics:
Domain: u:r:untrusted_app:s0:c[0-9]+,c[0-9]+,c[0-9],c[0-9]
Data context: u:object_r:app_data_file:s0:c[0-9]+,c[0-9]+,c[0-9],c[0-9]
Whereas apps targeting 27- will look like:
Domain: u:r:untrusted_app_27:s0:c[0-9]+,c[0-9]+
Data context: u:object_r:app_data_file:s0:c[0-9]+,c[0-9]+
To ensure backwards compatibility with previous SDK versions,
the levelFrom=all now enforces categories by dominance instead of
equality. Apps with per-app and per-user categories will continue
to have selinux permissions (but not necessarily unix permissions)
to access app data with only per-user categories, but apps with only
per-user categories will not be able to access the data of apps with
both per-app and per-user categories.
Bug: 63897054
Test: Boot sailfish, run apps, verify no new selinux denials.
Test: cts-tradefed run cts -m CtsSelinuxTargetSdkCurrentTestCases
Test: cts-tradefed run cts -m CtsSelinuxTargetSdk27TestCases
Test: cts-tradefed run cts -m CtsSelinuxTargetSdk25TestCases
Test: adb sideload an OTA and verify that files are correctly labeled.
Change-Id: I64b013874fe87b55f47e817a1279e76ecf86b7c0
2017-12-18 05:55:12 +01:00
|
|
|
(t2 != app_data_file or l1 dom l2 or t1 == mlstrustedsubject);
|
2015-03-04 18:50:34 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Constraints for file types other than app data files.
|
|
|
|
#
|
|
|
|
|
2012-01-04 18:33:27 +01:00
|
|
|
# Read operations: Subject must dominate object unless the subject
|
|
|
|
# or the object is trusted.
|
|
|
|
mlsconstrain dir { read getattr search }
|
2015-03-04 18:50:34 +01:00
|
|
|
(t2 == app_data_file or l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject);
|
2012-01-04 18:33:27 +01:00
|
|
|
|
2015-03-04 18:50:34 +01:00
|
|
|
mlsconstrain { file lnk_file sock_file chr_file blk_file } { read getattr execute }
|
|
|
|
(t2 == app_data_file or l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject);
|
2012-01-04 18:33:27 +01:00
|
|
|
|
2015-03-13 22:07:39 +01:00
|
|
|
# Write operations: Subject must be equivalent to the object unless the
|
2012-01-04 18:33:27 +01:00
|
|
|
# subject or the object is trusted.
|
|
|
|
mlsconstrain dir { write setattr rename add_name remove_name reparent rmdir }
|
2015-03-13 22:07:39 +01:00
|
|
|
(t2 == app_data_file or l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject);
|
2012-01-04 18:33:27 +01:00
|
|
|
|
|
|
|
mlsconstrain { file lnk_file sock_file chr_file blk_file } { write setattr append unlink link rename }
|
2015-03-13 22:07:39 +01:00
|
|
|
(t2 == app_data_file or l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject);
|
2012-01-04 18:33:27 +01:00
|
|
|
|
|
|
|
# Special case for FIFOs.
|
|
|
|
# These can be unnamed pipes, in which case they will be labeled with the
|
|
|
|
# creating process' label. Thus we also have an exemption when the "object"
|
2015-02-20 18:30:31 +01:00
|
|
|
# is a domain type, so that processes can communicate via unnamed pipes
|
|
|
|
# passed by binder or local socket IPC.
|
2012-01-04 18:33:27 +01:00
|
|
|
mlsconstrain fifo_file { read getattr }
|
2015-02-20 18:30:31 +01:00
|
|
|
(l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject or t2 == domain);
|
2012-01-04 18:33:27 +01:00
|
|
|
|
|
|
|
mlsconstrain fifo_file { write setattr append unlink link rename }
|
2015-03-13 22:07:39 +01:00
|
|
|
(l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject or t2 == domain);
|
2012-01-04 18:33:27 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Binder IPC constraints
|
|
|
|
#
|
|
|
|
# Presently commented out, as apps are expected to call one another.
|
|
|
|
# This would only make sense if apps were assigned categories
|
|
|
|
# based on allowable communications rather than per-app categories.
|
|
|
|
#mlsconstrain binder call
|
|
|
|
# (l1 eq l2 or t1 == mlstrustedsubject or t2 == mlstrustedsubject);
|