MidiService: check UID in getDeviceStatus()

If a MIDI device is marked private then make sure
the status can only be obtained by the owner.

Bug: 203549963
Test: see bug for repro steps
Test: atest CtsMidiTestCases
Test: https://source.android.com/devices/audio/midi_test.html
Change-Id: Ibe92f1ca58c7971855453f1794564e95bfb9380d
This commit is contained in:
Phil Burk
2021-12-16 21:54:21 +00:00
parent 9dff8fca5c
commit 5438955940

View File

@@ -864,7 +864,15 @@ public class MidiService extends IMidiManager.Stub {
if (device == null) {
throw new IllegalArgumentException("no such device for " + deviceInfo);
}
return device.getDeviceStatus();
int uid = Binder.getCallingUid();
if (device.isUidAllowed(uid)) {
return device.getDeviceStatus();
} else {
Log.e(TAG, "getDeviceStatus() invalid UID = " + uid);
EventLog.writeEvent(0x534e4554, "203549963",
uid, "getDeviceStatus: invalid uid");
return null;
}
}
@Override