2017-02-07 18:55:05 +01:00
|
|
|
### ADB daemon
|
|
|
|
|
2017-03-23 22:27:32 +01:00
|
|
|
typeattribute adbd coredomain;
|
2017-02-07 18:55:05 +01:00
|
|
|
typeattribute adbd mlstrustedsubject;
|
|
|
|
|
2017-07-31 12:38:28 +02:00
|
|
|
init_daemon_domain(adbd)
|
|
|
|
|
2016-07-22 22:13:11 +02:00
|
|
|
domain_auto_trans(adbd, shell_exec, shell)
|
2017-02-07 18:55:05 +01:00
|
|
|
|
|
|
|
userdebug_or_eng(`
|
|
|
|
allow adbd self:process setcurrent;
|
|
|
|
allow adbd su:process dyntransition;
|
|
|
|
')
|
|
|
|
|
2018-06-01 05:31:33 +02:00
|
|
|
# When 'adb shell' is executed in recovery mode, adbd explicitly
|
|
|
|
# switches into shell domain using setcon() because the shell executable
|
|
|
|
# is not labeled as shell but as rootfs.
|
|
|
|
recovery_only(`
|
|
|
|
domain_trans(adbd, rootfs, shell)
|
|
|
|
allow adbd shell:process dyntransition;
|
2018-05-29 19:54:16 +02:00
|
|
|
|
|
|
|
# Allows reboot fastboot to enter fastboot directly
|
|
|
|
unix_socket_connect(adbd, recovery, recovery)
|
2018-06-01 05:31:33 +02:00
|
|
|
')
|
|
|
|
|
2019-09-04 15:46:36 +02:00
|
|
|
# Control Perfetto traced and obtain traces from it.
|
|
|
|
# Needed to allow port forwarding directly to traced.
|
|
|
|
unix_socket_connect(adbd, traced_consumer, traced)
|
|
|
|
|
2017-02-07 18:55:05 +01:00
|
|
|
# Do not sanitize the environment or open fds of the shell. Allow signaling
|
|
|
|
# created processes.
|
|
|
|
allow adbd shell:process { noatsecure signal };
|
|
|
|
|
|
|
|
# Set UID and GID to shell. Set supplementary groups.
|
2017-11-09 23:51:26 +01:00
|
|
|
allow adbd self:global_capability_class_set { setuid setgid };
|
2017-02-07 18:55:05 +01:00
|
|
|
|
|
|
|
# Drop capabilities from bounding set on user builds.
|
2017-11-09 23:51:26 +01:00
|
|
|
allow adbd self:global_capability_class_set setpcap;
|
2017-02-07 18:55:05 +01:00
|
|
|
|
2018-05-01 17:21:30 +02:00
|
|
|
# ignore spurious denials for adbd when disk space is low.
|
|
|
|
dontaudit adbd self:global_capability_class_set sys_resource;
|
|
|
|
|
2019-02-25 23:55:27 +01:00
|
|
|
# adbd probes for vsock support. Do not generate denials when
|
|
|
|
# this occurs. (b/123569840)
|
|
|
|
dontaudit adbd self:{ socket vsock_socket } create;
|
|
|
|
|
2021-03-11 05:06:45 +01:00
|
|
|
# Allow adbd inside vm to forward vm's vsock.
|
|
|
|
allow adbd self:vsock_socket { create_socket_perms_no_ioctl listen accept };
|
|
|
|
|
2017-02-07 18:55:05 +01:00
|
|
|
# Create and use network sockets.
|
|
|
|
net_domain(adbd)
|
2023-01-18 08:52:43 +01:00
|
|
|
# Connect to mdnsd via mdnsd socket.
|
|
|
|
unix_socket_connect(adbd, mdnsd, mdnsd)
|
2017-02-07 18:55:05 +01:00
|
|
|
|
|
|
|
# Access /dev/usb-ffs/adb/ep0
|
|
|
|
allow adbd functionfs:dir search;
|
|
|
|
allow adbd functionfs:file rw_file_perms;
|
2018-10-09 23:22:47 +02:00
|
|
|
allowxperm adbd functionfs:file ioctl {
|
|
|
|
FUNCTIONFS_ENDPOINT_DESC
|
|
|
|
FUNCTIONFS_CLEAR_HALT
|
|
|
|
};
|
2017-02-07 18:55:05 +01:00
|
|
|
|
|
|
|
# Use a pseudo tty.
|
|
|
|
allow adbd devpts:chr_file rw_file_perms;
|
|
|
|
|
|
|
|
# adb push/pull /data/local/tmp.
|
|
|
|
allow adbd shell_data_file:dir create_dir_perms;
|
|
|
|
allow adbd shell_data_file:file create_file_perms;
|
|
|
|
|
2018-01-16 01:44:04 +01:00
|
|
|
# adb pull /data/local/traces/*
|
|
|
|
allow adbd trace_data_file:dir r_dir_perms;
|
|
|
|
allow adbd trace_data_file:file r_file_perms;
|
|
|
|
|
2017-02-07 18:55:05 +01:00
|
|
|
# adb pull /data/misc/profman.
|
|
|
|
allow adbd profman_dump_data_file:dir r_dir_perms;
|
|
|
|
allow adbd profman_dump_data_file:file r_file_perms;
|
|
|
|
|
|
|
|
# adb push/pull sdcard.
|
|
|
|
allow adbd tmpfs:dir search;
|
|
|
|
allow adbd rootfs:lnk_file r_file_perms; # /sdcard symlink
|
|
|
|
allow adbd tmpfs:lnk_file r_file_perms; # /mnt/sdcard symlink
|
2021-06-23 10:21:49 +02:00
|
|
|
allow adbd { sdcard_type fuse }:dir create_dir_perms;
|
|
|
|
allow adbd { sdcard_type fuse }:file create_file_perms;
|
2017-02-07 18:55:05 +01:00
|
|
|
|
|
|
|
# adb pull /data/anr/traces.txt
|
|
|
|
allow adbd anr_data_file:dir r_dir_perms;
|
|
|
|
allow adbd anr_data_file:file r_file_perms;
|
|
|
|
|
2021-06-02 15:17:23 +02:00
|
|
|
# adb pull /vendor/framework/*
|
|
|
|
allow adbd vendor_framework_file:dir r_dir_perms;
|
|
|
|
allow adbd vendor_framework_file:file r_file_perms;
|
|
|
|
|
2017-02-07 18:55:05 +01:00
|
|
|
# Set service.adb.*, sys.powerctl, and sys.usb.ffs.ready properties.
|
|
|
|
set_prop(adbd, shell_prop)
|
|
|
|
set_prop(adbd, powerctl_prop)
|
2020-04-27 16:49:15 +02:00
|
|
|
get_prop(adbd, ffs_config_prop)
|
|
|
|
set_prop(adbd, ffs_control_prop)
|
2017-02-07 18:55:05 +01:00
|
|
|
|
2020-10-28 21:56:23 +01:00
|
|
|
# Set service.adb.tcp.port, service.adb.tls.port, persist.adb.wifi.* properties
|
2020-02-12 19:18:10 +01:00
|
|
|
set_prop(adbd, adbd_prop)
|
2020-10-28 21:56:23 +01:00
|
|
|
set_prop(adbd, adbd_config_prop)
|
2020-02-12 19:18:10 +01:00
|
|
|
|
2020-03-04 09:20:35 +01:00
|
|
|
# Allow adbd start/stop mdnsd via ctl.start
|
|
|
|
set_prop(adbd, ctl_mdnsd_prop)
|
|
|
|
|
2017-02-07 18:55:05 +01:00
|
|
|
# Access device logging gating property
|
|
|
|
get_prop(adbd, device_logging_prop)
|
|
|
|
|
|
|
|
# Read device's serial number from system properties
|
|
|
|
get_prop(adbd, serialno_prop)
|
|
|
|
|
2019-01-15 22:39:30 +01:00
|
|
|
# Read whether or not Test Harness Mode is enabled
|
|
|
|
get_prop(adbd, test_harness_prop)
|
|
|
|
|
2020-02-12 19:18:10 +01:00
|
|
|
# Read persist.adb.tls_server.enable property
|
|
|
|
get_prop(adbd, system_adbd_prop)
|
|
|
|
|
2018-08-13 23:46:41 +02:00
|
|
|
# Read device's overlayfs related properties and files
|
|
|
|
userdebug_or_eng(`
|
|
|
|
get_prop(adbd, persistent_properties_ready_prop)
|
|
|
|
r_dir_file(adbd, sysfs_dt_firmware_android)
|
|
|
|
')
|
|
|
|
|
2017-02-07 18:55:05 +01:00
|
|
|
# Run /system/bin/bu
|
|
|
|
allow adbd system_file:file rx_file_perms;
|
|
|
|
|
2017-09-05 19:07:29 +02:00
|
|
|
# Perform binder IPC to surfaceflinger (screencap)
|
|
|
|
# XXX Run screencap in a separate domain?
|
|
|
|
binder_use(adbd)
|
|
|
|
binder_call(adbd, surfaceflinger)
|
2018-11-01 21:47:51 +01:00
|
|
|
binder_call(adbd, gpuservice)
|
2017-09-05 19:07:29 +02:00
|
|
|
# b/13188914
|
|
|
|
allow adbd gpu_device:chr_file rw_file_perms;
|
2022-02-24 19:32:16 +01:00
|
|
|
allow adbd gpu_device:dir r_dir_perms;
|
2017-09-05 19:07:29 +02:00
|
|
|
allow adbd ion_device:chr_file rw_file_perms;
|
|
|
|
r_dir_file(adbd, system_file)
|
2017-04-11 02:07:04 +02:00
|
|
|
|
2017-03-25 02:38:43 +01:00
|
|
|
# Needed for various screenshots
|
|
|
|
hal_client_domain(adbd, hal_graphics_allocator)
|
2017-02-07 18:55:05 +01:00
|
|
|
|
|
|
|
# Read /data/misc/adb/adb_keys.
|
|
|
|
allow adbd adb_keys_file:dir search;
|
|
|
|
allow adbd adb_keys_file:file r_file_perms;
|
|
|
|
|
|
|
|
userdebug_or_eng(`
|
|
|
|
# Write debugging information to /data/adb
|
|
|
|
# when persist.adb.trace_mask is set
|
|
|
|
# https://code.google.com/p/android/issues/detail?id=72895
|
|
|
|
allow adbd adb_data_file:dir rw_dir_perms;
|
|
|
|
allow adbd adb_data_file:file create_file_perms;
|
|
|
|
')
|
|
|
|
|
|
|
|
# ndk-gdb invokes adb forward to forward the gdbserver socket.
|
|
|
|
allow adbd app_data_file:dir search;
|
|
|
|
allow adbd app_data_file:sock_file write;
|
|
|
|
allow adbd appdomain:unix_stream_socket connectto;
|
|
|
|
|
|
|
|
# ndk-gdb invokes adb pull of app_process, linker, and libc.so.
|
|
|
|
allow adbd zygote_exec:file r_file_perms;
|
|
|
|
allow adbd system_file:file r_file_perms;
|
|
|
|
|
|
|
|
# Allow pulling the SELinux policy for CTS purposes
|
|
|
|
allow adbd selinuxfs:dir r_dir_perms;
|
|
|
|
allow adbd selinuxfs:file r_file_perms;
|
|
|
|
allow adbd kernel:security read_policy;
|
2017-03-24 20:24:43 +01:00
|
|
|
allow adbd service_contexts_file:file r_file_perms;
|
2017-03-24 23:02:13 +01:00
|
|
|
allow adbd file_contexts_file:file r_file_perms;
|
2017-03-27 19:57:07 +02:00
|
|
|
allow adbd seapp_contexts_file:file r_file_perms;
|
2017-04-04 01:31:09 +02:00
|
|
|
allow adbd property_contexts_file:file r_file_perms;
|
|
|
|
allow adbd sepolicy_file:file r_file_perms;
|
2017-02-07 18:55:05 +01:00
|
|
|
|
2017-05-08 23:38:45 +02:00
|
|
|
# Allow pulling config.gz for CTS purposes
|
|
|
|
allow adbd config_gz:file r_file_perms;
|
|
|
|
|
2021-09-06 03:25:13 +02:00
|
|
|
# For CTS listening ports test.
|
|
|
|
allow adbd proc_net_tcp_udp:file r_file_perms;
|
|
|
|
|
2018-11-01 21:47:51 +01:00
|
|
|
allow adbd gpu_service:service_manager find;
|
2017-02-07 18:55:05 +01:00
|
|
|
allow adbd surfaceflinger_service:service_manager find;
|
|
|
|
allow adbd bootchart_data_file:dir search;
|
|
|
|
allow adbd bootchart_data_file:file r_file_perms;
|
|
|
|
|
|
|
|
# Allow access to external storage; we have several visible mount points under /storage
|
|
|
|
# and symlinks to primary storage at places like /storage/sdcard0 and /mnt/user/0/primary
|
|
|
|
allow adbd storage_file:dir r_dir_perms;
|
|
|
|
allow adbd storage_file:lnk_file r_file_perms;
|
|
|
|
allow adbd mnt_user_file:dir r_dir_perms;
|
|
|
|
allow adbd mnt_user_file:lnk_file r_file_perms;
|
|
|
|
|
|
|
|
# Access to /data/media.
|
|
|
|
# This should be removed if sdcardfs is modified to alter the secontext for its
|
|
|
|
# accesses to the underlying FS.
|
|
|
|
allow adbd media_rw_data_file:dir create_dir_perms;
|
|
|
|
allow adbd media_rw_data_file:file create_file_perms;
|
|
|
|
|
|
|
|
r_dir_file(adbd, apk_data_file)
|
|
|
|
|
|
|
|
allow adbd rootfs:dir r_dir_perms;
|
|
|
|
|
2020-03-24 22:39:41 +01:00
|
|
|
# Allow killing child "perfetto" binary processes, which auto-transition to
|
|
|
|
# their own domain. Allows propagating termination of "adb shell perfetto ..."
|
|
|
|
# invocations.
|
|
|
|
allow adbd perfetto:process signal;
|
|
|
|
|
2018-11-08 16:01:15 +01:00
|
|
|
# Allow to pull Perfetto traces.
|
|
|
|
allow adbd perfetto_traces_data_file:file r_file_perms;
|
|
|
|
allow adbd perfetto_traces_data_file:dir r_dir_perms;
|
|
|
|
|
2020-10-13 22:13:09 +02:00
|
|
|
# Allow to push and manage configs in /data/misc/perfetto-configs.
|
|
|
|
allow adbd perfetto_configs_data_file:dir rw_dir_perms;
|
|
|
|
allow adbd perfetto_configs_data_file:file create_file_perms;
|
|
|
|
|
2018-12-15 00:45:07 +01:00
|
|
|
# Connect to shell and use a socket transferred from it.
|
|
|
|
# Used for e.g. abb.
|
2020-02-06 01:19:22 +01:00
|
|
|
allow adbd shell:unix_stream_socket { read write shutdown };
|
2018-12-15 00:45:07 +01:00
|
|
|
allow adbd shell:fd use;
|
|
|
|
|
2020-10-29 12:46:15 +01:00
|
|
|
# Allow pull /vendor/apex files for CTS tests
|
|
|
|
allow adbd vendor_apex_file:dir search;
|
|
|
|
allow adbd vendor_apex_file:file r_file_perms;
|
|
|
|
|
2021-04-13 00:16:33 +02:00
|
|
|
# Allow adb pull of updated apex files in /data/apex/active.
|
|
|
|
allow adbd apex_data_file:dir search;
|
|
|
|
allow adbd staging_data_file:file r_file_perms;
|
|
|
|
|
2021-06-10 16:37:25 +02:00
|
|
|
# Allow adbd to pull /apex/apex-info-list.xml for CTS tests.
|
|
|
|
allow adbd apex_info_file:file r_file_perms;
|
|
|
|
|
2024-02-14 19:54:58 +01:00
|
|
|
# allow reading tombstones. users can already use bugreports to get those.
|
|
|
|
allow adbd tombstone_data_file:dir r_dir_perms;
|
|
|
|
allow adbd tombstone_data_file:file r_file_perms;
|
|
|
|
|
2024-03-27 09:18:41 +01:00
|
|
|
# Access /data/local/tests.
|
|
|
|
allow adbd shell_test_data_file:dir create_dir_perms;
|
|
|
|
allow adbd shell_test_data_file:file create_file_perms;
|
|
|
|
allow adbd shell_test_data_file:lnk_file create_file_perms;
|
|
|
|
|
2017-02-07 18:55:05 +01:00
|
|
|
###
|
|
|
|
### Neverallow rules
|
|
|
|
###
|
|
|
|
|
|
|
|
# No transitions from adbd to non-shell, non-crash_dump domains. adbd only ever
|
|
|
|
# transitions to the shell domain (except when it crashes). In particular, we
|
|
|
|
# never want to see a transition from adbd to su (aka "adb root")
|
2017-09-05 19:07:29 +02:00
|
|
|
neverallow adbd { domain -crash_dump -shell }:process transition;
|
2018-06-01 05:31:33 +02:00
|
|
|
neverallow adbd { domain userdebug_or_eng(`-su') recovery_only(`-shell') }:process dyntransition;
|
2024-03-27 09:18:41 +01:00
|
|
|
|
|
|
|
# Only init is allowed to enter the adbd domain via exec()
|
|
|
|
neverallow { domain -init } adbd:process transition;
|
|
|
|
neverallow * adbd:process dyntransition;
|