Skip to content

Fix reliability, security, and performance issues across clients - #18

Merged
jwinarske merged 1 commit into
mainfrom
jw/audit-fixes
Jul 12, 2026
Merged

Fix reliability, security, and performance issues across clients#18
jwinarske merged 1 commit into
mainfrom
jw/audit-fixes

Conversation

@jwinarske

Copy link
Copy Markdown
Owner

Fixes reliability, security, and performance issues found across the clients. Builds clean (gcc 16 / clang 19), passes clang-format --Werror, and introduces no new clang-tidy warnings.

BlueZ game controllers (xbox / ps5 / horipad)

  • Run the hidraw read loop on an owned thread joined in the destructor and interruptible via epoll + eventfd, instead of a blocking coroutine that ran inline and never returned. Fixes a use-after-free when a controller is unplugged (the udev thread freed the reader while the read loop was still blocked in read()) and a hang that blocked shutdown and the D-Bus event loop.
  • Guard input_reader_ with a mutex; it is created on the D-Bus thread and reset on the udev thread.
  • Clamp the report memcpy to the bytes actually read, size the PS5 buffer to the largest report so report 0x31 is no longer truncated, and dump each HoriPad report array by its own size to stop a one-byte over-read.

Data races

  • Guard connman services_ / technologies_ with a mutex across the constructor and the async callbacks.
  • Guard udisks2 manager_nvme_ with a mutex on add and remove.

Error handling

  • geoclue2: bail out when the manager returns no client object (was a null-shared_ptr deref).
  • login1: contain sdbus errors from ListSeats / ListSessions / ListUsers in the async reply so they cannot escape the event loop and terminate the process.
  • packagekit: wrap main() in try/catch.
  • timedate1: guard against a null localtime_r result before put_time.

Performance

  • Dispatch PropertiesChanged by iterating the changed properties once instead of scanning every known property with two map lookups and a per-property MemberName allocation (device1, adapter1, upower, gatt*, le_advertising_manager1).
  • Extract each Variant container once in the utils formatters instead of twice.

Resource use

  • De-duplicate and cap systemd1 activeUnits_ growth.

BlueZ game controllers (xbox/ps5/horipad):
- Run the hidraw read loop on an owned thread joined in the destructor and
  interruptible via epoll+eventfd, instead of a blocking coroutine that ran
  inline and never returned. Fixes a use-after-free when a controller is
  unplugged and a hang that blocked shutdown and the D-Bus event loop.
- Guard input_reader_ with a mutex; it is created on the D-Bus thread and
  reset on the udev thread.
- Clamp the report memcpy to the bytes actually read, size the PS5 buffer to
  the largest report so report 0x31 is not truncated, and dump each HoriPad
  report array by its own size to stop a one-byte over-read.

Data races:
- Guard connman services_/technologies_ with a mutex across the constructor
  and the async callbacks.
- Guard udisks2 manager_nvme_ with a mutex on add and remove.

Error handling:
- geoclue2: bail out when the manager returns no client object.
- login1: contain sdbus errors from ListSeats/ListSessions/ListUsers in the
  async reply so they cannot terminate the process.
- packagekit: wrap main() in try/catch.
- timedate1: guard against a null localtime_r result before put_time.

Performance:
- Dispatch PropertiesChanged by iterating the changed properties once instead
  of scanning every known property with two map lookups and a per-property
  allocation (device1, adapter1, upower, gatt*, le_advertising_manager1).
- Extract each Variant container once in the utils formatters.

Resource use:
- De-duplicate and cap systemd1 activeUnits_ growth.

Signed-off-by: Joel Winarske <[email protected]>
@jwinarske
jwinarske merged commit 0b771e4 into main Jul 12, 2026
6 checks passed
@jwinarske
jwinarske deleted the jw/audit-fixes branch July 12, 2026 20:26
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