From bc7b339f732dced02621023117187954606a12cc Mon Sep 17 00:00:00 2001 From: Automerger Merge Worker Date: Wed, 11 Mar 2020 01:26:07 +0000 Subject: [PATCH] Remove lock inversion in LegacyVpnRunner This commit prevents the lock inversion introduced in aosp/1218118 by reverting some of the calls to the cleanup code that ensures all outer class state is reset. At worst, the correctness of the outer class' state for the LegacyVpnRunner shutdown is the same as before aosp/1218118. This generally seems safe as: 1. This reverts it to a known state (non-ideal, but non-broken) 2. If the interfaces have already been created and registered with the event observer, the event observer will trigger a interfaceRemoved, which will both shutdown the LegacyVpnRunner, and cleanup the Vpn instance state. Bug: 151068107 Test: FrameworksNetTests passing Test: Repeated steps in bug, no deadlock Change-Id: I51a475f575252fb981641fc6240bb8c15576c5f2 Merged-In: I51a475f575252fb981641fc6240bb8c15576c5f2 (cherry picked from commit 50aaea7e8d6d40bcddee124f1efdd33da4da6fd6) --- .../core/java/com/android/server/connectivity/Vpn.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index 7c3cab17704fc..20ffd9f51d6e5 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -2563,7 +2563,7 @@ public class Vpn { public void exitIfOuterInterfaceIs(String interfaze) { if (interfaze.equals(mOuterInterface)) { Log.i(TAG, "Legacy VPN is going down with " + interfaze); - exit(); + exitVpnRunner(); } } @@ -2572,6 +2572,10 @@ public class Vpn { public void exitVpnRunner() { // We assume that everything is reset after stopping the daemons. interrupt(); + + // Always disconnect. This may be called again in cleanupVpnStateLocked() if + // exitVpnRunner() was called from exit(), but it will be a no-op. + agentDisconnect(); try { mContext.unregisterReceiver(mBroadcastReceiver); } catch (IllegalArgumentException e) {} @@ -2794,7 +2798,7 @@ public class Vpn { } catch (Exception e) { Log.i(TAG, "Aborting", e); updateState(DetailedState.FAILED, e.getMessage()); - exit(); + exitVpnRunner(); } }