Skip to content

Commit c864b4c

Browse files
author
android-build-team Robot
committed
Snap for 6823548 from 6ee8dcd to rvc-qpr1-release
Change-Id: I75f8c30e4d4eb8f0b7229772e8b1a0aa3395acfa
2 parents 2128462 + 6ee8dcd commit c864b4c

File tree

8 files changed

+46
-0
lines changed

8 files changed

+46
-0
lines changed

prebuilts/api/30.0/private/system_server.te

+7
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,9 @@ get_prop(system_server, time_prop)
973973
# on low memory kills.
974974
get_prop(system_server, system_lmk_prop)
975975

976+
# Only system server can access BINDER_FREEZE
977+
allowxperm system_server binder_device:chr_file ioctl { BINDER_FREEZE };
978+
976979
###
977980
### Neverallow rules
978981
###
@@ -1172,3 +1175,7 @@ neverallow system_server self:perf_event ~{ open write cpu kernel };
11721175

11731176
# Do not allow any domain other than init or system server to set the property
11741177
neverallow { domain -init -system_server } socket_hook_prop:property_service set;
1178+
1179+
# BINDER_FREEZE is used to block ipc transactions to frozen processes, so it
1180+
# can be accessed by system_server only (b/143717177)
1181+
neverallowxperm { domain -system_server } binder_device:chr_file ioctl { BINDER_FREEZE };

prebuilts/api/30.0/public/domain.te

+4
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ allow domain ashmem_libcutils_device:chr_file rw_file_perms;
8080
# /dev/binder can be accessed by ... everyone! :)
8181
allow { domain -hwservicemanager -vndservicemanager } binder_device:chr_file rw_file_perms;
8282

83+
# Restrict binder ioctls to an allowlist. Additional ioctl commands may be
84+
# added to individual domains, but this sets safe defaults for all processes.
85+
allowxperm domain binder_device:chr_file ioctl unpriv_binder_ioctls;
86+
8387
# /dev/binderfs needs to be accessed by everyone too!
8488
allow domain binderfs:dir { getattr search };
8589
allow domain binderfs_logs_proc:dir search;

prebuilts/api/30.0/public/ioctl_defines

