diff options
| author | Treehugger Robot <treehugger-gerrit@google.com> | 2020-12-04 17:36:52 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-12-04 17:36:52 +0000 |
| commit | 0edbfa762d308cd952997bac4c2dc20b8bc088f8 (patch) | |
| tree | 0ef5b63137bed860f10cbe38c063ae7c1af18410 /server/NetworkController.cpp | |
| parent | 2c75d4c923d23eb73ee49aa1eb583efce920133f (diff) | |
| parent | 3a0518663266ca87651967717e414bf5f24baf07 (diff) | |
Merge "Add comments in checkUserNetworkAccessLocked" am: 3a05186632
Original change: https://android-review.googlesource.com/c/platform/system/netd/+/1512957
Change-Id: I4f692f4ff92ececb452e64ff31654626bfb93c9d
Diffstat (limited to 'server/NetworkController.cpp')
| -rw-r--r-- | server/NetworkController.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/server/NetworkController.cpp b/server/NetworkController.cpp index 20ae44b2..20ef9ebb 100644 --- a/server/NetworkController.cpp +++ b/server/NetworkController.cpp @@ -781,18 +781,23 @@ int NetworkController::checkUserNetworkAccessLocked(uid_t uid, unsigned netId) c if (uid == INVALID_UID) { return -EREMOTEIO; } + // If the UID has PERMISSION_SYSTEM, it can use whatever network it wants. Permission userPermission = getPermissionForUserLocked(uid); if ((userPermission & PERMISSION_SYSTEM) == PERMISSION_SYSTEM) { return 0; } + // If the UID wants to use a VPN, it can do so if and only if the VPN applies to the UID. if (network->getType() == Network::VIRTUAL) { return static_cast<VirtualNetwork*>(network)->appliesToUser(uid) ? 0 : -EPERM; } + // If a VPN applies to the UID, and the VPN is secure (i.e., not bypassable), then the UID can + // only select a different network if it has the ability to protect its sockets. VirtualNetwork* virtualNetwork = getVirtualNetworkForUserLocked(uid); if (virtualNetwork && virtualNetwork->isSecure() && mProtectableUsers.find(uid) == mProtectableUsers.end()) { return -EPERM; } + // Check whether the UID's permission bits are sufficient to use the network. Permission networkPermission = static_cast<PhysicalNetwork*>(network)->getPermission(); return ((userPermission & networkPermission) == networkPermission) ? 0 : -EACCES; } |
