Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c412a22 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

SchedulingPolicyService: add extra check for the target UID

When audio HAL is asking to boost priority of its I/O thread
it passes TID to the audio service. To reduce the chance of
boosting priority of a wrong thread due to PID wrapping,
ensure that the target thread belongs to the right UID.

Bug: 181148259
Test: manual validation of thread priorities
Change-Id: I73dc30492b292bede95e6fc38f318ef966f417ca
parent fa304e1f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -92,6 +92,12 @@ public class SchedulingPolicyService extends ISchedulingPolicyService.Stub {
                prio > PRIORITY_MAX || Process.getThreadGroupLeader(tid) != pid) {
           return PackageManager.PERMISSION_DENIED;
        }
        // If the calling UID is audio server, and this call is not for an app,
        // then it must be for the audio HAL. Validate the UID of the thread.
        if (Binder.getCallingUid() == Process.AUDIOSERVER_UID && !isForApp
                && Process.getUidForPid(tid) != Process.AUDIOSERVER_UID) {
            return PackageManager.PERMISSION_DENIED;
        }
        if (Binder.getCallingUid() != Process.BLUETOOTH_UID) {
            try {
                // make good use of our CAP_SYS_NICE capability