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
Loading
Please register or sign in to comment