Fix: sessiond: client/client_list lock inversion on disconnect
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 18 Aug 2020 20:01:30 +0000 (16:01 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 19 Aug 2020 21:27:45 +0000 (17:27 -0400)
commit6c24d3fd5ade8231445e720c174afe3da4210179
treea4a55ca0a33f1a9497e111c770f96edfcd40797a
parent98b5ff34df5d330fe139907ed77b4327ce9afa48
Fix: sessiond: client/client_list lock inversion on disconnect

Coverity reports a lock inversion scenario in
handle_notification_thread_client_disconnect() where a client's lock is
held while acquiring the client list lock. This is indeed a problem.

As indicated in the notification_client and notification_client_list
comments, the locking was shoe-horned to make it possible for the action
executor to enqueue notifications in a client's outgoing queue and flush
it.

Since this is the only access pattern that is supported, the client
locking is reworked slightly to only acquire the client lock when
checking the "active" flag, interacting with the outbound communication
state, and sending through a client's socket.

This change makes the client locking regions more narrow which accounts
for the somewhat large number of lines affected.

The updates to the `active` flag on error are moved to the function that
flushes the outbound queue instead of expecting the callers to set it.
This allows the locking to be limited to this function rather than
relying on the callers.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8632d0f7785ec727dabd329bdfba010fd5e4643a
src/bin/lttng-sessiond/action-executor.c
src/bin/lttng-sessiond/notification-thread-events.c
src/bin/lttng-sessiond/notification-thread-internal.h
This page took 0.026793 seconds and 5 git commands to generate.