Skip to content

Commit 2cc24ca

Browse files
sam3000PMS22
authored andcommitted
fw/b: Prevent double interface restriction remove on interface name change
* When temporarily removing a restriction owing to interface name change, update the boolean state array to match. Otherwise, we get out of sync, follow-on double removes can occur and the system server will crash. * In addition, it was observed that it is possible to receive a network callback for a (VPN) network that has both WIFI and VPN transports set (it looked transient rather than persisent but difficult to tell). So make the list of use cases in priority of match order, putting VPN first. Change-Id: If484b5a715e0a972769c847ea4549fd84afb3ccf
1 parent 832f885 commit 2cc24ca

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

services/core/java/com/android/server/NetworkManagementService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,10 @@ private static class RestrictIf {
282282

283283
@GuardedBy("mQuotaLock")
284284
private RestrictIf[] mRestrictIf = {
285-
new RestrictIf(RESTRICT_USECASE_DATA, NetworkCapabilities.TRANSPORT_CELLULAR),
285+
// Ordered by match preference (in the event we get a callback with
286+
// multiple transports).
286287
new RestrictIf(RESTRICT_USECASE_VPN, NetworkCapabilities.TRANSPORT_VPN),
288+
new RestrictIf(RESTRICT_USECASE_DATA, NetworkCapabilities.TRANSPORT_CELLULAR),
287289
new RestrictIf(RESTRICT_USECASE_WLAN, NetworkCapabilities.TRANSPORT_WIFI),
288290
};
289291

@@ -360,6 +362,7 @@ public void onLinkPropertiesChanged(Network network, LinkProperties linkProperti
360362
for (RestrictIf restrictIf : mRestrictIf) {
361363
if (nc.hasTransport(restrictIf.transport)) {
362364
matchedRestrictIf = restrictIf;
365+
break;
363366
}
364367
}
365368
if (matchedRestrictIf == null) {
@@ -1559,6 +1562,7 @@ private void updateAppOnInterfaceCallback(RestrictIf restrictIf, String newIface
15591562
continue;
15601563
}
15611564
setAppOnInterfaceLocked(restrictIf.useCase, restrictIf.ifName, uid, false);
1565+
restrictIf.active.setValueAt(i, false);
15621566
// Use pending list to queue re-add.
15631567
// (Prefer keeping existing pending status if it exists.)
15641568
if (restrictIf.pending.indexOfKey(uid) < 0) {

0 commit comments

Comments
 (0)