|
| 1 | +From a1e39f150a5ab95a7c251bf7c88ed3aa5e2443db Mon Sep 17 00:00:00 2001 |
| 2 | +From: kancharx <kancharlax.suresh@intel.com> |
| 3 | +Date: Wed, 3 Dec 2025 13:36:13 +0000 |
| 4 | +Subject: [PATCH] [CVE_2025_26436]RESTRICT AUTOMERGE Clear the BAL allowlist |
| 5 | + duration |
| 6 | + |
| 7 | +Tracked-On: OAM-134642 |
| 8 | +Signed-off-by: kancharx <kancharlax.suresh@intel.com> |
| 9 | + |
| 10 | +Clearing BAL privileges of a PendingIntent only cleared the tokens, |
| 11 | +but kept the duration based entries. `clearAllowBgActivityStarts` is exclusively used by SystemUI (in NotificationManagerService) and fixing this is part of fixing a security vulnerability (therefore and because this is a low risk change it is not flag guarded). |
| 12 | + |
| 13 | +BYPASS_INCLUSIVE_LANGUAGE_REASON=Using an existing API |
| 14 | + |
| 15 | +Bug: 322159724 |
| 16 | +Flag: EXEMPT bugfix |
| 17 | +Test: atest PendingIntentControllerTest |
| 18 | +(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:5782703d0f7c913477f1dd59b11e6e6e879199d9) |
| 19 | +(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:014d574afb413850c300f07af43148bf8ff684b6) |
| 20 | +Merged-In: I88e4df8fe4989fbc26aaa0e672626f3a1042678e |
| 21 | +Change-Id: I88e4df8fe4989fbc26aaa0e672626f3a1042678e |
| 22 | +--- |
| 23 | + .../server/am/PendingIntentRecord.java | 14 ++++++- |
| 24 | + .../am/PendingIntentControllerTest.java | 41 +++++++++++++++++++ |
| 25 | + 2 files changed, 54 insertions(+), 1 deletion(-) |
| 26 | + |
| 27 | +diff --git a/services/core/java/com/android/server/am/PendingIntentRecord.java b/services/core/java/com/android/server/am/PendingIntentRecord.java |
| 28 | +index 3817ba1a28b9..91501701e815 100644 |
| 29 | +--- a/services/core/java/com/android/server/am/PendingIntentRecord.java |
| 30 | ++++ b/services/core/java/com/android/server/am/PendingIntentRecord.java |
| 31 | +@@ -18,6 +18,8 @@ package com.android.server.am; |
| 32 | + |
| 33 | + import static android.app.ActivityManager.PROCESS_STATE_TOP; |
| 34 | + import static android.app.ActivityManager.START_SUCCESS; |
| 35 | ++import static android.os.PowerWhitelistManager.TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED; |
| 36 | ++import static android.os.PowerWhitelistManager.TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_NOT_ALLOWED; |
| 37 | + import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED; |
| 38 | + import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS; |
| 39 | + import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_COMPAT; |
| 40 | +@@ -304,6 +306,9 @@ public final class PendingIntentRecord extends IIntentSender.Stub { |
| 41 | + } |
| 42 | + this.stringName = null; |
| 43 | + } |
| 44 | ++ @VisibleForTesting TempAllowListDuration getAllowlistDurationLocked(IBinder allowlistToken) { |
| 45 | ++ return mAllowlistDuration.get(allowlistToken); |
| 46 | ++ } |
| 47 | + |
| 48 | + void setAllowBgActivityStarts(IBinder token, int flags) { |
| 49 | + if (token == null) return; |
| 50 | +@@ -323,6 +328,13 @@ public final class PendingIntentRecord extends IIntentSender.Stub { |
| 51 | + mAllowBgActivityStartsForActivitySender.remove(token); |
| 52 | + mAllowBgActivityStartsForBroadcastSender.remove(token); |
| 53 | + mAllowBgActivityStartsForServiceSender.remove(token); |
| 54 | ++ if (mAllowlistDuration != null) { |
| 55 | ++ TempAllowListDuration duration = mAllowlistDuration.get(token); |
| 56 | ++ if (duration != null |
| 57 | ++ && duration.type == TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED) { |
| 58 | ++ duration.type = TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_NOT_ALLOWED; |
| 59 | ++ } |
| 60 | ++ } |
| 61 | + } |
| 62 | + |
| 63 | + public void registerCancelListenerLocked(IResultReceiver receiver) { |
| 64 | +@@ -703,7 +715,7 @@ public final class PendingIntentRecord extends IIntentSender.Stub { |
| 65 | + return res; |
| 66 | + } |
| 67 | + |
| 68 | +- private BackgroundStartPrivileges getBackgroundStartPrivilegesForActivitySender( |
| 69 | ++ @VisibleForTesting BackgroundStartPrivileges getBackgroundStartPrivilegesForActivitySender( |
| 70 | + IBinder allowlistToken) { |
| 71 | + return mAllowBgActivityStartsForActivitySender.contains(allowlistToken) |
| 72 | + ? BackgroundStartPrivileges.allowBackgroundActivityStarts(allowlistToken) |
| 73 | +diff --git a/services/tests/mockingservicestests/src/com/android/server/am/PendingIntentControllerTest.java b/services/tests/mockingservicestests/src/com/android/server/am/PendingIntentControllerTest.java |
| 74 | +index 89b48bad2358..d3727ed5e988 100644 |
| 75 | +--- a/services/tests/mockingservicestests/src/com/android/server/am/PendingIntentControllerTest.java |
| 76 | ++++ b/services/tests/mockingservicestests/src/com/android/server/am/PendingIntentControllerTest.java |
| 77 | +@@ -16,11 +16,16 @@ |
| 78 | + |
| 79 | + package com.android.server.am; |
| 80 | + |
| 81 | ++import static android.os.PowerWhitelistManager.REASON_NOTIFICATION_SERVICE; |
| 82 | ++import static android.os.PowerWhitelistManager.TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED; |
| 83 | ++import static android.os.PowerWhitelistManager.TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_NOT_ALLOWED; |
| 84 | ++ |
| 85 | + import static android.os.Process.INVALID_UID; |
| 86 | + |
| 87 | + import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; |
| 88 | + import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession; |
| 89 | + import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; |
| 90 | ++import static com.android.server.am.PendingIntentRecord.FLAG_ACTIVITY_SENDER; |
| 91 | + import static com.android.server.am.PendingIntentRecord.CANCEL_REASON_NULL; |
| 92 | + import static com.android.server.am.PendingIntentRecord.CANCEL_REASON_ONE_SHOT_SENT; |
| 93 | + import static com.android.server.am.PendingIntentRecord.CANCEL_REASON_OWNER_CANCELED; |
| 94 | +@@ -30,6 +35,7 @@ import static com.android.server.am.PendingIntentRecord.CANCEL_REASON_USER_STOPP |
| 95 | + import static com.android.server.am.PendingIntentRecord.cancelReasonToString; |
| 96 | + |
| 97 | + import static org.junit.Assert.assertEquals; |
| 98 | ++import static org.junit.Assert.assertNotNull; |
| 99 | + import static org.mockito.ArgumentMatchers.anyInt; |
| 100 | + import static org.mockito.ArgumentMatchers.anyLong; |
| 101 | + import static org.mockito.ArgumentMatchers.eq; |
| 102 | +@@ -39,9 +45,11 @@ import static org.mockito.Mockito.when; |
| 103 | + import android.app.ActivityManager; |
| 104 | + import android.app.ActivityManagerInternal; |
| 105 | + import android.app.AppGlobals; |
| 106 | ++import android.app.BackgroundStartPrivileges; |
| 107 | + import android.app.PendingIntent; |
| 108 | + import android.content.Intent; |
| 109 | + import android.content.pm.IPackageManager; |
| 110 | ++import android.os.Binder; |
| 111 | + import android.os.Looper; |
| 112 | + import android.os.UserHandle; |
| 113 | + |
| 114 | +@@ -185,6 +193,39 @@ public class PendingIntentControllerTest { |
| 115 | + assertEquals(errMsg, expectedReason, actualReason); |
| 116 | + } |
| 117 | + |
| 118 | ++ @Test |
| 119 | ++ public void testClearAllowBgActivityStartsClearsToken() { |
| 120 | ++ final PendingIntentRecord pir = createPendingIntentRecord(0); |
| 121 | ++ Binder token = new Binder(); |
| 122 | ++ pir.setAllowBgActivityStarts(token, FLAG_ACTIVITY_SENDER); |
| 123 | ++ assertEquals(BackgroundStartPrivileges.allowBackgroundActivityStarts(token), |
| 124 | ++ pir.getBackgroundStartPrivilegesForActivitySender(token)); |
| 125 | ++ pir.clearAllowBgActivityStarts(token); |
| 126 | ++ assertEquals(BackgroundStartPrivileges.NONE, |
| 127 | ++ pir.getBackgroundStartPrivilegesForActivitySender(token)); |
| 128 | ++ } |
| 129 | ++ |
| 130 | ++ @Test |
| 131 | ++ public void testClearAllowBgActivityStartsClearsDuration() { |
| 132 | ++ final PendingIntentRecord pir = createPendingIntentRecord(0); |
| 133 | ++ Binder token = new Binder(); |
| 134 | ++ pir.setAllowlistDurationLocked(token, 1000, |
| 135 | ++ TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED, REASON_NOTIFICATION_SERVICE, |
| 136 | ++ "NotificationManagerService"); |
| 137 | ++ PendingIntentRecord.TempAllowListDuration allowlistDurationLocked = |
| 138 | ++ pir.getAllowlistDurationLocked(token); |
| 139 | ++ assertEquals(1000, allowlistDurationLocked.duration); |
| 140 | ++ assertEquals(TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED, |
| 141 | ++ allowlistDurationLocked.type); |
| 142 | ++ pir.clearAllowBgActivityStarts(token); |
| 143 | ++ PendingIntentRecord.TempAllowListDuration allowlistDurationLockedAfterClear = |
| 144 | ++ pir.getAllowlistDurationLocked(token); |
| 145 | ++ assertNotNull(allowlistDurationLockedAfterClear); |
| 146 | ++ assertEquals(1000, allowlistDurationLockedAfterClear.duration); |
| 147 | ++ assertEquals(TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_NOT_ALLOWED, |
| 148 | ++ allowlistDurationLocked.type); |
| 149 | ++ } |
| 150 | ++ |
| 151 | + @After |
| 152 | + public void tearDown() { |
| 153 | + if (mMockingSession != null) { |
| 154 | +-- |
| 155 | +2.34.1 |
| 156 | + |
0 commit comments