Fix: refcount issue in lttng-ust-abi.c
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 6 Mar 2013 15:07:12 +0000 (10:07 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 6 Mar 2013 15:21:17 +0000 (10:21 -0500)
commit164931d23d430b1770611ec0300720350261b346
tree03121b9936ddf3a1005ec936788055dff43c0b96
parent7e21c569b172c3f2254c999061aa6395b05f875d
Fix: refcount issue in lttng-ust-abi.c

The following scenario could lead to a segmentation fault in
applications when the sessiond disappears or when the application try to
exit. This is caused by incorrect handling of reference counts.

This can happen in very particular race scenario, described as follows:

1) The sessiond asks for "release" of one or more objects (e.g. a
   session object), but _without_ asking for release of _all_ objects
   referencing the session.
2) The application exits, thus calling objd_table_destroy(). It walks on
   all objects, decrementing their reference count, freeing memory when
   their reference count reaches "1".

However, here is the issue: since "release" has already been performed
by sessiond on the session object, this extra reference count unref
performed by objd_table_destroy() can make the session object disappear
while it is still needed by either the channel object or the enabler
object. Therefore, we can experience a segmentation fault when we try to
unref and free the channel or enabler objects within
objd_table_destroy().

Fix this issue by adding the concept of an "owner reference". Only
objd_table_destroy(), lttng_ust_objd_table_owner_cleanup(), "release"
commands, and failure paths of object creation are allowed to decrement
the owner reference. We restrict objd_table_destroy() and
lttng_ust_objd_table_owner_cleanup() to _only_ decrement refcount of
objects _if_ their owner reference is still held.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/ust-abi.h
liblttng-ust/lttng-ust-abi.c
liblttng-ust/lttng-ust-comm.c
This page took 0.025086 seconds and 4 git commands to generate.