Skip to content

Commit

Permalink
Coalesce shared_app, media_app, release_app into untrusted_app.
Browse files Browse the repository at this point in the history
This change folds the shared_app, media_app, and release_app
domains into untrusted_app, reducing the set of app domains down
to just distinct domains for the fixed UID apps (e.g. system_app, bluetooth,
nfc, radio), a single domain for apps signed by the platform key
(platform_app), and a single domain for all other apps (untrusted_app).
Thus, SELinux only distinguishes when already distinguished by a predefined
Android ID (AID) or by the platform certificate (which get the signature-only
Android permissions and thus may require special OS-level accesses).

It is still possible to introduce specific app domains for specific
apps by adding signer and package stanzas to mac_permissions.xml,
but this can be done on an as-needed basis for specialized apps that
require particular OS-level permissions outside the usual set.

As there is now only a single platform app domains, get rid of the
platformappdomain attribute and platform_app_domain() macro.  We used
to add mlstrustedsubject to those domains but drop this since we are not
using MLS in AOSP presently; we can revisit which domains need it if/when
we use MLS.

Since we are dropping the shared, media, and release seinfo entries from
seapp_contexts, drop them from mac_permissions.xml as well.  However,
we leave the keys.conf entries in case someone wants to add a signer
entry in the future for specific apps signed by those keys to
mac_permissions.xml.

Change-Id: I877192cca07360c4a3c0ef475f016cc273e1d968
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
  • Loading branch information
stephensmalley committed Apr 4, 2014
1 parent 3fa9b4d commit 9ba844f
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 95 deletions.
1 change: 1 addition & 0 deletions app.te
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ allow appdomain appdomain:unix_stream_socket { getopt getattr read write shutdow
# to any app that has backup ability. Hence, no open permissions here.
allow appdomain backup_data_file:file { read write getattr };
allow appdomain cache_backup_file:file { read write getattr };
allow appdomain cache_backup_file:dir getattr;
# Backup ability using 'adb backup'
allow appdomain system_data_file:lnk_file getattr;

Expand Down
3 changes: 0 additions & 3 deletions attributes
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,5 @@ attribute bluetoothdomain;
# All domains used for binder service domains.
attribute binderservicedomain;

# Allow domains used for platform (signed by build key) apps.
attribute platformappdomain;

# All domains which are allowed the "relabelto" permission
attribute relabeltodomain;
15 changes: 0 additions & 15 deletions mac_permissions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,6 @@
<seinfo value="platform" />
</signer>

<!-- Media dev key in AOSP -->
<signer signature="@MEDIA" >
<seinfo value="media" />
</signer>

<!-- shared dev key in AOSP -->
<signer signature="@SHARED" >
<seinfo value="shared" />
</signer>

<!-- release dev key in AOSP -->
<signer signature="@RELEASE" >
<seinfo value="release" />
</signer>

<!-- All other keys -->
<default>
<seinfo value="default" />
Expand Down
17 changes: 0 additions & 17 deletions media_app.te

This file was deleted.

9 changes: 7 additions & 2 deletions platform_app.te
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
type platform_app, domain;
permissive_or_unconfined(platform_app)
app_domain(platform_app)
platform_app_domain(platform_app)
# Access the network.
net_domain(platform_app)
# Access bluetooth.
Expand All @@ -22,4 +21,10 @@ allow platform_app apk_private_data_file:dir search;
allow platform_app asec_apk_file:dir create_dir_perms;
allow platform_app asec_apk_file:file create_file_perms;

# inherits from platformappdomain.te
# Access to /data/media.
allow platform_app media_rw_data_file:dir create_dir_perms;
allow platform_app media_rw_data_file:file create_file_perms;

# Write to /cache.
allow platform_app cache_file:dir create_dir_perms;
allow platform_app cache_file:file create_file_perms;
16 changes: 0 additions & 16 deletions platformappdomain.te

This file was deleted.

14 changes: 0 additions & 14 deletions release_app.te

This file was deleted.

7 changes: 2 additions & 5 deletions seapp_contexts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ user=bluetooth domain=bluetooth type=bluetooth_data_file
user=nfc domain=nfc type=nfc_data_file
user=radio domain=radio type=radio_data_file
user=shell domain=shell type=shell_data_file
user=_app domain=untrusted_app type=app_data_file
user=_app seinfo=platform domain=platform_app type=app_data_file
user=_app seinfo=shared domain=shared_app type=app_data_file
user=_app seinfo=media domain=media_app type=app_data_file
user=_app seinfo=release domain=release_app type=app_data_file
user=_isolated domain=isolated_app
user=_app seinfo=platform domain=platform_app type=app_data_file
user=_app domain=untrusted_app type=app_data_file
14 changes: 0 additions & 14 deletions shared_app.te

This file was deleted.

8 changes: 0 additions & 8 deletions te_macros
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,6 @@ define(`relabelto_domain', `
typeattribute $1 relabeltodomain;
')

#####################################
# platform_app_domain(domain)
# Allow permissions specific to platform apps.
define(`platform_app_domain', `
typeattribute $1 platformappdomain;
typeattribute $1 mlstrustedsubject;
')

#####################################
# net_domain(domain)
# Allow a base set of permissions required for network access.
Expand Down
18 changes: 17 additions & 1 deletion untrusted_app.te
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
### and AID_ISOLATED_START (99000) if the app has no specific seinfo
### value as determined from mac_permissions.xml. In current AOSP, this
### domain is assigned to all non-system apps as well as to any system apps
### that are not signed by one of the four platform keys. To move
### that are not signed by the platform key. To move
### a system app into a specific domain, add a signer entry for it to
### mac_permissions.xml and assign it one of the pre-existing seinfo values
### or define and use a new seinfo value in both mac_permissions.xml and
Expand Down Expand Up @@ -48,3 +48,19 @@ create_pty(untrusted_app)
# Figure out a way to remove these rules.
allow untrusted_app shell_data_file:file r_file_perms;
allow untrusted_app shell_data_file:dir r_dir_perms;

#
# Rules migrated from old app domains coalesced into untrusted_app.
# This includes what used to be media_app, shared_app, and release_app.
#

# Access /dev/mtp_usb.
allow untrusted_app mtp_device:chr_file rw_file_perms;

# Access to /data/media.
allow untrusted_app media_rw_data_file:dir create_dir_perms;
allow untrusted_app media_rw_data_file:file create_file_perms;

# Write to /cache.
allow untrusted_app cache_file:dir create_dir_perms;
allow untrusted_app cache_file:file create_file_perms;

0 comments on commit 9ba844f

Please sign in to comment.