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:07:12 +0000 (10:07 -0500)
commit1849ef7cdc349bef4b6f6eb4a50058e06c26d431
treeaba8574ad02b02c0b7230e23fbb223ae326b2972
parent3d0ef9f63c9766ef6b18e4fc2ddcefe452234168
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.02678 seconds and 4 git commands to generate.