Fix exploit where can hide the fact that a location was mocked am: a206a0f17e am: d417e54872 am: 3380a77516 am: 0a8978f04b am: 1684e5f344 am: d28eef0cc2
am: 1f458fdc66
Change-Id: I61d4b25ee0264397693f30e2091997c058d0c5fc
This commit is contained in:
@@ -87,6 +87,8 @@ import android.os.UserHandle;
|
|||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.os.WorkSource;
|
import android.os.WorkSource;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.EventLog;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
|
||||||
@@ -2505,9 +2507,22 @@ public class LocationManagerService extends ILocationManager.Stub {
|
|||||||
if (mockProvider == null) {
|
if (mockProvider == null) {
|
||||||
throw new IllegalArgumentException("Provider \"" + provider + "\" unknown");
|
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
|
// clear calling identity so INSTALL_LOCATION_PROVIDER permission is not required
|
||||||
long identity = Binder.clearCallingIdentity();
|
long identity = Binder.clearCallingIdentity();
|
||||||
mockProvider.setLocation(loc);
|
mockProvider.setLocation(mock);
|
||||||
Binder.restoreCallingIdentity(identity);
|
Binder.restoreCallingIdentity(identity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user