Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e29bf99a authored by Benedict Wong's avatar Benedict Wong Committed by Automerger Merge Worker
Browse files

Merge "Set correct owner UID for VPN agentConnect()" am: 7efd5a48 am:...

Merge "Set correct owner UID for VPN agentConnect()" am: 7efd5a48 am: 8cabf350 am: fe747eaf am: 0cf7776f am: c8fa2299

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1326493

Change-Id: Ib473ec592210bc7f7f8ee86ef0f9b10e7f45e0a4
parents b81f0f98 c8fa2299
Loading
Loading
Loading
Loading
+22 −5
Original line number Diff line number Diff line
@@ -900,9 +900,17 @@ public final class NetworkCapabilities implements Parcelable {
     * <p>For NetworkCapability instances being sent from ConnectivityService, this value MUST be
     * reset to Process.INVALID_UID unless all the following conditions are met:
     *
     * <p>The caller is the network owner, AND one of the following sets of requirements is met:
     *
     * <ol>
     *   <li>The described Network is a VPN
     * </ol>
     *
     * <p>OR:
     *
     * <ol>
     *   <li>The destination app is the network owner
     *   <li>The destination app has the ACCESS_FINE_LOCATION permission granted
     *   <li>The calling app is the network owner
     *   <li>The calling app has the ACCESS_FINE_LOCATION permission granted
     *   <li>The user's location toggle is on
     * </ol>
     *
@@ -928,7 +936,16 @@ public final class NetworkCapabilities implements Parcelable {
    /**
     * Retrieves the UID of the app that owns this network.
     *
     * <p>For user privacy reasons, this field will only be populated if:
     * <p>For user privacy reasons, this field will only be populated if the following conditions
     * are met:
     *
     * <p>The caller is the network owner, AND one of the following sets of requirements is met:
     *
     * <ol>
     *   <li>The described Network is a VPN
     * </ol>
     *
     * <p>OR:
     *
     * <ol>
     *   <li>The calling app is the network owner
@@ -936,8 +953,8 @@ public final class NetworkCapabilities implements Parcelable {
     *   <li>The user's location toggle is on
     * </ol>
     *
     * Instances of NetworkCapabilities sent to apps without the appropriate permissions will
     * have this field cleared out.
     * Instances of NetworkCapabilities sent to apps without the appropriate permissions will have
     * this field cleared out.
     */
    public int getOwnerUid() {
        return mOwnerUid;
+6 −0
Original line number Diff line number Diff line
@@ -1698,6 +1698,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
            return newNc;
        }

        // Allow VPNs to see ownership of their own VPN networks - not location sensitive.
        if (nc.hasTransport(TRANSPORT_VPN)) {
            // Owner UIDs already checked above. No need to re-check.
            return newNc;
        }

        Binder.withCleanCallingIdentity(
                () -> {
                    if (!mLocationPermissionChecker.checkLocationPermission(
+2 −1
Original line number Diff line number Diff line
@@ -1106,7 +1106,8 @@ public class Vpn {
        NetworkAgentConfig networkAgentConfig = new NetworkAgentConfig();
        networkAgentConfig.allowBypass = mConfig.allowBypass && !mLockdown;

        mNetworkCapabilities.setOwnerUid(Binder.getCallingUid());
        mNetworkCapabilities.setOwnerUid(mOwnerUID);
        mNetworkCapabilities.setAdministratorUids(new int[] {mOwnerUID});
        mNetworkCapabilities.setUids(createUserAndRestrictedProfilesRanges(mUserHandle,
                mConfig.allowedApplications, mConfig.disallowedApplications));
        long token = Binder.clearCallingIdentity();