Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05387b6d authored by Li Li's avatar Li Li
Browse files

Prevent frozenBinderTransactionDetected() storm

Although system_server is never frozen, its async binder buffer might
still be exhausted in some extreme conditions. In such a case, this
async call itself would fail, triggering endless loop. Throttle this
callback function to fix it.

Bug: 336171553
Bug: 333508040
Bug: 328423444
Test: frozenBinderTransactionDetected is throttled
Change-Id: Ibe475f7f9699921a1555ab937e5f67ddcf502f58
parent 6d602b0b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -353,6 +353,9 @@ public final class ActivityThread extends ClientTransactionHandler

    private static final String DEFAULT_FULL_BACKUP_AGENT = "android.app.backup.FullBackupAgent";

    private static final long BINDER_CALLBACK_THROTTLE = 10_100L;
    private long mBinderCallbackLast = -1;

    /**
     * Denotes the sequence number of the process state change for which the main thread needs
     * to block until the network rules are updated for it.
@@ -7525,6 +7528,12 @@ public final class ActivityThread extends ClientTransactionHandler
        Binder.setTransactionCallback(new IBinderCallback() {
            @Override
            public void onTransactionError(int pid, int code, int flags, int err) {
                final long now = SystemClock.uptimeMillis();
                if (now < mBinderCallbackLast + BINDER_CALLBACK_THROTTLE) {
                    Slog.d(TAG, "Too many transaction errors, throttling freezer binder callback.");
                    return;
                }
                mBinderCallbackLast = now;
                try {
                    mgr.frozenBinderTransactionDetected(pid, code, flags, err);
                } catch (RemoteException ex) {