adb: add SELinux policy for adbd and interactive adb shell session - #1176
Conversation
c55ae13 to
8de93b6
Compare
pebenito
left a comment
There was a problem hiding this comment.
How much testing has this received? For example, adb can operate over IP, but I see nothing about that in adbd_t. What about adb operations other than the shell?
There should probably also be tunables controlling which domain you end up in for the shell. It seems like we should be able to toggle between unconfined (if available), sysadm, and the restricted adb_shell_t.
Please rename the module to simply "adb".
Please refer to StyleGuide as this needs style cleanup.
| @@ -0,0 +1,111 @@ | |||
| policy_module(adb_shell, 1.0) | |||
There was a problem hiding this comment.
The version field is deprecated.
| files_read_var_symlinks(adb_shell_t) | ||
| files_read_mnt_symlinks(adb_shell_t) | ||
|
|
||
| dbus_system_bus_client(adb_shell_t) |
There was a problem hiding this comment.
Is dbus mandatory for adb? If not, this should be an optional_policy.
Thanks for the review and suggestions. I have renamed the module from adb_shell to adb and started cleaning up the policy according to the refpolicy StyleGuide. For testing, the current testing has mainly covered adbd startup and interactive adb shell over the local/USB path. I will expand the test coverage and document the results in the PR description, including:
Regarding the shell domain tunables, I attempted to model this as tunable-controlled transitions from adbd_t to adb_shell_t, sysadm_t, and unconfined_t using shell_exec_t as the entrypoint. However, this results in conflicting type_transition rules for the same tuple as below. Can you please help to review the change. |
8de93b6 to
e128d7f
Compare
You need to make sure the transitions are in opposite if-then-else blocks, e.g.: |
e128d7f to
e10a4dd
Compare
thanks for the suggestion and I have updated the change . |
e10a4dd to
d444c1f
Compare
|
|
||
| allow adb_shell_t self:fifo_file rw_inherited_fifo_file_perms; | ||
| allow adb_shell_t self:process { setpgid getcap signal }; | ||
| allow adb_shell_t self:capability { net_admin sys_resource }; |
There was a problem hiding this comment.
Why are these capabilities needed by default? There should be transitions to other domains for tools that need them.
There was a problem hiding this comment.
thanks , removed these capabilities.
can you please review it again.
05048b9 to
50a904a
Compare
Add SELinux policy support for the Android Debug Bridge (ADB) daemon and interactive adb shell sessions. The new module introduces the adbd_t and adb_shell_t domains and defines the transition from adbd_t to adb_shell_t when launching an interactive shell. The module also introduces the adb_unconfined_shell tunables, allowing interactive adb shell sessions to transition to the unconfined_t domains instead of the default adb_shell_t domain when enabled. The policy allows the operations required by adbd, including shell access, PTY allocation, temporary file management, log access, runtime configuration lookup, USB transport support, and file transfer operations used by adb push and adb pull. An optional adb_shell_extended_access tunable is provided for debugging and diagnostic use cases. When enabled, it grants access to selected kernel state information, sysctls, SELinux policy information, kernel logs, and other resources commonly used during troubleshooting. Signed-off-by: Jaihind Yadav <jaihindy@qti.qualcomm.com>
50a904a to
a1a878c
Compare
This patch introduces SELinux policy support for adbd and interactive
adb shell sessions.
It defines the adbd_t and adb_shell_t domains, establishes the
transition between them, and provides the permissions required for
interactive shell operation.
The module also introduces the adb_unconfined_shell tunables,
allowing interactive adb shell sessions to transition to
the unconfined_t domains instead of the default adb_shell_t domain
when enabled.
Additional debugging-related permissions are isolated behind the
adb_shell_extended_access tunable, which remains disabled by default
to preserve the default security posture while allowing developers to
enable extended debugging capabilities when needed.