Skip to content

Commit 51640ed

Browse files
author
Android Build Coastguard Worker
committed
Merge cherrypicks of ['googleplex-android-review.googlesource.com/24308837', 'googleplex-android-review.googlesource.com/24310393', 'googleplex-android-review.googlesource.com/23982977', 'googleplex-android-review.googlesource.com/24424817', 'googleplex-android-review.googlesource.com/24270326'] into security-aosp-tm-release.
Change-Id: I67f3e69797c4afcb2703ccd7be4a5dc2e83457d2
2 parents 08f9c38 + 35ebd43 commit 51640ed

File tree

6 files changed

+72
-8
lines changed

6 files changed

+72
-8
lines changed

core/java/android/app/Notification.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3404,8 +3404,11 @@ public void setLatestEventInfo(Context context,
34043404
*
34053405
* @hide
34063406
*/
3407-
public void setAllowlistToken(@Nullable IBinder token) {
3408-
mAllowlistToken = token;
3407+
public void clearAllowlistToken() {
3408+
mAllowlistToken = null;
3409+
if (publicVersion != null) {
3410+
publicVersion.clearAllowlistToken();
3411+
}
34093412
}
34103413

34113414
/**

core/java/android/hardware/usb/UsbConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ public UsbConfiguration createFromParcel(Parcel in) {
172172
String name = in.readString();
173173
int attributes = in.readInt();
174174
int maxPower = in.readInt();
175-
Parcelable[] interfaces = in.readParcelableArray(UsbInterface.class.getClassLoader());
175+
Parcelable[] interfaces = in.readParcelableArray(
176+
UsbInterface.class.getClassLoader(), UsbInterface.class);
176177
UsbConfiguration configuration = new UsbConfiguration(id, name, attributes, maxPower);
177178
configuration.setInterfaces(interfaces);
178179
return configuration;

packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,9 @@ private boolean mutateSystemSetting(String name, String value, int runAsUserId,
19281928
cacheName = Settings.System.ALARM_ALERT_CACHE;
19291929
}
19301930
if (cacheName != null) {
1931+
if (!isValidAudioUri(name, value)) {
1932+
return false;
1933+
}
19311934
final File cacheFile = new File(
19321935
getRingtoneCacheDir(owningUserId), cacheName);
19331936
cacheFile.delete();
@@ -1960,6 +1963,34 @@ private boolean mutateSystemSetting(String name, String value, int runAsUserId,
19601963
}
19611964
}
19621965

1966+
private boolean isValidAudioUri(String name, String uri) {
1967+
if (uri != null) {
1968+
Uri audioUri = Uri.parse(uri);
1969+
if (Settings.AUTHORITY.equals(
1970+
ContentProvider.getAuthorityWithoutUserId(audioUri.getAuthority()))) {
1971+
// Don't accept setting the default uri to self-referential URIs like
1972+
// Settings.System.DEFAULT_RINGTONE_URI, which is an alias to the value of this
1973+
// setting.
1974+
return false;
1975+
}
1976+
final String mimeType = getContext().getContentResolver().getType(audioUri);
1977+
if (mimeType == null) {
1978+
Slog.e(LOG_TAG,
1979+
"mutateSystemSetting for setting: " + name + " URI: " + audioUri
1980+
+ " ignored: failure to find mimeType (no access from this context?)");
1981+
return false;
1982+
}
1983+
if (!(mimeType.startsWith("audio/") || mimeType.equals("application/ogg")
1984+
|| mimeType.equals("application/x-flac"))) {
1985+
Slog.e(LOG_TAG,
1986+
"mutateSystemSetting for setting: " + name + " URI: " + audioUri
1987+
+ " ignored: associated mimeType: " + mimeType + " is not an audio type");
1988+
return false;
1989+
}
1990+
}
1991+
return true;
1992+
}
1993+
19631994
private boolean hasWriteSecureSettingsPermission() {
19641995
// Write secure settings is a more protected permission. If caller has it we are good.
19651996
return getContext().checkCallingOrSelfPermission(Manifest.permission.WRITE_SECURE_SETTINGS)

services/core/java/com/android/server/am/ActivityManagerService.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2988,6 +2988,22 @@ private void enforceAllowedToStartOrBindServiceIfSdkSandbox(Intent intent) {
29882988
}
29892989
}
29902990

2991+
/**
2992+
* Enforces that the uid of the caller matches the uid of the package.
2993+
*
2994+
* @param packageName the name of the package to match uid against.
2995+
* @param callingUid the uid of the caller.
2996+
* @throws SecurityException if the calling uid doesn't match uid of the package.
2997+
*/
2998+
private void enforceCallingPackage(String packageName, int callingUid) {
2999+
final int userId = UserHandle.getUserId(callingUid);
3000+
final int packageUid = getPackageManagerInternal().getPackageUid(packageName,
3001+
/*flags=*/ 0, userId);
3002+
if (packageUid != callingUid) {
3003+
throw new SecurityException(packageName + " does not belong to uid " + callingUid);
3004+
}
3005+
}
3006+
29913007
@Override
29923008
public void setPackageScreenCompatMode(String packageName, int mode) {
29933009
mActivityTaskManager.setPackageScreenCompatMode(packageName, mode);
@@ -12918,13 +12934,16 @@ private void clearPendingBackup(int userId) {
1291812934
// A backup agent has just come up
1291912935
@Override
1292012936
public void backupAgentCreated(String agentPackageName, IBinder agent, int userId) {
12937+
final int callingUid = Binder.getCallingUid();
12938+
enforceCallingPackage(agentPackageName, callingUid);
12939+
1292112940
// Resolve the target user id and enforce permissions.
12922-
userId = mUserController.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
12941+
userId = mUserController.handleIncomingUser(Binder.getCallingPid(), callingUid,
1292312942
userId, /* allowAll */ false, ALLOW_FULL_ONLY, "backupAgentCreated", null);
1292412943
if (DEBUG_BACKUP) {
1292512944
Slog.v(TAG_BACKUP, "backupAgentCreated: " + agentPackageName + " = " + agent
1292612945
+ " callingUserId = " + UserHandle.getCallingUserId() + " userId = " + userId
12927-
+ " callingUid = " + Binder.getCallingUid() + " uid = " + Process.myUid());
12946+
+ " callingUid = " + callingUid + " uid = " + Process.myUid());
1292812947
}
1292912948

1293012949
synchronized(this) {

services/core/java/com/android/server/locksettings/LockSettingsService.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2992,9 +2992,19 @@ private void onCredentialVerified(AuthenticationToken authToken, PasswordMetrics
29922992
}
29932993
activateEscrowTokens(authToken, userId);
29942994

2995-
if (isProfileWithSeparatedLock(userId)) {
2996-
setDeviceUnlockedForUser(userId);
2995+
if (isCredentialSharableWithParent(userId)) {
2996+
if (getSeparateProfileChallengeEnabledInternal(userId)) {
2997+
setDeviceUnlockedForUser(userId);
2998+
} else {
2999+
// Here only clear StrongAuthFlags for a profile that has a unified challenge.
3000+
// StrongAuth for a profile with a separate challenge is handled differently and
3001+
// is cleared after the user successfully confirms the separate challenge to enter
3002+
// the profile. StrongAuth for the full user (e.g. userId 0) is also handled
3003+
// separately by Keyguard.
3004+
mStrongAuth.reportUnlock(userId);
3005+
}
29973006
}
3007+
29983008
mStrongAuth.reportSuccessfulStrongAuthUnlock(userId);
29993009

30003010
onAuthTokenKnownForUser(userId, authToken);

services/core/java/com/android/server/notification/NotificationManagerService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4341,7 +4341,7 @@ private StatusBarNotification sanitizeSbn(String pkg, int userId,
43414341
// Remove background token before returning notification to untrusted app, this
43424342
// ensures the app isn't able to perform background operations that are
43434343
// associated with notification interactions.
4344-
notification.setAllowlistToken(null);
4344+
notification.clearAllowlistToken();
43454345
return new StatusBarNotification(
43464346
sbn.getPackageName(),
43474347
sbn.getOpPkg(),

0 commit comments

Comments
 (0)