Skip to content
Snippets Groups Projects
Commit fb678339 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes from topic 'selinux-targetSdkVersion'

* changes:
  untrusted_app: policy versioning based on targetSdkVersion
  Add minTargetSdkVersion input selector to seapp_contexts
parents 3b06b971 bacb6d79
No related branches found
No related tags found
No related merge requests found
...@@ -2,26 +2,33 @@ ...@@ -2,26 +2,33 @@
### neverallow rules for untrusted app domains ### neverallow rules for untrusted app domains
### ###
# Only allow domains in AOSP to use the untrusted_app_all attribute.
neverallow { untrusted_app_all -untrusted_app -untrusted_app_25 } domain:process fork;
# Receive or send uevent messages. # Receive or send uevent messages.
neverallow { untrusted_app ephemeral_app isolated_app } domain:netlink_kobject_uevent_socket *; neverallow { untrusted_app_all ephemeral_app isolated_app } domain:netlink_kobject_uevent_socket *;
# Receive or send generic netlink messages # Receive or send generic netlink messages
neverallow { untrusted_app ephemeral_app isolated_app } domain:netlink_socket *; neverallow { untrusted_app_all ephemeral_app isolated_app } domain:netlink_socket *;
# Too much leaky information in debugfs. It's a security # Too much leaky information in debugfs. It's a security
# best practice to ensure these files aren't readable. # best practice to ensure these files aren't readable.
neverallow { untrusted_app ephemeral_app isolated_app } debugfs_type:file read; neverallow { untrusted_app_all ephemeral_app isolated_app } debugfs_type:file read;
# Do not allow untrusted apps to register services. # Do not allow untrusted apps to register services.
# Only trusted components of Android should be registering # Only trusted components of Android should be registering
# services. # services.
neverallow { untrusted_app ephemeral_app isolated_app } service_manager_type:service_manager add; neverallow { untrusted_app_all ephemeral_app isolated_app } service_manager_type:service_manager add;
# Do not allow untrusted apps to connect to the property service # Do not allow untrusted apps to connect to the property service
# or set properties. b/10243159 # or set properties. b/10243159
neverallow { untrusted_app ephemeral_app isolated_app } property_socket:sock_file write; neverallow { untrusted_app_all ephemeral_app isolated_app } property_socket:sock_file write;
neverallow { untrusted_app ephemeral_app isolated_app } init:unix_stream_socket connectto; neverallow { untrusted_app_all ephemeral_app isolated_app } init:unix_stream_socket connectto;
neverallow { untrusted_app ephemeral_app isolated_app } property_type:property_service set; neverallow { untrusted_app_all ephemeral_app isolated_app } property_type:property_service set;
# b/34115651 - net.dns* properties read
# This will go away in a future Android release
neverallow { appdomain -untrusted_app_25 } net_dns_prop:file r_file_perms;
# Do not allow untrusted apps to be assigned mlstrustedsubject. # Do not allow untrusted apps to be assigned mlstrustedsubject.
# This would undermine the per-user isolation model being # This would undermine the per-user isolation model being
...@@ -31,7 +38,7 @@ neverallow { untrusted_app ephemeral_app isolated_app } property_type:property_s ...@@ -31,7 +38,7 @@ neverallow { untrusted_app ephemeral_app isolated_app } property_type:property_s
# permission only makes sense within a domain (hence should # permission only makes sense within a domain (hence should
# never be granted to any other domain within mlstrustedsubject) # never be granted to any other domain within mlstrustedsubject)
# and an untrusted app is allowed fork permission to itself. # and an untrusted app is allowed fork permission to itself.
neverallow { untrusted_app ephemeral_app isolated_app } mlstrustedsubject:process fork; neverallow { untrusted_app_all ephemeral_app isolated_app } mlstrustedsubject:process fork;
# Do not allow untrusted apps to hard link to any files. # Do not allow untrusted apps to hard link to any files.
# In particular, if an untrusted app links to other app data # In particular, if an untrusted app links to other app data
...@@ -39,16 +46,16 @@ neverallow { untrusted_app ephemeral_app isolated_app } mlstrustedsubject:proces ...@@ -39,16 +46,16 @@ neverallow { untrusted_app ephemeral_app isolated_app } mlstrustedsubject:proces
# of the linked to file. Hard links also contribute to security # of the linked to file. Hard links also contribute to security
# bugs, so we want to ensure untrusted apps never have this # bugs, so we want to ensure untrusted apps never have this
# capability. # capability.
neverallow { untrusted_app ephemeral_app isolated_app } file_type:file link; neverallow { untrusted_app_all ephemeral_app isolated_app } file_type:file link;
# Do not allow untrusted apps to access network MAC address file # Do not allow untrusted apps to access network MAC address file
neverallow { untrusted_app ephemeral_app isolated_app } sysfs_mac_address:file no_rw_file_perms; neverallow { untrusted_app_all ephemeral_app isolated_app } sysfs_mac_address:file no_rw_file_perms;
# Restrict socket ioctls. Either 1. disallow privileged ioctls, 2. disallow the # Restrict socket ioctls. Either 1. disallow privileged ioctls, 2. disallow the
# ioctl permission, or 3. disallow the socket class. # ioctl permission, or 3. disallow the socket class.
neverallowxperm { untrusted_app ephemeral_app isolated_app } domain:{ rawip_socket tcp_socket udp_socket } ioctl priv_sock_ioctls; neverallowxperm { untrusted_app_all ephemeral_app isolated_app } domain:{ rawip_socket tcp_socket udp_socket } ioctl priv_sock_ioctls;
neverallow { untrusted_app ephemeral_app isolated_app } *:{ netlink_route_socket netlink_selinux_socket } ioctl; neverallow { untrusted_app_all ephemeral_app isolated_app } *:{ netlink_route_socket netlink_selinux_socket } ioctl;
neverallow { untrusted_app ephemeral_app isolated_app } *:{ neverallow { untrusted_app_all ephemeral_app isolated_app } *:{
socket netlink_socket packet_socket key_socket appletalk_socket socket netlink_socket packet_socket key_socket appletalk_socket
netlink_tcpdiag_socket netlink_nflog_socket netlink_tcpdiag_socket netlink_nflog_socket
netlink_xfrm_socket netlink_audit_socket netlink_xfrm_socket netlink_audit_socket
...@@ -59,15 +66,15 @@ neverallow { untrusted_app ephemeral_app isolated_app } *:{ ...@@ -59,15 +66,15 @@ neverallow { untrusted_app ephemeral_app isolated_app } *:{
} *; } *;
# Do not allow untrusted apps access to /cache # Do not allow untrusted apps access to /cache
neverallow { untrusted_app ephemeral_app isolated_app } { cache_file cache_recovery_file }:dir ~{ r_dir_perms }; neverallow { untrusted_app_all ephemeral_app isolated_app } { cache_file cache_recovery_file }:dir ~{ r_dir_perms };
neverallow { untrusted_app ephemeral_app isolated_app } { cache_file cache_recovery_file }:file ~{ read getattr }; neverallow { untrusted_app_all ephemeral_app isolated_app } { cache_file cache_recovery_file }:file ~{ read getattr };
# Do not allow untrusted apps to create/unlink files outside of its sandbox, # Do not allow untrusted apps to create/unlink files outside of its sandbox,
# internal storage or sdcard. # internal storage or sdcard.
# World accessible data locations allow application to fill the device # World accessible data locations allow application to fill the device
# with unaccounted for data. This data will not get removed during # with unaccounted for data. This data will not get removed during
# application un-installation. # application un-installation.
neverallow { untrusted_app ephemeral_app isolated_app } { neverallow { untrusted_app_all ephemeral_app isolated_app } {
fs_type fs_type
-fuse # sdcard -fuse # sdcard
-sdcardfs # sdcard -sdcardfs # sdcard
...@@ -85,12 +92,12 @@ neverallow { untrusted_app ephemeral_app isolated_app } { ...@@ -85,12 +92,12 @@ neverallow { untrusted_app ephemeral_app isolated_app } {
}:dir_file_class_set { create unlink }; }:dir_file_class_set { create unlink };
# Do not allow untrusted apps to directly open tun_device # Do not allow untrusted apps to directly open tun_device
neverallow { untrusted_app ephemeral_app isolated_app } tun_device:chr_file open; neverallow { untrusted_app_all ephemeral_app isolated_app } tun_device:chr_file open;
# Only allow appending to /data/anr/traces.txt (b/27853304, b/18340553) # Only allow appending to /data/anr/traces.txt (b/27853304, b/18340553)
neverallow { untrusted_app ephemeral_app isolated_app } anr_data_file:file ~{ open append }; neverallow { untrusted_app_all ephemeral_app isolated_app } anr_data_file:file ~{ open append };
neverallow { untrusted_app ephemeral_app isolated_app } anr_data_file:dir ~search; neverallow { untrusted_app_all ephemeral_app isolated_app } anr_data_file:dir ~search;
# Avoid reads from generically labeled /proc files # Avoid reads from generically labeled /proc files
# Create a more specific label if needed # Create a more specific label if needed
neverallow { untrusted_app ephemeral_app isolated_app } proc:file { no_rw_file_perms no_x_file_perms }; neverallow { untrusted_app_all ephemeral_app isolated_app } proc:file { no_rw_file_perms no_x_file_perms };
# Input selectors: # Input selectors:
# isSystemServer (boolean) # isSystemServer (boolean)
# isEphemeralApp (boolean) # isEphemeralApp (boolean)
# isOwner (boolean) # isOwner (boolean)
# user (string) # user (string)
# seinfo (string) # seinfo (string)
# name (string) # name (string)
# path (string) # path (string)
# isPrivApp (boolean) # isPrivApp (boolean)
# minTargetSdkVersion (unsigned integer)
# isSystemServer=true can only be used once. # isSystemServer=true can only be used once.
# An unspecified isSystemServer defaults to false. # An unspecified isSystemServer defaults to false.
# isEphemeralApp=true will match apps marked by PackageManager as Ephemeral # isEphemeralApp=true will match apps marked by PackageManager as Ephemeral
...@@ -19,27 +20,32 @@ ...@@ -19,27 +20,32 @@
# user=_isolated will match any isolated service UID. # user=_isolated will match any isolated service UID.
# isPrivApp=true will only match for applications preinstalled in # isPrivApp=true will only match for applications preinstalled in
# /system/priv-app. # /system/priv-app.
# minTargetSdkVersion will match applications with a targetSdkVersion
# greater than or equal to the specified value. If unspecified,
# it has a default value of 0.
# All specified input selectors in an entry must match (i.e. logical AND). # All specified input selectors in an entry must match (i.e. logical AND).
# Matching is case-insensitive. # Matching is case-insensitive.
# #
# Precedence rules (see external/selinux/libselinux/src/android/android.c seapp_context_cmp()): # Precedence rules (see external/selinux/libselinux/src/android/android.c seapp_context_cmp()):
# (1) isSystemServer=true before isSystemServer=false. # (1) isSystemServer=true before isSystemServer=false.
# (2) Specified isEphemeralApp= before unspecified isEphemeralApp= boolean. # (2) Specified isEphemeralApp= before unspecified isEphemeralApp= boolean.
# (3) Specified isOwner= before unspecified isOwner= boolean. # (3) Specified isOwner= before unspecified isOwner= boolean.
# (4) Specified user= string before unspecified user= string. # (4) Specified user= string before unspecified user= string.
# (5) Fixed user= string before user= prefix (i.e. ending in *). # (5) Fixed user= string before user= prefix (i.e. ending in *).
# (6) Longer user= prefix before shorter user= prefix. # (6) Longer user= prefix before shorter user= prefix.
# (7) Specified seinfo= string before unspecified seinfo= string. # (7) Specified seinfo= string before unspecified seinfo= string.
# ':' character is reserved and may not be used. # ':' character is reserved and may not be used.
# (8) Specified name= string before unspecified name= string. # (8) Specified name= string before unspecified name= string.
# (9) Specified path= string before unspecified path= string. # (9) Specified path= string before unspecified path= string.
# (10) Specified isPrivApp= before unspecified isPrivApp= boolean. # (10) Specified isPrivApp= before unspecified isPrivApp= boolean.
# (11) Higher value of minTargetSdkVersion= before lower value of minTargetSdkVersion=
# integer. Note that minTargetSdkVersion= defaults to 0 if unspecified.
# #
# Outputs: # Outputs:
# domain (string) # domain (string)
# type (string) # type (string)
# levelFrom (string; one of none, all, app, or user) # levelFrom (string; one of none, all, app, or user)
# level (string) # level (string)
# Only entries that specify domain= will be used for app process labeling. # Only entries that specify domain= will be used for app process labeling.
# Only entries that specify type= will be used for app directory labeling. # Only entries that specify type= will be used for app directory labeling.
# levelFrom=user is only supported for _app or _isolated UIDs. # levelFrom=user is only supported for _app or _isolated UIDs.
...@@ -96,4 +102,5 @@ user=_isolated domain=isolated_app levelFrom=user ...@@ -96,4 +102,5 @@ user=_isolated domain=isolated_app levelFrom=user
user=_app seinfo=platform domain=platform_app type=app_data_file levelFrom=user user=_app seinfo=platform domain=platform_app type=app_data_file levelFrom=user
user=_app isEphemeralApp=true domain=ephemeral_app type=app_data_file levelFrom=all user=_app isEphemeralApp=true domain=ephemeral_app type=app_data_file levelFrom=all
user=_app isPrivApp=true domain=priv_app type=app_data_file levelFrom=user user=_app isPrivApp=true domain=priv_app type=app_data_file levelFrom=user
user=_app domain=untrusted_app type=app_data_file levelFrom=user user=_app minTargetSdkVersion=26 domain=untrusted_app type=app_data_file levelFrom=user
user=_app domain=untrusted_app_25 type=app_data_file levelFrom=user
...@@ -18,93 +18,6 @@ ...@@ -18,93 +18,6 @@
### ###
app_domain(untrusted_app) app_domain(untrusted_app)
untrusted_app_domain(untrusted_app)
net_domain(untrusted_app) net_domain(untrusted_app)
bluetooth_domain(untrusted_app) bluetooth_domain(untrusted_app)
# b/34115651 - net.dns* properties read
# This will go away in a future Android release
get_prop(untrusted_app, net_dns_prop)
# Allow the allocation and use of ptys
# Used by: https://play.google.com/store/apps/details?id=jackpal.androidterm
create_pty(untrusted_app)
# Legacy text relocations
allow untrusted_app apk_data_file:file execmod;
# Some apps ship with shared libraries and binaries that they write out
# to their sandbox directory and then execute.
allow untrusted_app app_data_file:file { rx_file_perms execmod };
# ASEC
allow untrusted_app asec_apk_file:file r_file_perms;
allow untrusted_app asec_apk_file:dir r_dir_perms;
# Execute libs in asec containers.
allow untrusted_app asec_public_file:file { execute execmod };
# Used by Finsky / Android "Verify Apps" functionality when
# running "adb install foo.apk".
# TODO: Long term, we don't want apps probing into shell data files.
# 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;
# Read and write system app data files passed over Binder.
# Motivating case was /data/data/com.android.settings/cache/*.jpg for
# cropping or taking user photos.
allow untrusted_app system_app_data_file:file { read write getattr };
#
# Rules migrated from old app domains coalesced into untrusted_app.
# This includes what used to be media_app, shared_app, and release_app.
#
# 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;
# Traverse into /mnt/media_rw for bypassing FUSE daemon
# TODO: narrow this to just MediaProvider
allow untrusted_app mnt_media_rw_file:dir search;
# allow cts to query all services
allow untrusted_app servicemanager:service_manager list;
allow untrusted_app audioserver_service:service_manager find;
allow untrusted_app cameraserver_service:service_manager find;
allow untrusted_app drmserver_service:service_manager find;
allow untrusted_app mediaserver_service:service_manager find;
allow untrusted_app mediaextractor_service:service_manager find;
allow untrusted_app mediacodec_service:service_manager find;
allow untrusted_app mediametrics_service:service_manager find;
allow untrusted_app mediadrmserver_service:service_manager find;
allow untrusted_app nfc_service:service_manager find;
allow untrusted_app radio_service:service_manager find;
allow untrusted_app surfaceflinger_service:service_manager find;
allow untrusted_app app_api_service:service_manager find;
allow untrusted_app vr_manager_service:service_manager find;
# Allow GMS core to access perfprofd output, which is stored
# in /data/misc/perfprofd/. GMS core will need to list all
# data stored in that directory to process them one by one.
userdebug_or_eng(`
allow untrusted_app perfprofd_data_file:file r_file_perms;
allow untrusted_app perfprofd_data_file:dir r_dir_perms;
')
# gdbserver for ndk-gdb ptrace attaches to app process.
allow untrusted_app self:process ptrace;
# Cts: HwRngTest
allow untrusted_app sysfs_hwrandom:dir search;
allow untrusted_app sysfs_hwrandom:file r_file_perms;
# Allow apps to view preloaded content
allow untrusted_app preloads_data_file:dir r_dir_perms;
allow untrusted_app preloads_data_file:file r_file_perms;
# Access to /proc/tty/drivers, to allow apps to determine if they
# are running in an emulated environment.
# b/33214085 b/33814662 b/33791054 b/33211769
# https://github.com/strazzere/anti-emulator/blob/master/AntiEmulator/src/diff/strazzere/anti/emulator/FindEmulator.java
allow untrusted_app proc_tty_drivers:file r_file_perms;
###
### Untrusted_app_25
###
### This file defines the rules for untrusted apps running with
### targetSdkVersion <= 25.
###
### Apps are labeled based on mac_permissions.xml (maps signer and
### optionally package name to seinfo value) and seapp_contexts (maps UID
### and optionally seinfo value to domain for process and type for data
### directory). The untrusted_app domain is the default assignment in
### seapp_contexts for any app with UID between APP_AID (10000)
### 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 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
### seapp_contexts.
###
app_domain(untrusted_app_25)
untrusted_app_domain(untrusted_app_25)
net_domain(untrusted_app_25)
bluetooth_domain(untrusted_app_25)
# b/34115651 - net.dns* properties read
# This will go away in a future Android release
get_prop(untrusted_app_25, net_dns_prop)
###
### Untrusted_app_all.
###
### This file defines the rules shared by all untrusted app domains.
### Apps are labeled based on mac_permissions.xml (maps signer and
### optionally package name to seinfo value) and seapp_contexts (maps UID
### and optionally seinfo value to domain for process and type for data
### directory). The untrusted_app_all attribute is assigned to all default
### seapp_contexts for any app with UID between APP_AID (10000)
### and AID_ISOLATED_START (99000) if the app has no specific seinfo
### value as determined from mac_permissions.xml. In current AOSP, this
### attribute is assigned to all non-system apps as well as to any system apps
### 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
### seapp_contexts.
###
# Allow the allocation and use of ptys
# Used by: https://play.google.com/store/apps/details?id=jackpal.androidterm
create_pty(untrusted_app)
# Legacy text relocations
allow untrusted_app_all apk_data_file:file execmod;
# Some apps ship with shared libraries and binaries that they write out
# to their sandbox directory and then execute.
allow untrusted_app_all app_data_file:file { rx_file_perms execmod };
# ASEC
allow untrusted_app_all asec_apk_file:file r_file_perms;
allow untrusted_app_all asec_apk_file:dir r_dir_perms;
# Execute libs in asec containers.
allow untrusted_app_all asec_public_file:file { execute execmod };
# Used by Finsky / Android "Verify Apps" functionality when
# running "adb install foo.apk".
# TODO: Long term, we don't want apps probing into shell data files.
# Figure out a way to remove these rules.
allow untrusted_app_all shell_data_file:file r_file_perms;
allow untrusted_app_all shell_data_file:dir r_dir_perms;
# Read and write system app data files passed over Binder.
# Motivating case was /data/data/com.android.settings/cache/*.jpg for
# cropping or taking user photos.
allow untrusted_app_all system_app_data_file:file { read write getattr };
#
# Rules migrated from old app domains coalesced into untrusted_app.
# This includes what used to be media_app, shared_app, and release_app.
#
# Access to /data/media.
allow untrusted_app_all media_rw_data_file:dir create_dir_perms;
allow untrusted_app_all media_rw_data_file:file create_file_perms;
# Traverse into /mnt/media_rw for bypassing FUSE daemon
# TODO: narrow this to just MediaProvider
allow untrusted_app_all mnt_media_rw_file:dir search;
# allow cts to query all services
allow untrusted_app_all servicemanager:service_manager list;
allow untrusted_app_all audioserver_service:service_manager find;
allow untrusted_app_all cameraserver_service:service_manager find;
allow untrusted_app_all drmserver_service:service_manager find;
allow untrusted_app_all mediaserver_service:service_manager find;
allow untrusted_app_all mediaextractor_service:service_manager find;
allow untrusted_app_all mediacodec_service:service_manager find;
allow untrusted_app_all mediametrics_service:service_manager find;
allow untrusted_app_all mediadrmserver_service:service_manager find;
allow untrusted_app_all nfc_service:service_manager find;
allow untrusted_app_all radio_service:service_manager find;
allow untrusted_app_all surfaceflinger_service:service_manager find;
allow untrusted_app_all app_api_service:service_manager find;
allow untrusted_app_all vr_manager_service:service_manager find;
# Allow GMS core to access perfprofd output, which is stored
# in /data/misc/perfprofd/. GMS core will need to list all
# data stored in that directory to process them one by one.
userdebug_or_eng(`
allow untrusted_app_all perfprofd_data_file:file r_file_perms;
allow untrusted_app_all perfprofd_data_file:dir r_dir_perms;
')
# gdbserver for ndk-gdb ptrace attaches to app process.
allow untrusted_app_all self:process ptrace;
# Cts: HwRngTest
allow untrusted_app_all sysfs_hwrandom:dir search;
allow untrusted_app_all sysfs_hwrandom:file r_file_perms;
# Allow apps to view preloaded content
allow untrusted_app_all preloads_data_file:dir r_dir_perms;
allow untrusted_app_all preloads_data_file:file r_file_perms;
# Access to /proc/tty/drivers, to allow apps to determine if they
# are running in an emulated environment.
# b/33214085 b/33814662 b/33791054 b/33211769
# https://github.com/strazzere/anti-emulator/blob/master/AntiEmulator/src/diff/strazzere/anti/emulator/FindEmulator.java
allow untrusted_app_all proc_tty_drivers:file r_file_perms;
...@@ -95,6 +95,9 @@ attribute mlstrustedobject; ...@@ -95,6 +95,9 @@ attribute mlstrustedobject;
# All domains used for apps. # All domains used for apps.
attribute appdomain; attribute appdomain;
# All third party apps.
attribute untrusted_app_all;
# All domains used for apps with network access. # All domains used for apps with network access.
attribute netdomain; attribute netdomain;
......
...@@ -499,7 +499,7 @@ neverallow * self:process { execstack execheap }; ...@@ -499,7 +499,7 @@ neverallow * self:process { execstack execheap };
# prohibit non-zygote spawned processes from using shared libraries # prohibit non-zygote spawned processes from using shared libraries
# with text relocations. b/20013628 . # with text relocations. b/20013628 .
neverallow { domain -untrusted_app } file_type:file execmod; neverallow { domain -untrusted_app_all } file_type:file execmod;
neverallow { domain -init } proc:{ file dir } mounton; neverallow { domain -init } proc:{ file dir } mounton;
......
...@@ -127,6 +127,13 @@ tmpfs_domain($1) ...@@ -127,6 +127,13 @@ tmpfs_domain($1)
allow $1 $1_tmpfs:file execute; allow $1 $1_tmpfs:file execute;
') ')
#####################################
# untrusted_app_domain(domain)
# Allow a base set of permissions required for all untrusted apps.
define(`untrusted_app_domain', `
typeattribute $1 untrusted_app_all;
')
##################################### #####################################
# net_domain(domain) # net_domain(domain)
# Allow a base set of permissions required for network access. # Allow a base set of permissions required for network access.
......
###
### Untrusted apps.
###
### Apps are labeled based on mac_permissions.xml (maps signer and
### optionally package name to seinfo value) and seapp_contexts (maps UID
### and optionally seinfo value to domain for process and type for data
### directory). The untrusted_app domain is the default assignment in
### seapp_contexts for any app with UID between APP_AID (10000)
### 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 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
### seapp_contexts.
###
type untrusted_app_25, domain;
...@@ -194,6 +194,7 @@ static bool validate_bool(char *value, char **errmsg); ...@@ -194,6 +194,7 @@ static bool validate_bool(char *value, char **errmsg);
static bool validate_levelFrom(char *value, char **errmsg); static bool validate_levelFrom(char *value, char **errmsg);
static bool validate_selinux_type(char *value, char **errmsg); static bool validate_selinux_type(char *value, char **errmsg);
static bool validate_selinux_level(char *value, char **errmsg); static bool validate_selinux_level(char *value, char **errmsg);
static bool validate_uint(char *value, char **errmsg);
/** /**
* The heart of the mapping process, this must be updated if a new key value pair is added * The heart of the mapping process, this must be updated if a new key value pair is added
...@@ -209,6 +210,7 @@ key_map rules[] = { ...@@ -209,6 +210,7 @@ key_map rules[] = {
{ .name = "name", .dir = dir_in, }, { .name = "name", .dir = dir_in, },
{ .name = "path", .dir = dir_in, }, { .name = "path", .dir = dir_in, },
{ .name = "isPrivApp", .dir = dir_in, .fn_validate = validate_bool }, { .name = "isPrivApp", .dir = dir_in, .fn_validate = validate_bool },
{ .name = "minTargetSdkVersion", .dir = dir_in, .fn_validate = validate_uint },
/*Outputs*/ /*Outputs*/
{ .name = "domain", .dir = dir_out, .fn_validate = validate_selinux_type }, { .name = "domain", .dir = dir_out, .fn_validate = validate_selinux_type },
{ .name = "type", .dir = dir_out, .fn_validate = validate_selinux_type }, { .name = "type", .dir = dir_out, .fn_validate = validate_selinux_type },
...@@ -417,6 +419,19 @@ static bool validate_selinux_level(char *value, char **errmsg) { ...@@ -417,6 +419,19 @@ static bool validate_selinux_level(char *value, char **errmsg) {
return true; return true;
} }
static bool validate_uint(char *value, char **errmsg) {
char *endptr;
long longvalue;
longvalue = strtol(value, &endptr, 10);
if (('\0' != *endptr) || (longvalue < 0) || (longvalue > INT32_MAX)) {
*errmsg = "Expecting a valid unsigned integer";
return false;
}
return true;
}
/** /**
* Validates a key_map against a set of enforcement rules, this * Validates a key_map against a set of enforcement rules, this
* function exits the application on a type that cannot be properly * function exits the application on a type that cannot be properly
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment