diff options
| author | Treehugger Robot <treehugger-gerrit@google.com> | 2020-12-04 16:09:56 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-12-04 16:09:56 +0000 |
| commit | 3a0518663266ca87651967717e414bf5f24baf07 (patch) | |
| tree | 0ef5b63137bed860f10cbe38c063ae7c1af18410 /server/NetworkController.cpp | |
| parent | 25890623a01079106fd929d041772600bf3aca41 (diff) | |
| parent | f875b52973e9932d4e50cb9d031965d3bf66829a (diff) | |
Merge "Add comments in checkUserNetworkAccessLocked"
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; } |
