liblttng-ctl: use export list to define exported symbols Symbols are currently exported by default by liblttng-ctl.so (usable by other shared libraries / programs using liblttng-ctl.so), so we must use LTTNG_HIDDEN on all symbols that are meant to be internal to liblttng-ctl.so. Of course, this is easy to forget, so over the years many symbols that were not meant to be exported were exported, and must now stay exported to avoid breaking the ABI. As explained here [1], a better method is to make symbols hidden by default, and mark those we want to be exported as such. I have tried to use this, but when subsequently converting the code to C++, I have noticed that some symbols related to the STL were exported anyway, which is bad. The other alternative, implemented in this patch, is to use an explicit symbol export list [2], using libtool's -export-symbols (which uses the linker's -version-script option). Only the symbols listed here are exported. So, in practice, this patch: - Adds an liblttng-ctl.sym file with the list of exported symbols and adjusts the Makefile to use the -export-symbol option - Removes LTTNG_HIDDEN and all its uses abidiff shows no changes for liblttng-ctl.so between before and after this patch. [1] https://gcc.gnu.org/wiki/Visibility [2] https://www.gnu.org/software/libtool/manual/libtool.html#Link-mode Change-Id: I5d8c558303894b0ad8113c6e52f79a053bb580e1 Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Force usage of assert() condition when NDEBUG is defined Reuse the BT2 approach to force the usage of the assertion condition even when assert() are removed by the NDEBUG define. See `BT_USE_EXPR()` macro and documentation in Babeltrace commit[0]: commit 1778c2a4134647150b199b2b57130817144446b0 Author: Philippe Proulx <eeppeliteloop@gmail.com> Date: Tue Apr 21 11:15:42 2020 -0400 lib: assign a unique ID to each pre/postcond. and report it on failure 0: https://github.com/efficios/babeltrace/commit/1778c2a4134647150b199b2b57130817144446b0 Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I3844b6ae7e95952d90033898397ac936540b785c
Fix: relayd: unchecked allocation result of unlinked file pool `pool` is not checked for NULL after its allocation. Error out if the allocation fails. In lttng_unlinked_file_pool_create: Return value of function which returns null is dereferenced without checking (CWE-476) Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I2a7717701cf3d11de557b9ecdc6609c1f6a1fd6f
Fix: fd-tracker: mark symbols as hidden The fd-tracker is part of libcommon and, as such, its symbols must be marked as hidden since it is linked into liblttng-ctl. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I007d950c0e3f7e059ba372c4d20b096c3069febb
Fix: unchecked return value of lttng_directory_handle_create() Although unlikely in this case (as the path was just created), the creation of a directory handle can fail and this should always be accounted-for. 1415129 Dereference null return value If the function actually returns a null value, a null pointer dereference will occur. In lttng_unlinked_file_pool_add_inode: Return value of function which returns null is dereferenced without checking (CWE-476) Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I914802c25b569320e08265aae251e062bccbd50e
relayd: track directory handles through the fd-tracker Track directory handles through the fd-tracker as unsuspendable file descriptors. New fd-tracker utils are introduced to wrap the creation and registration of the file descriptors to the fd-tracker. Note that file descriptors only need to be tracked when the dirfd-backed implementation of the directory handles is used. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I754af1943f5d6f02a6219d48c8fc4b8106de1c13
Move to kernel style SPDX license identifiers The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. See https://spdx.org/ids-how for details. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Change-Id: I62e7038e191a061286abcef5550b58f5ee67149d Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
fd-tracker: restore suspended handles from their inode's path In order to support session rotations and, to a lesser degree, the "clear" command, the fd-tracker internals (lttng_inode and fs_handle) need to recover from files being renamed while the handle to it is suspended. This refactor introduces a "location" to the lttng_inode which is updated anytime an unlink or rename is performed on an fs_handle. Keep in mind that multiple independent fs_handles can refer to the same lttng_inode (a unique tuple of device id and inode number). This location is used to restore the fs_handle whenever it is needed. Moreover, since the session rotation/clear operations sometimes rely on directories having been emptied after rename/unlink, the current scheme of renaming unlinked files to the form "filename-deleted-suffix" no longer works. The renaming scheme is replaced by a new "unlinked file pool", which is an hidden directory at the base of the output directory which contains the files which were unlinked to which references (fs_handles) are still being held. The API of the fd-tracker itself had to be changed slightly and the tests are adapted as a consequence. New tests targeting this new behaviour are also added. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I9b1344da1966c85bdd6b51838507d3208e1d9a42
Clean-up: apply clang-format to the newly added fd-tracker The fd-tracker code was just merged but clang-format found some changes to apply. Since there is no need to backport to this code yet, clean it up as much as possible now. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Ia0bec41e0531c9f5d611d742e96a984de3f06784
fd-tracker: add the lttng-inode interface The lttng-inode interface is internal to the fd-tracker. It allows unlink operations on an fs_handle to determine if another fs_handle refers to the same file. When this is deemed to be the case, the unlink can be delayed by renaming the file to a temporary name and, finally, unlinking it when all references have been released. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>