Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit 203e27b

Browse files
15.1: June ASB work
Signed-off-by: Tavi <[email protected]>
1 parent 7e6c6ad commit 203e27b

File tree

6 files changed

+234
-1
lines changed

6 files changed

+234
-1
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
From 2d2a31353a07daf096aa9e2ca09e18ad2773b1ba Mon Sep 17 00:00:00 2001
2+
From: Dmitry Dementyev <[email protected]>
3+
Date: Tue, 26 Mar 2024 10:31:44 -0700
4+
Subject: [PATCH] Add more checkKeyIntent checks to AccountManagerService.
5+
6+
Another verification is needed after Bundle modification.
7+
Bug: 321941232
8+
Test: manual
9+
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:36db8a1d61a881f89fdd3911886adcda6e1f0d7f)
10+
Merged-In: I9e45d758a2320328da5664b6341eafe6f285f297
11+
Change-Id: I9e45d758a2320328da5664b6341eafe6f285f297
12+
---
13+
.../android/server/accounts/AccountManagerService.java | 10 ++++++++++
14+
1 file changed, 10 insertions(+)
15+
16+
diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java
17+
index 4e4c261d0cc46..19e1a4c55120a 100644
18+
--- a/services/core/java/com/android/server/accounts/AccountManagerService.java
19+
+++ b/services/core/java/com/android/server/accounts/AccountManagerService.java
20+
@@ -3453,6 +3453,11 @@ public void onResult(Bundle result) {
21+
22+
// Strip auth token from result.
23+
result.remove(AccountManager.KEY_AUTHTOKEN);
24+
+ if (!checkKeyIntent(Binder.getCallingUid(), result)) {
25+
+ onError(AccountManager.ERROR_CODE_INVALID_RESPONSE,
26+
+ "invalid intent in bundle returned");
27+
+ return;
28+
+ }
29+
30+
if (Log.isLoggable(TAG, Log.VERBOSE)) {
31+
Log.v(TAG,
32+
@@ -5039,6 +5044,11 @@ public void onResult(Bundle result) {
33+
} else {
34+
if (mStripAuthTokenFromResult) {
35+
result.remove(AccountManager.KEY_AUTHTOKEN);
36+
+ if (!checkKeyIntent(Binder.getCallingUid(), result)) {
37+
+ onError(AccountManager.ERROR_CODE_INVALID_RESPONSE,
38+
+ "invalid intent in bundle returned");
39+
+ return;
40+
+ }
41+
}
42+
if (Log.isLoggable(TAG, Log.VERBOSE)) {
43+
Log.v(TAG, getClass().getSimpleName()
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
From a568a9144f1a804e4ac136522dfcd1f8aaae81a3 Mon Sep 17 00:00:00 2001
2+
From: Chris Wailes <[email protected]>
3+
Date: Thu, 18 Apr 2019 18:25:57 -0700
4+
Subject: [PATCH] Adds additional sanitization for Zygote command arguments.
5+
6+
Previously we were only insuring that the arguments provided to the
7+
Zygote didn't contain any newlines. This adds additional checks for
8+
carriage returns and standalone integer arguments to protect against
9+
malicious argument and packet injection respectively.
10+
11+
Bug: 130164289
12+
Test: m & flash & boot & check logs
13+
Change-Id: I4055c50d52db0047c02c11096710fd07b429660c
14+
Merged-In: I4055c50d52db0047c02c11096710fd07b429660c
15+
(cherry picked from commit c99198249f8bb79487d4f9f0f45b5b2fefaba41a)
16+
---
17+
core/java/android/os/ZygoteProcess.java | 9 +++++++--
18+
1 file changed, 7 insertions(+), 2 deletions(-)
19+
20+
diff --git a/core/java/android/os/ZygoteProcess.java b/core/java/android/os/ZygoteProcess.java
21+
index 6994033a963a8..904ec46859fa4 100644
22+
--- a/core/java/android/os/ZygoteProcess.java
23+
+++ b/core/java/android/os/ZygoteProcess.java
24+
@@ -16,6 +16,7 @@
25+
26+
package android.os;
27+
28+
+import android.annotation.NonNull;
29+
import android.net.LocalSocket;
30+
import android.net.LocalSocketAddress;
31+
import android.util.Log;
32+
@@ -278,15 +279,19 @@ private static String getAbiList(BufferedWriter writer, DataInputStream inputStr
33+
*/
34+
@GuardedBy("mLock")
35+
private static Process.ProcessStartResult zygoteSendArgsAndGetResult(
36+
- ZygoteState zygoteState, ArrayList<String> args)
37+
+ ZygoteState zygoteState, @NonNull ArrayList<String> args)
38+
throws ZygoteStartFailedEx {
39+
try {
40+
// Throw early if any of the arguments are malformed. This means we can
41+
// avoid writing a partial response to the zygote.
42+
int sz = args.size();
43+
for (int i = 0; i < sz; i++) {
44+
+ // Making two indexOf calls here is faster than running a manually fused loop due
45+
+ // to the fact that indexOf is a optimized intrinsic.
46+
if (args.get(i).indexOf('\n') >= 0) {
47+
- throw new ZygoteStartFailedEx("embedded newlines not allowed");
48+
+ throw new ZygoteStartFailedEx("Embedded newlines not allowed");
49+
+ } else if (args.get(i).indexOf('\r') >= 0) {
50+
+ throw new ZygoteStartFailedEx("Embedded carriage returns not allowed");
51+
}
52+
}
53+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
From 00ff56bb646c525192f06cbeed96c3dc78d45795 Mon Sep 17 00:00:00 2001
2+
From: Hans Boehm <[email protected]>
3+
Date: Tue, 2 Jan 2024 16:53:13 -0800
4+
Subject: [PATCH] Check hidden API exemptions
5+
6+
Refuse to deal with newlines and null characters in
7+
HiddenApiSettings.update(). Also disallow nulls in process start
8+
arguments.
9+
10+
Bug: 316153291
11+
Test: Treehugger for now
12+
(cherry picked from commit 7ba059e2cf0a2c20f9a849719cdc32b12c933a44)
13+
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:60669aa49aba34c0950d6246bd95b54f91a3c8e8)
14+
Merged-In: I83cd60e46407a4a082f9f3c80e937dbd522dbac4
15+
Change-Id: I83cd60e46407a4a082f9f3c80e937dbd522dbac4
16+
---
17+
core/java/android/os/ZygoteProcess.java | 2 ++
18+
1 file changed, 2 insertions(+)
19+
20+
diff --git a/core/java/android/os/ZygoteProcess.java b/core/java/android/os/ZygoteProcess.java
21+
index 904ec46859fa4..aab1d9d578031 100644
22+
--- a/core/java/android/os/ZygoteProcess.java
23+
+++ b/core/java/android/os/ZygoteProcess.java
24+
@@ -292,6 +292,8 @@ private static Process.ProcessStartResult zygoteSendArgsAndGetResult(
25+
throw new ZygoteStartFailedEx("Embedded newlines not allowed");
26+
} else if (args.get(i).indexOf('\r') >= 0) {
27+
throw new ZygoteStartFailedEx("Embedded carriage returns not allowed");
28+
+ } else if (args.get(i).indexOf('\u0000') >= 0) {
29+
+ throw new ZygoteStartFailedEx("Embedded nulls not allowed");
30+
}
31+
}
32+
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Ameer Armaly <[email protected]>
3+
Date: Fri, 8 Mar 2024 19:41:06 +0000
4+
Subject: [PATCH] AccessibilityManagerService: remove uninstalled services from
5+
enabled list after service update.
6+
7+
Bug: 326485767
8+
Test: atest AccessibilityEndToEndTest#testUpdateServiceWithoutIntent_disablesService
9+
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:5405514a23edcba0cf30e6ec78189e3f4e7d95cf)
10+
Merged-In: I5e59296fcad68e62b34c74ee5fd80b6ad6b46fa1
11+
Change-Id: I5e59296fcad68e62b34c74ee5fd80b6ad6b46fa1
12+
---
13+
.../AccessibilityManagerService.java | 23 +++++++++++++++++++
14+
1 file changed, 23 insertions(+)
15+
16+
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
17+
index 1e07aa5d4376..99f997220c40 100644
18+
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
19+
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
20+
@@ -1548,10 +1548,13 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
21+
boolean isUnlockingOrUnlocked = LocalServices.getService(UserManagerInternal.class)
22+
.isUserUnlockingOrUnlocked(userState.mUserId);
23+
24+
+ // Store the list of installed services.
25+
+ mTempComponentNameSet.clear();
26+
for (int i = 0, count = userState.mInstalledServices.size(); i < count; i++) {
27+
AccessibilityServiceInfo installedService = userState.mInstalledServices.get(i);
28+
ComponentName componentName = ComponentName.unflattenFromString(
29+
installedService.getId());
30+
+ mTempComponentNameSet.add(componentName);
31+
32+
Service service = componentNameToServiceMap.get(componentName);
33+
34+
@@ -1594,6 +1597,26 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
35+
if (audioManager != null) {
36+
audioManager.setAccessibilityServiceUids(mTempIntArray);
37+
}
38+
+
39+
+ // If any services have been removed, remove them from the enabled list and the touch
40+
+ // exploration granted list.
41+
+ boolean anyServiceRemoved =
42+
+ userState.mEnabledServices.removeIf((comp) -> !mTempComponentNameSet.contains(comp))
43+
+ || userState.mTouchExplorationGrantedServices.removeIf(
44+
+ (comp) -> !mTempComponentNameSet.contains(comp));
45+
+ if (anyServiceRemoved) {
46+
+ // Update the enabled services setting.
47+
+ persistComponentNamesToSettingLocked(
48+
+ Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
49+
+ userState.mEnabledServices,
50+
+ userState.mUserId);
51+
+ // Update the touch exploration granted services setting.
52+
+ persistComponentNamesToSettingLocked(
53+
+ Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
54+
+ userState.mTouchExplorationGrantedServices,
55+
+ userState.mUserId);
56+
+ }
57+
+ mTempComponentNameSet.clear();
58+
updateAccessibilityEnabledSetting(userState);
59+
}
60+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
From 538cc6c384985f272dc7ab6c7cc7222a59b4c341 Mon Sep 17 00:00:00 2001
2+
From: Guojing Yuan <[email protected]>
3+
Date: Thu, 14 Dec 2023 19:30:04 +0000
4+
Subject: [PATCH] [BACKPORT] Check permissions for CDM shell commands
5+
6+
Override handleShellCommand instead of onShellCommand because
7+
Binder.onShellCommand checks the necessary permissions of the caller.
8+
9+
Backport by [email protected]:
10+
In Pie, method handleShellCommand does not exist, only Binder.onShellCommand, in which
11+
the caller uid check isn't yet implemented. Backport: Take over the uid check from A11
12+
and implement it in the method override.
13+
14+
Bug: 313428840
15+
16+
Test: manually tested CDM shell commands
17+
(cherry picked from commit 1761a0fee9c2cd9787bbb7fbdbe30b4c2b03396e)
18+
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:8d008c61451dba86aa9f14c6bcd661db2cea4856)
19+
Merged-In: I5539b3594feb5544c458c0fd1061b51a0a808900
20+
Change-Id: I5539b3594feb5544c458c0fd1061b51a0a808900
21+
---
22+
.../server/companion/CompanionDeviceManagerService.java | 5 +++++
23+
1 file changed, 5 insertions(+)
24+
25+
diff --git a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
26+
index 087fe8560fc80..8ffb53f8a3b9d 100644
27+
--- a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
28+
+++ b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java
29+
@@ -345,6 +345,11 @@ private void checkUsesFeature(String pkg, int userId) {
30+
public void onShellCommand(FileDescriptor in, FileDescriptor out, FileDescriptor err,
31+
String[] args, ShellCallback callback, ResultReceiver resultReceiver)
32+
throws RemoteException {
33+
+ final int callingUid = Binder.getCallingUid();
34+
+ if (callingUid != Process.ROOT_UID && callingUid != Process.SHELL_UID) {
35+
+ resultReceiver.send(-1, null);
36+
+ throw new RemoteException("Shell commands are only callable by ADB");
37+
+ }
38+
new ShellCmd().exec(this, in, out, err, args, callback, resultReceiver);
39+
}
40+
}

Scripts/LineageOS-15.1/Patch.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ applyPatch "$DOS_PATCHES/android_build/0002-Enable_fwrapv.patch"; #Use -fwrapv a
7676
applyPatch "$DOS_PATCHES/android_build/0003-verity-openssl3.patch"; #Fix VB 1.0 failure due to openssl output format change
7777
sed -i '57i$(my_res_package): PRIVATE_AAPT_FLAGS += --auto-add-overlay' core/aapt2.mk; #Enable auto-add-overlay for packages, this allows the vendor overlay to easily work across all branches.
7878
awk -i inplace '!/Email/' target/product/core.mk; #Remove Email
79-
sed -i 's/2021-10-05/2024-05-05/' core/version_defaults.mk; #Bump Security String #XXX
79+
sed -i 's/2021-10-05/2024-06-05/' core/version_defaults.mk; #Bump Security String #XXX
8080
fi;
8181

8282
if enterAndClear "build/soong"; then
@@ -258,6 +258,11 @@ applyPatch "$DOS_PATCHES/android_frameworks_base/385672.patch"; #P_asb_2024-03 R
258258
applyPatch "$DOS_PATCHES/android_frameworks_base/385673.patch"; #P_asb_2024-03 Disallow system apps to be installed/updated as instant.
259259
applyPatch "$DOS_PATCHES/android_frameworks_base/385674.patch"; #P_asb_2024-03 Close AccountManagerService.session after timeout.
260260
applyPatch "$DOS_PATCHES/android_frameworks_base/389014-backport.patch"; #S_asb_2024-04 Fix security vulnerability that creates user with no restrictions when accountOptions are too long.
261+
applyPatch "$DOS_PATCHES/android_frameworks_base/394878.patch"; #P_asb_2024-06 Add more checkKeyIntent checks to AccountManagerService.
262+
applyPatch "$DOS_PATCHES/android_frameworks_base/394879.patch"; #P_asb_2024-06 Adds additional sanitization for Zygote command arguments.
263+
applyPatch "$DOS_PATCHES/android_frameworks_base/394880.patch"; #P_asb_2024-06 Check hidden API exemptions
264+
applyPatch "$DOS_PATCHES/android_frameworks_base/394881-backport.patch"; #P_asb_2024-06 AccessibilityManagerService: remove uninstalled services from enabled list after service update.
265+
applyPatch "$DOS_PATCHES/android_frameworks_base/394882.patch"; #P_asb_2024-06 Check permissions for CDM shell commands
261266
applyPatch "$DOS_PATCHES_COMMON/android_frameworks_base/0001-Browser_No_Location.patch"; #Don't grant location permission to system browsers (GrapheneOS)
262267
applyPatch "$DOS_PATCHES_COMMON/android_frameworks_base/0003-SUPL_No_IMSI.patch"; #Don't send IMSI to SUPL (MSe1969)
263268
applyPatch "$DOS_PATCHES_COMMON/android_frameworks_base/0004-Fingerprint_Lockout.patch"; #Enable fingerprint lockout after five failed attempts (GrapheneOS)

0 commit comments

Comments
 (0)