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: lttng-ctl: trigger leak on failure to deserialize evaluation 1452207 Resource leak The system resource will not be reclaimed and reused, reducing the future availability of the resource. In lttng_notification_create_from_payload: Leak of memory or pointers to system resources (CWE-404) Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I5a66af837d46ca4b8e1909012cd28dc8ea990bad
notification: transmit originating trigger as part of evaluation Transmit the full trigger object instead of its condition when sending a notification to a client. This allows clients to reliably filter on triggers as, currently, only the name of a trigger is made available to clients as part of the "on_event" evaluation object (the owner uid is needed to perform a correct comparison for filtering). This will also make the trigger accessible for all condition types. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I61d587436177eb34744487a1d3c486d87fe2e1f1
Make captured field values available to event rule cond. evaluation liblttng-ctl: Add the public lttng_evaluation_get_captured_values() function. This function returns an array event field value which contains the captured field values as requested by the evaluation's condition's capture descriptors. This array event field value contains as many elements as returned by lttng_condition_event_rule_get_capture_descriptor_count() for the evaluation's condition. However, lttng_event_field_value_array_get_element_at_index() could return `LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE` for some or all indexes if there was no such field to capture at tracing time. Common: Internally, an event rule evaluation now contains a captured field value payload (CFVP) as well as the array event field value to be returned by lttng_evaluation_get_captured_values(). The CFVP is MessagePack-encoded. When you create an event rule evaluation with lttng_evaluation_event_rule_create(), you must pass the CFVP as well as the `decode_capture_payload` option parameter. If `decode_capture_payload` is `true`, lttng_evaluation_event_rule_create() creates the array event field value from the CFVP thanks to msgpack-c. lttng_evaluation_event_rule_create() also accepts the event rule condition now because it relies on the capture descriptors to create the event field values if `decode_capture_payload` is `true`. When an event rule evaluation is serialized: Only its CFVP is serialized (as is). When an event rule evaluation is deserialized: lttng_evaluation_event_rule_create() is called with the `decode_capture_payload` parameter set to `true`. Session daemon: action_executor_notify_handler() calls lttng_evaluation_event_rule_create() with the `decode_capture_payload` parameter set to `false` to send the evaluation to the clients with the CFVP. This CFVP directly comes from the tracer. Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Ib2ae39dae005ad555eb8309e0bfd53f746d5e8dd Depends-on: lttng-ust: I8423c510bf6af2f9bf85256e8d6f931d36f7054b
Fix: unchecked buffer size for communication header A number of object de-serialization functions rely on a fixed-size communication header to create an object from a payload. A large number of those functions assume that the initial header fits in the provided buffer or payload view. Also, the functions that do validate that the header fits do so in different ways: - checking the view's size, - creating a new fixed-size view and checking the 'data' pointer. To harmonize all of those checks, the following utils are added: - lttng_buffer_view_is_valid() - lttng_payload_view_is_valid() These functions should be used whenever a fixed-size view is created (not passing -1 as the length parameter). The checks are added and/or harmonized to: - create a new 'header' view, - validate it with the corresponding *_is_valid() function, - initialize the header pointer using the header view. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I763946feac714ecef4fc5bd427dab2d3fe5dc1a4
common: move lttng_payload[_view] to libcommon The payload utils are moved from libsessiond-comm to libcommon since they present a circular dependancy: a payload uses the dynamic buffer utilities while the actions, triggers, and conditions make use of the lttng_payload utilities. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Ib448bde0e442e7660bb7a61cd629f29442715b21
liblttng-ctl: use lttng_payload for serialize/create_from_buffer Some objects used in the sessiond <-> liblttng-ctl communication (e.g. such as userspace probe event rule) contain file descriptors that must be carried accross process boundaries (fd passing). Since those objects are often nested within a higher-level object hierarchy, it makes sense to adapt the existing serialize/create_from_buffer interface to use an lttng_payload. An lttng_payload contains a dynamic buffer and an array of file descriptors. Objects are expected to push their file descriptors in the payload in the same way they currently push the bytes of their binary representation in a dynamic buffer. Conversely, an lttng_payload_view interface is added and contains a buffer_view and an iterator which allows objects to ̀ pop` a file descriptors when appropriate. Tests are added to validate the FD consumption behaviour depending on the origin of payload views (root view or descendant view). Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Id378d8b5a3376a074ab138a60733377e39a24133
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>
Use the dynamic buffer to serialize notification objects The objects of the notification/trigger APIs are currently serialized by calling their serialization functions with a NULL buffer, returning the expected size, and then calling the serialization function with a sufficiently-large buffer. This code predates the dynamic buffer utility which can now be used to perform serialization operations in one pass. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Silence bogus Coverity warning of uninitialized value Coverity complains that struct lttng_notification_comm's payload field is not initialized. "payload" is a flexible array member which should be ignored. Normally, a such a member _could_ result in additional padding added at the end of the structure. In this case, the structure is declared as packed. Nonetheless, using a designated initializer gets rid of the ambiguity and silences Coverity. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>