Skip to content

CCB: Fix potential deadlock in PolicyHandler  #3176

@LitvinenkoIra

Description

@LitvinenkoIra

Bug Report

Potential deadlock in PolicyHandler

Detailed analysis:

There is a vulnerability in the PolicyHandler which causes a mutex deadlock. For example - MessageLoop thread of RpcService handles incoming messages. In case when SDL receives AllowSDLFunctionality notification, this thread calls OnAllowSDLFunctionalityNotification inside PolicyHandler. At some point of time this function captures accessor from AM which holds applications_list_lock_ there. At this moment thread AM Pool 0 of RequestController processes some RPC from queue and captures policy_manager_lock_ in PolicyHandler. After that at
some moment thread AM Pool 0 tries to get application shared pointer from AM and locks itself as this mutex are already locked with thread MessageLoop. Also, MessageLoop thread at some moment tries to acquire policy_manager_lock_ and locks itself as this mutex are already locked with thread AM Pool 0, which is waiting for applications_list_lock_ to unlock. As a result we have a
classical thread deadlock after which SDL stuck forever.

To avoid such situations, all bottlenecks related to
applications_list_lock_ and its accessors should be analyzed . Accessors should be scoped in several places to avoid similar deadlocks in the future.

Reproduction Steps
  1. Start SDL, HMI, connect Mobile
  2. Trigger PTU
  3. Send VR.ChangeLanguage
Expected Behavior

SDL should not crash

Observed Behavior

SDL crashed

OS & Version Information

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions