Skip to content
Commit 446c9c91 authored by Hugo Benichi's avatar Hugo Benichi
Browse files

NetworkPolicyManagerService: fix deadlock

Callers of addNetworkPolicy() were not taking locks in the correct order
inside NetworkPolicyManagerService:
  - addNetworkPolicy() is an internal method that calls
    setNetworkPolicies which takes both mUidRulesFirstLock and
    mNetworkPoliciesSecondLock in order.
  - both callers of addNetworkPolicy, mWifiStateReceiver and
    mConnReceiver via ensureActiveMobilePolicy, were taking
    mNetworkPoliciesSecondLock before calling addNetworkPolicy.
    - this causes the order of locking to be reversed, which can cause a
    deadlock when another concurrent codepath in
    NetworkPolicyManagerService tries to take both locks in the correct
    order.

This patch fixes this issue by wrapping both problematic codepaths into
addNetworkPolicy() with a lock on mUidRulesFirstLock.

Test: build, flashed, NetworkPolicyManagerServiceTest passes
Bug: 36972283
Change-Id: If7888c11aef8b628e1b013224075c4c75eae0022
parent 34cb00ac
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment