Skip to content

Commit

Permalink
Fix exploit where can hide the fact that a location was mocked
Browse files Browse the repository at this point in the history
- Even if call setTestProviderLocation() with inconsistent providers,
should still end up with a location that is flagged as mocked

- Bug: 33091107

Change-Id: I39e038f25b975989c2e8651bfd9ec9e74073e6cd
  • Loading branch information
Tom O'Neill committed Dec 15, 2016
1 parent 418e086 commit a206a0f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion services/java/com/android/server/LocationManagerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
import android.os.UserHandle;
import android.os.WorkSource;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.EventLog;
import android.util.Log;
import android.util.Slog;
import com.android.internal.content.PackageMonitor;
Expand Down Expand Up @@ -2247,9 +2249,22 @@ public void setTestProviderLocation(String provider, Location loc) {
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);
}
}
Expand Down

0 comments on commit a206a0f

Please sign in to comment.