Skip to content

Library: fix race conditions in device management#687

Open
reinauer wants to merge 1 commit intoUSBGuard:mainfrom
reinauer:race_conditions
Open

Library: fix race conditions in device management#687
reinauer wants to merge 1 commit intoUSBGuard:mainfrom
reinauer:race_conditions

Conversation

@reinauer
Copy link

The _sysfs_path_to_id_map and _backlog structures were being accessed
concurrently by the main thread and the uevent thread without proper
synchronization. This could lead to memory corruption or erroneous
device rejections during the initial system scanning phase.

Fix this by:

  1. Protecting _sysfs_path_to_id_map in DeviceManagerBase using the
    existing refDeviceMapMutex().
  2. Protecting the event _backlog in UEventDeviceManager using a
    dedicated static mutex to ensure thread-safe buffering and handoff.

The _sysfs_path_to_id_map and _backlog structures were being accessed
concurrently by the main thread and the uevent thread without proper
synchronization. This could lead to memory corruption or erroneous
device rejections during the initial system scanning phase.

Fix this by:
1. Protecting _sysfs_path_to_id_map in DeviceManagerBase using the
   existing refDeviceMapMutex().
2. Protecting the event _backlog in UEventDeviceManager using a
   dedicated static mutex to ensure thread-safe buffering and handoff.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant