CWE-765
Multiple Unlocks of a Critical Resource
AI Translation Available
The product unlocks a critical resource more times than intended, leading to an unexpected state in the system.
Status
incomplete
Abstraction
base
Affected Platforms
Extended Description
AI Translation
When the product is operating in a concurrent environment and repeatedly unlocks a critical resource, the consequences will vary based on the type of lock, the lock's implementation, and the resource being protected. In some situations such as with semaphores, the resources are pooled and extra calls to unlock will increase the count for the number of available resources, likely resulting in a crash or unpredictable behavior when the system nears capacity.
Technical Details
AI Translation
Common Consequences
availability
integrity
Impacts
dos: crash, exit, or restart
modify memory
unexpected state
Detection Methods
automated static analysis
Potential Mitigations
Phases:
implementation
Descriptions:
•
When locking and unlocking a resource, try to be sure that all control paths through the code in which the resource is locked one or more times correspond to exactly as many unlocks. If the product acquires a lock and then determines it is not able to perform its intended behavior, be sure to release the lock(s) before waiting for conditions to improve. Reacquire the lock(s) before trying again.