Remove check for NETWORK_STACK permission inside system_server
This check does not make any sense. enforceNetworkStackPermission calls
Context#checkCallingOrSelfPermission() and checks whether this process
or the calling process has NETWORK_STACK or MAINLINE_NETWORK_STACK
permission.
This code runs in system server, and I believe checkSelfPermission()
eventually runs ActivityManagerService#checkComponentPermission which
grants all permissions to the system server uid.
Check calling permission is based on Binder.getCallingUid(), which in
turn only works on the binder thread (it's based on the thread-local
IPCThreadState). However, this code runs on the service's handler
thread.
Note: This was added in aosp/1553695 but I cannot figure out why. Presumably a copy / paste error from looking at the other CLs in that topic.
Side note: this would throw a SecurityException which would kill the
handler thread as it is not caught by the surrounding try / catch. I
believe this would invoke the default UncaughtExceptionHandler set by
RuntimeInit (KillApplicationHandler) and take down system server.
Change-Id: I225948b7fbe076e7d1f069289902e4fdcaba4e54
Test: TH
diff --git a/service-t/src/com/android/server/ethernet/EthernetTracker.java b/service-t/src/com/android/server/ethernet/EthernetTracker.java
index 6079413..4a9410e 100644
--- a/service-t/src/com/android/server/ethernet/EthernetTracker.java
+++ b/service-t/src/com/android/server/ethernet/EthernetTracker.java
@@ -594,7 +594,6 @@
InterfaceConfigurationParcel config = null;
// Bring up the interface so we get link status indications.
try {
- PermissionUtils.enforceNetworkStackPermission(mContext);
// Read the flags before attempting to bring up the interface. If the interface is
// already running an UP event is created after adding the interface.
config = NetdUtils.getInterfaceConfigParcel(mNetd, iface);