diff options
| author | 2020-06-01 13:56:28 -0600 | |
|---|---|---|
| committer | 2020-06-01 13:57:33 -0600 | |
| commit | 3f91f9392152c7d7a654096652dba9d89e4964c9 (patch) | |
| tree | f3b5ae0b88dbae3d838fa9f7ee57129ed9a25e9e | |
| parent | 20534dcc8dfbdd4ba4cd904c96d45d2e7e2caf1b (diff) | |
Remove thread delegation when checking grants.
This code was leftover from previous attempts at avoiding deadlock,
and itself was causing deadlocks with the latest strategy.
Reproduced deadlock in linked bugs, and confirmed that this CL fixes
the underlying deadlock.
Bug: 115619667, 157863128
Test: atest CtsAppSecurityHostTestCases:android.appsecurity.cts.AppSecurityTests#testPermissionDiffCert
Change-Id: I9a8e5828090adebae1bfc306219c4b42d0c97432
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index a4e45cd334bf..caaa8371af53 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -18900,30 +18900,8 @@ public class ActivityManagerService extends IActivityManager.Stub @Override public int checkContentProviderUriPermission(Uri uri, int userId, int callingUid, int modeFlags) { - // We can find ourselves needing to check Uri permissions while - // already holding the WM lock, which means reaching back here for - // the AM lock would cause an inversion. The WM team has requested - // that we use the strategy below instead of shifting where Uri - // grants are calculated. - - // Since we could also arrive here while holding the AM lock, we - // can't always delegate the call through the handler, and we need - // to delicately dance between the deadlocks. - if (Thread.currentThread().holdsLock(ActivityManagerService.this)) { - return ActivityManagerService.this.checkContentProviderUriPermission(uri, - userId, callingUid, modeFlags); - } else { - final CompletableFuture<Integer> res = new CompletableFuture<>(); - mHandler.post(() -> { - res.complete(ActivityManagerService.this.checkContentProviderUriPermission(uri, - userId, callingUid, modeFlags)); - }); - try { - return res.get(); - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - } + return ActivityManagerService.this.checkContentProviderUriPermission(uri, + userId, callingUid, modeFlags); } @Override |