+4
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ define(`BC_RELEASE', `0x40046306')
132132
define(`BC_REPLY', `0x40406301')
133133
define(`BC_REQUEST_DEATH_NOTIFICATION', `0x400c630e')
134134
define(`BC_TRANSACTION', `0x40406300')
135+
define(`BINDER_FREEZE', `0x400c620e')
136+
define(`BINDER_GET_NODE_DEBUG_INFO', `0xc018620b')
137+
define(`BINDER_GET_NODE_INFO_FOR_REF', `0xc018620c')
135138
define(`BINDER_SET_CONTEXT_MGR', `0x40046207')
139+
define(`BINDER_SET_CONTEXT_MGR_EXT', `0x4018620d')
136140
define(`BINDER_SET_IDLE_PRIORITY', `0x40046206')
137141
define(`BINDER_SET_IDLE_TIMEOUT', `0x40086203')
138142
define(`BINDER_SET_MAX_THREADS', `0x40046205')

prebuilts/api/30.0/public/ioctl_macros

+8
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,11 @@ PPPIOCGASYNCMAP PPPIOCSFLAGS PPPIOCGFLAGS PPPIOCGCALLINFO
6666
PPPIOCBUNDLE PPPIOCGMPFLAGS PPPIOCSMPFLAGS PPPIOCSMPMTU
6767
PPPIOCSMPMRU PPPIOCGCOMPRESSORS PPPIOCSCOMPRESSOR PPPIOCGIFNAME
6868
}')
69+
70+
# unprivileged binder ioctls
71+
define(`unpriv_binder_ioctls', `{
72+
BINDER_WRITE_READ BINDER_SET_IDLE_TIMEOUT BINDER_SET_MAX_THREADS
73+
BINDER_SET_IDLE_PRIORITY BINDER_SET_CONTEXT_MGR BINDER_THREAD_EXIT
74+
BINDER_VERSION BINDER_GET_NODE_DEBUG_INFO BINDER_GET_NODE_INFO_FOR_REF
75+
BINDER_SET_CONTEXT_MGR_EXT
76+
}')

private/system_server.te

+7
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,9 @@ get_prop(system_server, time_prop)
973973
# on low memory kills.
974974
get_prop(system_server, system_lmk_prop)
975975

976+
# Only system server can access BINDER_FREEZE
977+
allowxperm system_server binder_device:chr_file ioctl { BINDER_FREEZE };
978+
976979
###
977980
### Neverallow rules
978981
###
@@ -1172,3 +1175,7 @@ neverallow system_server self:perf_event ~{ open write cpu kernel };
11721175

11731176
# Do not allow any domain other than init or system server to set the property
11741177
neverallow { domain -init -system_server } socket_hook_prop:property_service set;
1178+
1179+
# BINDER_FREEZE is used to block ipc transactions to frozen processes, so it
1180+
# can be accessed by system_server only (b/143717177)
1181+
neverallowxperm { domain -system_server } binder_device:chr_file ioctl { BINDER_FREEZE };

public/domain.te

+4
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ allow domain ashmem_libcutils_device:chr_file rw_file_perms;
8080
# /dev/binder can be accessed by ... everyone! :)
8181
allow { domain -hwservicemanager -vndservicemanager } binder_device:chr_file rw_file_perms;
8282

83+
# Restrict binder ioctls to an allowlist. Additional ioctl commands may be
84+
# added to individual domains, but this sets safe defaults for all processes.
85+
allowxperm domain binder_device:chr_file ioctl unpriv_binder_ioctls;
86+
8387
# /dev/binderfs needs to be accessed by everyone too!
8488
allow domain binderfs:dir { getattr search };
8589
allow domain binderfs_logs_proc:dir search;

public/ioctl_defines

+4
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ define(`BC_RELEASE', `0x40046306')
132132
define(`BC_REPLY', `0x40406301')
133133
define(`BC_REQUEST_DEATH_NOTIFICATION', `0x400c630e')
134134
define(`BC_TRANSACTION', `0x40406300')
135+
define(`BINDER_FREEZE', `0x400c620e')
136+
define(`BINDER_GET_NODE_DEBUG_INFO', `0xc018620b')
137+
define(`BINDER_GET_NODE_INFO_FOR_REF', `0xc018620c')
135138
define(`BINDER_SET_CONTEXT_MGR', `0x40046207')
139+
define(`BINDER_SET_CONTEXT_MGR_EXT', `0x4018620d')
136140
define(`BINDER_SET_IDLE_PRIORITY', `0x40046206')
137141
define(`BINDER_SET_IDLE_TIMEOUT', `0x40086203')
138142
define(`BINDER_SET_MAX_THREADS', `0x40046205')

public/ioctl_macros

+8
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,11 @@ PPPIOCGASYNCMAP PPPIOCSFLAGS PPPIOCGFLAGS PPPIOCGCALLINFO
6666
PPPIOCBUNDLE PPPIOCGMPFLAGS PPPIOCSMPFLAGS PPPIOCSMPMTU
6767
PPPIOCSMPMRU PPPIOCGCOMPRESSORS PPPIOCSCOMPRESSOR PPPIOCGIFNAME
6868
}')
69+
70+
# unprivileged binder ioctls
71+
define(`unpriv_binder_ioctls', `{
72+
BINDER_WRITE_READ BINDER_SET_IDLE_TIMEOUT BINDER_SET_MAX_THREADS
73+
BINDER_SET_IDLE_PRIORITY BINDER_SET_CONTEXT_MGR BINDER_THREAD_EXIT
74+
BINDER_VERSION BINDER_GET_NODE_DEBUG_INFO BINDER_GET_NODE_INFO_FOR_REF
75+
BINDER_SET_CONTEXT_MGR_EXT
76+
}')

0 commit comments

Comments
 (0)