summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2016-06-13 23:43:11 -0700
committerJessica Wagantall <jwagantall@cyngn.com>2016-07-08 12:51:48 -0700
commitdf57cc462e068657726fb32503639c1a38b2f245 (patch)
tree063222c42fa9395e75e06dee297b0eb555eb5837
parent9ff73979bfdbbb91af3fb739d0302eadd16a4db2 (diff)
downloadandroid_frameworks_base-df57cc462e068657726fb32503639c1a38b2f245.tar.gz
android_frameworks_base-df57cc462e068657726fb32503639c1a38b2f245.tar.bz2
android_frameworks_base-df57cc462e068657726fb32503639c1a38b2f245.zip
DO NOT MERGE : backport of backup transport whitelist
Sysconfig define a whitelist of permitted backup transports Previously any apk bundled in priv-app could insert a backup transport. Reduce risk surface by giving the OEM explicit control over who is allowed to handle backup data. Bug 28406080 CYNGNOS-3020 Backport of 494df791728f4d42d67e935c327910975993ad29 from N Change-Id: I405b49daee8c576584575c3e46877cc97632d8c6
-rw-r--r--services/backup/java/com/android/server/backup/BackupManagerService.java31
-rw-r--r--services/core/java/com/android/server/SystemConfig.java26
2 files changed, 51 insertions, 6 deletions
diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java
index 6b9f4f5fab9..41e8b5bbaa2 100644
--- a/services/backup/java/com/android/server/backup/BackupManagerService.java
+++ b/services/backup/java/com/android/server/backup/BackupManagerService.java
@@ -79,7 +79,9 @@ import android.os.storage.StorageManager;
import android.provider.Settings;
import android.system.ErrnoException;
import android.system.Os;
+import android.text.TextUtils;
import android.util.ArrayMap;
+import android.util.ArraySet;
import android.util.AtomicFile;
import android.util.EventLog;
import android.util.Log;
@@ -91,6 +93,7 @@ import com.android.internal.backup.IBackupTransport;
import com.android.internal.backup.IObbBackupService;
import com.android.server.AppWidgetBackupBridge;
import com.android.server.EventLogTags;
+import com.android.server.SystemConfig;
import com.android.server.SystemService;
import com.android.server.backup.PackageManagerBackupAgent.Metadata;
@@ -336,6 +339,7 @@ public class BackupManagerService {
volatile boolean mClearingData;
// Transport bookkeeping
+ final ArraySet<ComponentName> mTransportWhitelist;
final Intent mTransportServiceIntent = new Intent(SERVICE_ACTION_TRANSPORT_HOST);
final ArrayMap<String,String> mTransportNames
= new ArrayMap<String,String>(); // component name -> registration name
@@ -1107,11 +1111,15 @@ public class BackupManagerService {
// Set up our transport options and initialize the default transport
// TODO: Don't create transports that we don't need to?
- mCurrentTransport = Settings.Secure.getString(context.getContentResolver(),
+ SystemConfig systemConfig = SystemConfig.getInstance();
+ mTransportWhitelist = systemConfig.getBackupTransportWhitelist();
+
+ String transport = Settings.Secure.getString(context.getContentResolver(),
Settings.Secure.BACKUP_TRANSPORT);
- if ("".equals(mCurrentTransport)) {
- mCurrentTransport = null;
+ if (TextUtils.isEmpty(transport)) {
+ transport = null;
}
+ mCurrentTransport = transport;
if (DEBUG) Slog.v(TAG, "Starting with transport " + mCurrentTransport);
// Find all transport hosts and bind to their services
@@ -1122,11 +1130,11 @@ public class BackupManagerService {
}
if (hosts != null) {
for (int i = 0; i < hosts.size(); i++) {
- final ServiceInfo transport = hosts.get(i).serviceInfo;
+ final ServiceInfo transportService = hosts.get(i).serviceInfo;
if (MORE_DEBUG) {
- Slog.v(TAG, " " + transport.packageName + "/" + transport.name);
+ Slog.v(TAG, " " + transportService.packageName + "/" + transportService.name);
}
- tryBindTransport(transport);
+ tryBindTransport(transportService);
}
}
@@ -1916,6 +1924,11 @@ public class BackupManagerService {
// Actually bind; presumes that we have already validated the transport service
boolean bindTransport(ServiceInfo transport) {
ComponentName svcName = new ComponentName(transport.packageName, transport.name);
+ if (!mTransportWhitelist.contains(svcName)) {
+ Slog.w(TAG, "Proposed transport " + svcName + " not whitelisted; ignoring");
+ return false;
+ }
+
if (DEBUG) {
Slog.i(TAG, "Binding to transport host " + svcName);
}
@@ -9515,6 +9528,12 @@ if (MORE_DEBUG) Slog.v(TAG, " + got " + nRead + "; now wanting " + (size - soF
+ " (now = " + System.currentTimeMillis() + ')');
pw.println(" next scheduled: " + mNextBackupPass);
+ pw.println("Transport whitelist:");
+ for (ComponentName transport : mTransportWhitelist) {
+ pw.print(" ");
+ pw.println(transport.flattenToShortString());
+ }
+
pw.println("Available transports:");
final String[] transports = listAllTransports();
if (transports != null) {
diff --git a/services/core/java/com/android/server/SystemConfig.java b/services/core/java/com/android/server/SystemConfig.java
index 1bd11261689..e0ef5ae1e69 100644
--- a/services/core/java/com/android/server/SystemConfig.java
+++ b/services/core/java/com/android/server/SystemConfig.java
@@ -17,6 +17,7 @@
package com.android.server;
import android.app.ActivityManager;
+import android.content.ComponentName;
import android.content.pm.FeatureInfo;
import android.content.pm.Signature;
import android.os.*;
@@ -89,6 +90,9 @@ public class SystemConfig {
// These are the app package names that should not allow IME switching.
final ArraySet<String> mFixedImeApps = new ArraySet<>();
+ // These are the permitted backup transport service components
+ final ArraySet<ComponentName> mBackupTransportWhitelist = new ArraySet<>();
+
final ArrayMap<Signature, ArraySet<String>> mSignatureAllowances
= new ArrayMap<Signature, ArraySet<String>>();
@@ -133,6 +137,10 @@ public class SystemConfig {
return mSignatureAllowances;
}
+ public ArraySet<ComponentName> getBackupTransportWhitelist() {
+ return mBackupTransportWhitelist;
+ }
+
SystemConfig() {
// Read configuration from system
readPermissions(Environment.buildPath(
@@ -388,6 +396,24 @@ public class SystemConfig {
XmlUtils.skipCurrentTag(parser);
continue;
+ } else if ("backup-transport-whitelisted-service".equals(name)) {
+ String serviceName = parser.getAttributeValue(null, "service");
+ if (serviceName == null) {
+ Slog.w(TAG, "<backup-transport-whitelisted-service> without service in "
+ + permFile + " at " + parser.getPositionDescription());
+ } else {
+ ComponentName cn = ComponentName.unflattenFromString(serviceName);
+ if (cn == null) {
+ Slog.w(TAG,
+ "<backup-transport-whitelisted-service> with invalid service name "
+ + serviceName + " in "+ permFile
+ + " at " + parser.getPositionDescription());
+ } else {
+ mBackupTransportWhitelist.add(cn);
+ }
+ }
+ XmlUtils.skipCurrentTag(parser);
+
} else {
XmlUtils.skipCurrentTag(parser);
continue;