diff options
| author | 2016-12-22 17:19:10 +0000 | |
|---|---|---|
| committer | 2016-12-22 17:19:10 +0000 | |
| commit | d28eef0cc2b5cc8b01f3e36a883bfaa529ec0cfd (patch) | |
| tree | c63bc7a72260b15fb4ca7403834fd633f666adcf | |
| parent | 920b02a94fb7e9ecd7f07fa96370e1858b7c85c7 (diff) | |
| parent | 1684e5f344e385a88c5f672619c4aeaed9417957 (diff) | |
Fix exploit where can hide the fact that a location was mocked am: a206a0f17e am: d417e54872 am: 3380a77516 am: 0a8978f04b
am: 1684e5f344
Change-Id: I0ebd2856e2e2f3793273ba952b44dc77e85b021e
| -rw-r--r-- | services/core/java/com/android/server/LocationManagerService.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java index be83b9b26fd0..771491b749f4 100644 --- a/services/core/java/com/android/server/LocationManagerService.java +++ b/services/core/java/com/android/server/LocationManagerService.java @@ -87,6 +87,8 @@ import android.os.UserHandle; import android.os.UserManager; import android.os.WorkSource; import android.provider.Settings; +import android.text.TextUtils; +import android.util.EventLog; import android.util.Log; import android.util.Slog; @@ -2435,9 +2437,22 @@ public class LocationManagerService extends ILocationManager.Stub { if (mockProvider == null) { throw new IllegalArgumentException("Provider \"" + provider + "\" unknown"); } + + // Ensure that the location is marked as being mock. There's some logic to do this in + // handleLocationChanged(), but it fails if loc has the wrong provider (bug 33091107). + Location mock = new Location(loc); + mock.setIsFromMockProvider(true); + + if (!TextUtils.isEmpty(loc.getProvider()) && !provider.equals(loc.getProvider())) { + // The location has an explicit provider that is different from the mock provider + // name. The caller may be trying to fool us via bug 33091107. + EventLog.writeEvent(0x534e4554, "33091107", Binder.getCallingUid(), + provider + "!=" + loc.getProvider()); + } + // clear calling identity so INSTALL_LOCATION_PROVIDER permission is not required long identity = Binder.clearCallingIdentity(); - mockProvider.setLocation(loc); + mockProvider.setLocation(mock); Binder.restoreCallingIdentity(identity); } } |