lttng-tools.git
3 years agoClean-up: consumer: fix -Wshadow error in lttng_consumer_rotate_channel
Simon Marchi [Wed, 31 Mar 2021 18:38:26 +0000 (14:38 -0400)] 
Clean-up: consumer: fix -Wshadow error in lttng_consumer_rotate_channel

We can safely re-use the chunk_status declared in the broader scope.

Change-Id: I0dc501168b1c35522a2ce4805d4514854162cefc
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoClean-up: config: fix -Wshadow error in config_load_session
Simon Marchi [Wed, 31 Mar 2021 18:37:15 +0000 (14:37 -0400)] 
Clean-up: config: fix -Wshadow error in config_load_session

Fix:

      CC       libconfig_la-session-config.lo
    /home/simark/src/lttng-tools/src/common/config/session-config.c: In function ‘config_load_session’:
    /home/simark/src/lttng-tools/src/common/config/session-config.c:4020:9: error: declaration of ‘path’ shadows a parameter [-Werror=shadow]
     4020 |    char path[PATH_MAX];
          |         ^~~~
    /home/simark/src/lttng-tools/src/common/config/session-config.c:3999:37: note: shadowed declaration is here
     3999 | int config_load_session(const char *path, const char *session_name,
          |                         ~~~~~~~~~~~~^~~~

Change-Id: Id7d5f6fcf0e88f43dee420dfb174d9bf01aa8fbd
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoClean-up: ust-consumer: fix -Wshadow issues in lttng_ustconsumer_recv_cmd
Simon Marchi [Wed, 31 Mar 2021 16:08:41 +0000 (12:08 -0400)] 
Clean-up: ust-consumer: fix -Wshadow issues in lttng_ustconsumer_recv_cmd

Same rationale and idea as previous patch, but for UST.

To differentiante the top-level `channel` variable, which owns a
channel, and the non-owning `channel` variables used when looking up
existing channels, the latter are renamed `found_channel`.

Change-Id: I6bf94be8d4368b5716756f4e12bae17c3e0d7cee
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoClean-up: kernel-consumer: fix -Wshadow issues in lttng_kconsumer_recv_cmd
Simon Marchi [Wed, 31 Mar 2021 15:10:30 +0000 (11:10 -0400)] 
Clean-up: kernel-consumer: fix -Wshadow issues in lttng_kconsumer_recv_cmd

There is a "ret" variable declared at the top and used throughout, but
there are also some other "ret" variables declared in narrower scopes.

Most of the time, the return value is not communicated from the "case"s
to the return value of the function. On failure, they goto an error
label which overrides ret to -1. There is one exception in "case
LTTNG_CONSUMER_ADD_STREAM", which goes directly to label end, not sure
if that's on purpose or not.

So what I did is: declare variables in narrower scopes when possible,
name them according to their intended use (e.g. ret_send, ret_recv). In
the end, there is no variable simply named "ret". The variable holding
the function's return value is "ret_func".

Change-Id: Ic02067c23757bd98d4b2d3d0f2b77384b4b0d743
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoClean-up: kernel-ctl: rename local variables in LTTNG_IOCTL_{,NO_}CHECK
Simon Marchi [Wed, 31 Mar 2021 14:48:13 +0000 (10:48 -0400)] 
Clean-up: kernel-ctl: rename local variables in LTTNG_IOCTL_{,NO_}CHECK

Same rationale as previous patch.

Change-Id: Ie1782adad99616b3705c015360fa31d7e9273718
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoClean-up: common: rename local variables in PERROR
Simon Marchi [Wed, 31 Mar 2021 14:46:20 +0000 (10:46 -0400)] 
Clean-up: common: rename local variables in PERROR

If PERROR is used in a function where a `buf` or `tmp` variable already
exists, we get this when enabling -Wshadow:

      CC       poll.lo
    In file included from /home/simark/src/lttng-tools/src/common/compat/poll.c:15:
    /home/simark/src/lttng-tools/src/common/compat/poll.c: In function ‘compat_epoll_set_max_size’:
    /home/simark/src/lttng-tools/src/common/error.h:247:9: error: declaration of ‘buf’ shadows a previous local [-Werror=shadow]
      247 |   char *buf; \
          |         ^~~
    /home/simark/src/lttng-tools/src/common/compat/poll.c:335:3: note: in expansion of macro ‘PERROR’
      335 |   PERROR("read set max size");
          |   ^~~~~~
    /home/simark/src/lttng-tools/src/common/compat/poll.c:313:7: note: shadowed declaration is here
      313 |  char buf[64];
          |       ^~~

Avoid that by giving PERROR's variables names that are unlikely to be
used elsewhere.

Change-Id: I167491fd3b232e6cfd86d13c0003ad4facb40c58
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoClean-up: filter: fix variable shadowing in visit_node_load_expression
Simon Marchi [Wed, 31 Mar 2021 14:45:01 +0000 (10:45 -0400)] 
Clean-up: filter: fix variable shadowing in visit_node_load_expression

It seems safe to just re-use the `ret` variable at the function-level
scope.

Change-Id: I7826edf2b8bb41f9c202af75a8b5e7dff9cbbcc8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoClean-up: filter: rename variable in filter-grammar-test.c
Simon Marchi [Wed, 31 Mar 2021 14:43:46 +0000 (10:43 -0400)] 
Clean-up: filter: rename variable in filter-grammar-test.c

... to avoid variable shadowing.

Change-Id: If5781b7e2f41ab5b1df361b9b247714b17751a32
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoClean-up: sessiond: remove some declarations from lttng-sessiond.h
Simon Marchi [Wed, 31 Mar 2021 14:40:44 +0000 (10:40 -0400)] 
Clean-up: sessiond: remove some declarations from lttng-sessiond.h

As far as I can see, they aren't used anymore, there is no corresponding
definition.

Change-Id: Ie72e643e04da033bd590525de617201303f6dd23
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoClean-up: sessiond: prepend `the_` to global variable names
Simon Marchi [Wed, 31 Mar 2021 14:36:33 +0000 (10:36 -0400)] 
Clean-up: sessiond: prepend `the_` to global variable names

This avoids name clashes between global variables and local variables or
function parameters (notification_thread_handle, for example). This is a
step towards enabling -Wshadow.

This also helps readability, in my opinion, as it helps quickly spot
that some code is using a global variable.

Change-Id: Ib0e35ad7efcc54fa88e1900cab3388b98a06b8d9
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoFix: utils: avoid strncpy overlap in utils_partial_realpath
Simon Marchi [Mon, 12 Apr 2021 17:23:39 +0000 (13:23 -0400)] 
Fix: utils: avoid strncpy overlap in utils_partial_realpath

When running the test_utils_expand_path test with ASan enabled, I get:

➜  lttng-tools ./tests/unit/test_utils_expand_path
1..29
INPUT: /a/b/c/d/e
=================================================================
==1485873==ERROR: AddressSanitizer: strncpy-param-overlap: memory ranges [0x621000021d00,0x621000021d0b) and [0x621000021d00, 0x621000021d0b) overlap
    #0 0x7ffff761fd97 in __interceptor_strncpy /build/gcc/src/gcc/libsanitizer/asan/asan_interceptors.cpp:481
    #1 0x555555573834 in utils_partial_realpath /home/simark/src/lttng-tools/src/common/utils.c:195
    #2 0x55555557410b in _utils_expand_path /home/simark/src/lttng-tools/src/common/utils.c:374
    #3 0x555555574340 in utils_expand_path /home/simark/src/lttng-tools/src/common/utils.c:420
    #4 0x555555570b28 in test_utils_expand_path /home/simark/src/lttng-tools/tests/unit/test_utils_expand_path.c:274
    #5 0x55555557119e in main /home/simark/src/lttng-tools/tests/unit/test_utils_expand_path.c:345
    #6 0x7ffff725fb24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #7 0x55555556fa3d in _start (/home/simark/build/lttng-tools/tests/unit/test_utils_expand_path+0x1ba3d)

0x621000021d00 is located 0 bytes inside of 4096-byte region [0x621000021d00,0x621000022d00)
allocated by thread T0 here:
    #0 0x7ffff7677639 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x55555557269d in zmalloc /home/simark/src/lttng-tools/src/common/macros.h:45
    #2 0x555555573d34 in _utils_expand_path /home/simark/src/lttng-tools/src/common/utils.c:335
    #3 0x555555574340 in utils_expand_path /home/simark/src/lttng-tools/src/common/utils.c:420
    #4 0x555555570b28 in test_utils_expand_path /home/simark/src/lttng-tools/tests/unit/test_utils_expand_path.c:274
    #5 0x55555557119e in main /home/simark/src/lttng-tools/tests/unit/test_utils_expand_path.c:345
    #6 0x7ffff725fb24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)

0x621000021d00 is located 0 bytes inside of 4096-byte region [0x621000021d00,0x621000022d00)
allocated by thread T0 here:
    #0 0x7ffff7677639 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x55555557269d in zmalloc /home/simark/src/lttng-tools/src/common/macros.h:45
    #2 0x555555573d34 in _utils_expand_path /home/simark/src/lttng-tools/src/common/utils.c:335
    #3 0x555555574340 in utils_expand_path /home/simark/src/lttng-tools/src/common/utils.c:420
    #4 0x555555570b28 in test_utils_expand_path /home/simark/src/lttng-tools/tests/unit/test_utils_expand_path.c:274
    #5 0x55555557119e in main /home/simark/src/lttng-tools/tests/unit/test_utils_expand_path.c:345
    #6 0x7ffff725fb24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)

The sole caller of utils_partial_realpath, _utils_expand_path, passes
the same buffer (resolved_path) for the input and output.  This causes
utils_partial_realpath to call strncpy with overlapping strings.

Fix it by making utils_partial_realpath allocate new memory for the
returned string itself.  This causes one more allocation than the
current code, because we don't re-use the existing buffer, but this
should be fine since this isn't exactly performance-critical code.
I think the code is easier to follow as a result.

Change-Id: I98a9aafc08d3bef45e3a83cbeef049f249b86f59
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoClean-up: utils: make utils_partial_realpath static
Simon Marchi [Mon, 12 Apr 2021 17:18:15 +0000 (13:18 -0400)] 
Clean-up: utils: make utils_partial_realpath static

It is only used within its file.

Change-Id: I3e9b01e0cb765c74d3564a7c57598dace8104a29
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoFix: lttng: list_triggers: use proper format specifier for uint64_t
Michael Jeanson [Fri, 9 Apr 2021 17:48:16 +0000 (13:48 -0400)] 
Fix: lttng: list_triggers: use proper format specifier for uint64_t

This fixes a warning on 32 bit systems.

Change-Id: Ie00e340cbe5a2b4e82bb544275bea914708d8e38
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoFix: sessiond: error accounting: wrong sizeof argument cpu_counters
Jérémie Galarneau [Wed, 7 Apr 2021 17:01:44 +0000 (13:01 -0400)] 
Fix: sessiond: error accounting: wrong sizeof argument cpu_counters

1452205 Wrong sizeof argument

The wrong sizeof value is used in an expression or as argument to a function. The result is an incorrect value that may cause unexpected program behaviors.

In create_uid_accounting_entry: The sizeof operator is invoked on the wrong argument (CWE-569)

Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1912964bd1579f3b1ff013000848c28cea6a9d52

3 years agoFix: sessiond: error accounting: wrong sizeof argument cpu_counters
Jérémie Galarneau [Wed, 7 Apr 2021 16:54:09 +0000 (12:54 -0400)] 
Fix: sessiond: error accounting: wrong sizeof argument cpu_counters

`cpu_counters` is an array of `struct lttng_ust_abi_object_data *`, not
of `struct lttng_ust_abi_object_data`. This didn't cause any problems
since the structure is larger than a pointer.

1452203 Wrong sizeof argument

The wrong sizeof value is used in an expression or as argument to a function. The result is an incorrect value that may cause unexpected program behaviors.

In event_notifier_error_accounting_register_app: The sizeof operator is invoked on the wrong argument (CWE-569)

Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9278949aab0a98f050ec232d7b8ce024240020d0

3 years agoFix: sessiond: notification: missing unlock on client list on error
Jérémie Galarneau [Wed, 7 Apr 2021 16:51:36 +0000 (12:51 -0400)] 
Fix: sessiond: notification: missing unlock on client list on error

1452204 Missing unlock

May result in deadlock if there is another attempt to acquire the lock.

In notification_thread_client_subscribe: Missing a release of a lock on a path (CWE-667)

Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iabfe3eecfbea89c96c7f16fbb25a0beef48f78b7

3 years agoDocs: sessiond: document the rationale for the iteration on triggers list
Jérémie Galarneau [Wed, 7 Apr 2021 16:50:51 +0000 (12:50 -0400)] 
Docs: sessiond: document the rationale for the iteration on triggers list

Document the reason why an iteration is performed on the list of
triggers of a "client list" when a client subscribes to a condition.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I7d1c15016064ff2f6498c925f4933450fc7da30b

3 years agoFix: added missing test_channel and removed double defined test_syscall
Anders Wallin via lttng-dev [Wed, 31 Mar 2021 18:54:39 +0000 (20:54 +0200)] 
Fix: added missing test_channel and removed double defined test_syscall

Signed-off-by: Anders Wallin <wallinux@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3f4963e3e10d81f18e4327e8189f9cb8316fe5ed

3 years agoClean-up: sessiond: blasphemous declaration of variable in code
Jérémie Galarneau [Wed, 7 Apr 2021 16:12:25 +0000 (12:12 -0400)] 
Clean-up: sessiond: blasphemous declaration of variable in code

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I5200a2a3e077e3e33f6773a2b0ada1db04261a9f

3 years agoFix: sessiond: error accounting: leak of cpu_counter array on error path
Jérémie Galarneau [Wed, 7 Apr 2021 16:07:43 +0000 (12:07 -0400)] 
Fix: sessiond: error accounting: leak of cpu_counter array on error path

1452202 Resource leak

The system resource will not be reclaimed and reused, reducing the future availability of the resource.

In event_notifier_error_accounting_register_app: 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: I07cc8808b05c497b9bc3099deca58e14f721c5a1

3 years agoFix: sessiond: error accounting: dereference of null pointer on error path
Jérémie Galarneau [Wed, 7 Apr 2021 16:04:58 +0000 (12:04 -0400)] 
Fix: sessiond: error accounting: dereference of null pointer on error path

1452201 Dereference after null check

Either the check against null is unnecessary, or there may be a null pointer dereference.

In event_notifier_error_accounting_register_app: Pointer is checked against null but then dereferenced anyway (CWE-476)

Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I169fd6434606b2a35e076ae9258de6597565effe

3 years agoFix: sessiond: error accounting: unchecked lttng_ht_del return value
Jérémie Galarneau [Wed, 7 Apr 2021 16:01:33 +0000 (12:01 -0400)] 
Fix: sessiond: error accounting: unchecked lttng_ht_del return value

There is no reason for this deletion to fail; assert that it succeeds
to detect any internal error.

1451556 Unchecked return value

If the function returns an error value, the error value may be mistaken for a normal value.

In event_notifier_error_accounting_unregister_event_notifier: Value returned from a function is not checked for errors before being used (CWE-252)

Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3d0f8995608ac96cd3c94b5e92c4459fff592702

3 years agoFix: sessiond: kernel: invalid error code check
Jérémie Galarneau [Wed, 7 Apr 2021 15:55:26 +0000 (11:55 -0400)] 
Fix: sessiond: kernel: invalid error code check

The `EEXIST` error code does not make sense for a kernctl_disable()
operation. In fact, not existing would be an error.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iae193c9c8d8697af3154a9862bf14d4398c60b60

3 years agoFix: sessiond: kernel: missing check for unregistration error
Jérémie Galarneau [Wed, 7 Apr 2021 15:54:17 +0000 (11:54 -0400)] 
Fix: sessiond: kernel: missing check for unregistration error

1451463 Unused value

An assigned value that is never used may represent unnecessary computation, an incorrect algorithm, or possibly the need for cleanup or refactoring.

In synchronize_tracer_notifier_unregister: A value assigned to a variable is never used. (CWE-563)

Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iaea550a2d70730cc4c90f8d1bdcd8cc0a4af6bd8

3 years agoTests: fix: unchecked sscanf return value
Jérémie Galarneau [Wed, 7 Apr 2021 15:49:39 +0000 (11:49 -0400)] 
Tests: fix: unchecked sscanf return value

1407934 Unchecked return value

If the function returns an error value, the error value may be mistaken for a normal value.

In parse_arguments: Value returned from a function is not checked for errors before being used (CWE-252)

Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I7733e88ea6af6313379bd8d4ca131cd243cda401

3 years agoon-event evaluation: remove trigger name accessor
Jérémie Galarneau [Wed, 7 Apr 2021 02:05:26 +0000 (22:05 -0400)] 
on-event evaluation: remove trigger name accessor

The trigger name accessor on an on-event evaluation is no longer needed
as the originating trigger is now accessible on a notification.

The tests are adapted to use the name of the trigger as returned by
the lttng_notification received by the client.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I57bd64d7f5ec35f015dfb115ecfadd75806b9a75

3 years agonotification: add trigger accessor to lttng_notification
Jérémie Galarneau [Wed, 7 Apr 2021 01:10:35 +0000 (21:10 -0400)] 
notification: add trigger accessor to lttng_notification

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If154de643f0d3ec0978b96551b3c3873f4b3380b

3 years agonotification: transmit originating trigger as part of evaluation
Jérémie Galarneau [Wed, 7 Apr 2021 00:41:25 +0000 (20:41 -0400)] 
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

3 years agoFix: .gitignore: use full paths for test binaries
Mathieu Desnoyers [Tue, 6 Apr 2021 18:58:28 +0000 (14:58 -0400)] 
Fix: .gitignore: use full paths for test binaries

Using only the binary name in the .gitignore paths yields confusion
for git and search tools relying on this file's content (e.g. ag
silversearcher), because the binary file name may also be part of a
path, e.g. the filename "gen-ust-events" is also part of the path
leading to the .c file implementing this test:
"./tests/utils/testapp/gen-ust-events/gen-ust-events.c", which means
this .c file is ignored, even though it should not be.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I309b268fed8e66b693c1e0670044b40bf90593c4

3 years agoTests: use TRACEPOINT_INCLUDE
Mathieu Desnoyers [Tue, 6 Apr 2021 18:26:03 +0000 (14:26 -0400)] 
Tests: use TRACEPOINT_INCLUDE

The macro TRACEPOINT_INCLUDE_FILE is deprecated since LTTng-UST 2.1. In
preparation for LTTng-UST 2.13, this compatibility macro is finally
removed.

The tests in lttng-tools need to keep up with times and start using its
replacement: TRACEPOINT_INCLUDE.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id2bb15062f37878de03656dc5a47d9dd35687b41

3 years agoFix: sessiond: ust-app: assertion failure on registration of dead app
Jérémie Galarneau [Fri, 2 Apr 2021 17:11:34 +0000 (13:11 -0400)] 
Fix: sessiond: ust-app: assertion failure on registration of dead app

While setting up the event notifier group of a newly registered
application (see `ust_app_setup_event_notifier_group()`), communications
with the application can fail (generally because the application exited)
while sending the error counter configuration. This causes the UST
handle to the event notifier group to be released.

However, a second release is performed which results in undefined
behaviour (I have seen it succeed, assert, and crash under different
circumstances) while disposing of the application (see
`delete_ust_app()`).

Set the event notifier group ust handle to NULL to mark it as invalid
and prevent a second release during the clean-up.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia5623a8d3f57174effa51c278e9654b6adc43289

3 years agocommon: credentials: hide symbols
Jérémie Galarneau [Fri, 2 Apr 2021 13:07:00 +0000 (09:07 -0400)] 
common: credentials: hide symbols

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I089502d46bdd0cf34b0721703a08fdd28f61b8f7

3 years agotrigger: consider name in trigger _is_equal()`
Francis Deslauriers [Mon, 8 Mar 2021 21:11:37 +0000 (16:11 -0500)] 
trigger: consider name in trigger _is_equal()`

For the moment, this is a breaking change since, before 2.13, users
could not register two identical triggers.

Triggers were previously unnamed, but a name is now generated
automatically. This means that a pre-2.13 user that could expect
a TRIGGER_ALREADY_EXISTS reply when registering a trigger that already
existed will now get "OK".

However, since it doesn't know about trigger names, it could now fail
to unregister a trigger (if the instance used to register the trigger
was not kept around).

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9549980677e2387a7cc0f275233a3b5717fb915e

3 years agoFix: sessiond: notification: use after free of trigger object
Francis Deslauriers [Tue, 23 Mar 2021 23:50:30 +0000 (19:50 -0400)] 
Fix: sessiond: notification: use after free of trigger object

Background
==========
* Clients can subscribe to certain specific conditions (e.g. buffer
  usage) using the `lttng_notification_channel_subscribe()` function.

* This subscription is only useful once a trigger with that condition
  AND at least one notify action is registered.

* The sessiond keeps a list for client subscribed to each registered
  condition.

* More than one trigger with the same condition may be registered
  the sessiond at the same time if they have different actions.

Issue
=====
Currently, when registering a trigger (T1) the sessiond looks if there
is already a client list for the condition of this trigger. If not, the
sessiond links the newly created client list object to that trigger T1
by keeping a pointer to it.

This means that if another trigger (T2) is registered with the same
condition (but a different name, or different actions) it will reuse the
same client list object and use the pointer to the T1.

This causes problems if T1 is unregistered before T2. In that case, the
pointer to T1 in the client list object is pointing to a deallocated
trigger object.

This issue is not encountered with the current test suite, namely the
`test_notification_multi_app` test case, because triggers with the same
condition also had the same action, so they are considered identical and
are not registered.

This issue was first witnessed when adding a trigger name comparison in
the `lttng_trigger_is_equal()` function.

Fix
===
Change the client list object so that it has its own copy of the
condition and a list of dependent triggers. Each trigger with that
condition has a reference on this client list object.

When unregistering a trigger, the notification thread removes it for the
client list's triggers list and put its reference on the client list
object.

Tests
=====
This commit adds a parameter to the base_client that dictates if the
notify action should be in a group. This is a trick to create triggers
that are not equal but have the same behaviour.

The `test_notification_multi_app` test case is modified to turn on this
option every other trigger registration.

Semi-related cleanups
=====================
* Merge `notification_client_list_create()` and
  `publish_notification_client_list()` functions since they are used
  together anyway. This removes the need to call
  `notification_client_list_put()` at the end of the
  `_register_trigger()` function

* Rename `trigger_applies_to_client()` to `condition_applies_to_client()`.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3ebb90a1a64236a440a085e6fc1b82726a0e5af9

3 years agosessiond: Extract `{setup,teardown}_tracer_notifier()` functions
Francis Deslauriers [Thu, 5 Nov 2020 19:55:26 +0000 (14:55 -0500)] 
sessiond: Extract `{setup,teardown}_tracer_notifier()` functions

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ic394b1a50f166afc911b58607aece6ae69422841

3 years agoClean-up: sessiond: Extract trigger_ht_element removal function
Francis Deslauriers [Thu, 5 Nov 2020 17:25:44 +0000 (12:25 -0500)] 
Clean-up: sessiond: Extract trigger_ht_element removal function

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4994d1dce7a8fc188b6df6ad72e5cd1081cb0cc7

3 years agoTests: event notifier error counters
Francis Deslauriers [Mon, 31 Aug 2020 15:05:41 +0000 (11:05 -0400)] 
Tests: event notifier error counters

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9e2a4bab833d9204717029c1d5f594455c2262ce

3 years agosessiond: Implement UST event notifier error counter
Francis Deslauriers [Wed, 14 Oct 2020 19:33:46 +0000 (15:33 -0400)] 
sessiond: Implement UST event notifier error counter

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I254b2cec39b8c61ad945376043b5b9053de98f6f

3 years agocommon: document why spawn_viewer() is public
Jérémie Galarneau [Thu, 1 Apr 2021 03:38:07 +0000 (23:38 -0400)] 
common: document why spawn_viewer() is public

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I09574ebd82bb583db5a7acec2b8f129a7dcd36fc

3 years agoDocs: document trigger condition and action ownership in 2.13+
Jérémie Galarneau [Mon, 1 Mar 2021 20:40:48 +0000 (15:40 -0500)] 
Docs: document trigger condition and action ownership in 2.13+

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8a52f166565efc87c6073713ce0f6569ba6d3661

3 years agoFix: sessiond: kernel: close on badfd on initialization error
Jérémie Galarneau [Mon, 29 Mar 2021 16:17:12 +0000 (12:17 -0400)] 
Fix: sessiond: kernel: close on badfd on initialization error

The various kernel tracer file descriptors are closed during an
initialization error, but are not set to `-1` which causes them to
be closed again when the session daemon performs its clean-up.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I11d3ce7accea51394c34b9ca7ea0445e4ee422fc

3 years agoFix: sessiond: kernel error accounting fd still open when unloading modules
Francis Deslauriers [Fri, 26 Mar 2021 21:06:12 +0000 (17:06 -0400)] 
Fix: sessiond: kernel error accounting fd still open when unloading modules

Issue
=====
I noticed that some kernel modules were not unloading properly when
shutting down the sessiond. Namely those modules:
  lttng_counter_client_percpu_64_modular
  lttng_ring_buffer_event_notifier_client

The call to `modprobe -r` for those modules is failing because the
kernel error accounting fd has not been closed.

Fix
===
Only call `modprobe -r` after all kernel resources (file descriptors)
have been released.

Side note
=========
The `modprobe_remove_lttng()` is currently printing that the removal of a
_OPTIONAL module was a success even if it failed. I rework this function
to print a debug message in such situation. I used the
`modprobe_lttng()` as a template for this function.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ibb51425ef3deedf6e982084ef879bc83ac823ba3

3 years agosessiond: Implement kernel event notifier error counter
Francis Deslauriers [Wed, 14 Oct 2020 19:33:19 +0000 (15:33 -0400)] 
sessiond: Implement kernel event notifier error counter

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I390113873567a98d7e53db605d48b59a60a1074e

3 years agoFix: on-event condition: don't abort() on invalid event expression type
Jérémie Galarneau [Fri, 26 Mar 2021 22:39:30 +0000 (18:39 -0400)] 
Fix: on-event condition: don't abort() on invalid event expression type

Protocol errors should not result in crashes. Simply report the
failure to deserialize the event expression.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ic5a0be6b248c430fcf1fe487cd734d9bdf5dd36a

3 years agoFix: common: index_allocator_get_index_count() returns size
Francis Deslauriers [Fri, 26 Mar 2021 18:41:01 +0000 (14:41 -0400)] 
Fix: common: index_allocator_get_index_count() returns size

The lttng_index_allocator_get_index_count() should return the number of
allocated indexes. Right now it returns the maximum number of indexes.

I witnessed the following message when running testing the event
notifier error counter feature:
  Warning: Destroying index allocator with 4096 slot indexes still in use

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ibbcb3f128553df0a4118901ef85ae6fe17ebcecf

3 years agoon-event: add error counter fields to condition
Francis Deslauriers [Mon, 7 Dec 2020 21:08:30 +0000 (16:08 -0500)] 
on-event: add error counter fields to condition

Modified from proposed change: don't include error counter index in serdes

The error counter index is an internal implementation detail that
doesn't need to be exposed to the client (the accessor is not reacheble
to them anyway).

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ibc84d4cc3bcc7e304f4b52bd45f1de010dd8b87b

3 years agocompiler warning cleanup: is_signed_type: compare -1 to 1
Mathieu Desnoyers [Thu, 25 Mar 2021 19:18:13 +0000 (15:18 -0400)] 
compiler warning cleanup: is_signed_type: compare -1 to 1

Comparing -1 to 0 triggers compiler warnings (gcc -Wtype-limits and
-Wbool-compare) and Coverity warning "Macro compares unsigned to 0".

Comparing -1 to 1 instead takes care of silencing those warnings while
keeping the same behavior.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id4aebce6eed214f0ccba2c0289fb3b034808cb64

3 years agocommon: shm.c: improve logging on various error paths
Jérémie Galarneau [Wed, 24 Mar 2021 23:23:54 +0000 (19:23 -0400)] 
common: shm.c: improve logging on various error paths

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1d68f952b8a01b79aeab7c8d05d98085071a45a7

3 years agoCleanup: Move `create_posix_shm()` to common/shm.c
Francis Deslauriers [Thu, 8 Oct 2020 20:59:57 +0000 (16:59 -0400)] 
Cleanup: Move `create_posix_shm()` to common/shm.c

* This function will be used for trigger error accounting.

* This function is renamed to `shm_create_anonymous()` and now takes one
  parameter for the owner of the shared memory area. Again this is code
  reuse.

* Remove erroneous comment about the `name` parameter for the
  `shm_open()` function. It's the absence (and not its presence) of the
  '/' at the beginning of the name that makes the behaviour implementation
  defined.

* Move the bin/lttng-sessiond/shm.c to common/shm.c so that all shm
  related functions are in one location.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I690b38801ffb4772e7c5069c4cccf470b0671f63

3 years agocommon: Add index allocator for error counters
Francis Deslauriers [Mon, 24 Aug 2020 21:02:05 +0000 (17:02 -0400)] 
common: Add index allocator for error counters

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I677a8f5b774315eadb8e3b2c2f2a5b1aae02133f

3 years agoFix: sessiond: agent: lazy creation of agent on removal
Jérémie Galarneau [Wed, 24 Mar 2021 18:21:40 +0000 (14:21 -0400)] 
Fix: sessiond: agent: lazy creation of agent on removal

When unregistering a trigger that was previously registered, the
agent corresponding to the trigger's domain will already exist. It is
superfluous to handle the case where it doesn't exist and it would only
hide an internal error.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ifc6d14b74586af8423a70b3466e0a2c00491d3c3

3 years agoClean-up: sessiond: make some accesses to conditions const
Jérémie Galarneau [Wed, 24 Mar 2021 16:17:59 +0000 (12:17 -0400)] 
Clean-up: sessiond: make some accesses to conditions const

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I88edd184c06d2f2912331da8e83b624f8ae8bcc2

3 years agoExtract synchronize tracer notifier functions
Francis Deslauriers [Wed, 4 Nov 2020 23:10:52 +0000 (18:10 -0500)] 
Extract synchronize tracer notifier functions

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I2d92227d93ede0b04bf7314ff819c2b777247262

3 years agoCleanup: Extract `ust_app_synchronize_all_channels()` function
Francis Deslauriers [Thu, 14 Jan 2021 22:44:49 +0000 (17:44 -0500)] 
Cleanup: Extract `ust_app_synchronize_all_channels()` function

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id24eff10cc07c5e061fbb45e871087c17eac9b1d

3 years agoust-abi: add missing lttng_ust_abi prefixes
Mathieu Desnoyers [Tue, 23 Mar 2021 19:01:19 +0000 (15:01 -0400)] 
ust-abi: add missing lttng_ust_abi prefixes

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I03f465659cd7b044d1ec10458fa77332d5e9db41

3 years agoclock override: use getter API from LTTng-UST
Mathieu Desnoyers [Tue, 23 Mar 2021 16:01:43 +0000 (12:01 -0400)] 
clock override: use getter API from LTTng-UST

Currently, the lttng session daemon reimplements its own copy of
struct lttng_trace_clock, which is pretty bad as ABI go.

Use getter functions for each of the clock callback instead. This
refactoring needs to be introduced with a matching commit to implement
the new ABI in LTTng-UST.

Move the implementation of the clock frequency, uuid, name and
description default callbacks (for monotonic clock) to lttng-ust.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If2e671bacacc55d3fb27b6b4d4fc8c16aaffd059

3 years agoFix: bytecode test should be in UST_FILTERS, not UST_STR_FILTERS
Mathieu Desnoyers [Tue, 23 Mar 2021 15:22:56 +0000 (11:22 -0400)] 
Fix: bytecode test should be in UST_FILTERS, not UST_STR_FILTERS

The UST test is in the wrong array, making it always succeed when it
should fail when run with a non-patched UST, because it uses a different
test application which does not contain the targeted fields.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I96f74e26ffdead5e03e069c944f215967b7890f2

3 years agoTests: test bytecode linker refusal of non-string arrays and sequences
Mathieu Desnoyers [Mon, 22 Mar 2021 17:23:45 +0000 (13:23 -0400)] 
Tests: test bytecode linker refusal of non-string arrays and sequences

The bytecode linker should refuse loading arrays and sequences of data
which are not strings for the purpose of comparison against other
strings.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id3b14cb6674b0e2e1edaf039fbc5f929708e2451

3 years agoTests: utils.sh: pass arbitrary arguments to start_lttng_sessiond*
Jonathan Rajotte [Tue, 15 Dec 2020 19:03:15 +0000 (14:03 -0500)] 
Tests: utils.sh: pass arbitrary arguments to start_lttng_sessiond*

Allows for easier arguments passing to lttng-sessiond. This is useful
both for debugging manually and passing specific flag as needed in
testing. Passing  "--event-notifier-error-number-of-bucket=X" or "-vvv"
for examples.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I36bd6eaf1c4fc84c3a1e8cfe70a37a46e7130c75

3 years agoCleanup: clarify `buffer_reg_channel` and `ust_registry_channel` variables
Francis Deslauriers [Tue, 2 Feb 2021 17:00:50 +0000 (12:00 -0500)] 
Cleanup: clarify `buffer_reg_channel` and `ust_registry_channel` variables

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3eab9f1c2f53a72209ae95c05a5f9f3669e4ea0f

3 years agoFix: return value of register trigger to the notification thread is not acted upon
Jonathan Rajotte [Tue, 2 Mar 2021 20:07:42 +0000 (15:07 -0500)] 
Fix: return value of register trigger to the notification thread is not acted upon

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I0fd6dea34854b82b6d4c1550c4f84a7c79f9076f

3 years agoTests: Cleanup: gen-syscall-events: remove duplicated help line
Francis Deslauriers [Mon, 15 Mar 2021 19:31:08 +0000 (15:31 -0400)] 
Tests: Cleanup: gen-syscall-events: remove duplicated help line

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id5bc54598f8abf7498f3b81064a83c60379922d6

3 years agoTests: Cleanup: add `lttng_{add, remove}_trigger_ok()` bash functions
Francis Deslauriers [Thu, 4 Mar 2021 22:12:57 +0000 (17:12 -0500)] 
Tests: Cleanup: add `lttng_{add, remove}_trigger_ok()` bash functions

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I63b1f4d2a72b291f93df4548114014a116824864

3 years agoTests: fix: log level rule: leak of rule after test
Jérémie Galarneau [Mon, 22 Mar 2021 17:02:56 +0000 (13:02 -0400)] 
Tests: fix: log level rule: leak of rule after test

1451079 Resource leak

The system resource will not be reclaimed and reused, reducing the future availability of the resource.

In test_log_level_rule_at_least_as_severe_as: 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: Ica923f9f010e51217ca62664faab99cb34999c0b

3 years agoFix: lttng-sessiond: kernel: leak of event notifier rule
Jérémie Galarneau [Mon, 22 Mar 2021 17:00:09 +0000 (13:00 -0400)] 
Fix: lttng-sessiond: kernel: leak of event notifier rule

1445768 Resource leak

The system resource will not be reclaimed and reused, reducing the future availability of the resource.

In kernel_create_event_notifier_rule: 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: I58862b3b38c7e61806e0047840bf68619273db49

3 years agoTests: add log level rule validation tests
Jérémie Galarneau [Thu, 18 Mar 2021 21:11:37 +0000 (17:11 -0400)] 
Tests: add log level rule validation tests

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Idabc5420ac2b188d13ed5537be81128976661357

3 years agoFix: event-rule: report log level rules as unsupported for kernel domain
Jérémie Galarneau [Thu, 18 Mar 2021 23:11:32 +0000 (19:11 -0400)] 
Fix: event-rule: report log level rules as unsupported for kernel domain

Log levels are not supported for by tracepoints for the kernel domain.
Return `LTTNG_EVENT_RULE_STATUS_UNSUPPORTED` when setting a log level
rule on a kernel-domain tracepoint.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I73b6067ec0a11ae1f83098a6966dc956e1772224

3 years agoTests: Fix: list-triggers test case out of date
Francis Deslauriers [Thu, 18 Mar 2021 20:01:34 +0000 (16:01 -0400)] 
Tests: Fix: list-triggers test case out of date

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9d78c025693fce9dc0ae2177d71d24217a4b1d6a

3 years agoTests: add kernel --function basic test case
Francis Deslauriers [Tue, 16 Mar 2021 20:27:23 +0000 (16:27 -0400)] 
Tests: add kernel --function basic test case

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I584be60bd7325433aa9c30338ceb652c48806ac6

3 years agoRename event rule kretprobe to kernel function
Francis Deslauriers [Tue, 16 Mar 2021 18:28:08 +0000 (14:28 -0400)] 
Rename event rule kretprobe to kernel function

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ibbd0cfa74e7d8e5b922debd23fc5f89cdeb14621

3 years agoon-event evaluation: introduce on-event evaluation specific status code
Jérémie Galarneau [Wed, 17 Mar 2021 05:10:27 +0000 (01:10 -0400)] 
on-event evaluation: introduce on-event evaluation specific status code

Before this change, `lttng_evaluation_on_event_get_captured_values`
returns `LTTNG_EVALUATION_STATUS_INVALID` when an evaluation's
condition has no capture descriptors. That status code is also used to
indicate a handful of "invalid parameter" conditions.

Not having captured values in an evaluation should not be considered an
error. Hence, a status enum that is specific to on-event evaluations is
added to introduce a "NONE" status that is not an error (positive value)
and wouldn't make sense for all evaluations (it could mean an error in
other circumstances).

`LTTNG_EVALUATION_ON_EVENT_STATUS_NONE` is returned when the condition
of an on-event evaluation has no capture descriptors.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ic2e3e90317a44c7bb3e95630956565690bffd760

3 years agoevent-notifier: implement `lttng_trigger_needs_tracer_notifier()` function
Francis Deslauriers [Thu, 5 Nov 2020 20:22:03 +0000 (15:22 -0500)] 
event-notifier: implement `lttng_trigger_needs_tracer_notifier()` function

This function is used to tell if a trigger needs a tracer notifier. This
depends on its condition and its actions.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie3c928ba1c705c32e4c2e4c6b6b22aa8c10837a9

3 years agolttng-ctl: Introduce lttng_log_level_rule
Jonathan Rajotte [Fri, 6 Nov 2020 15:06:23 +0000 (10:06 -0500)] 
lttng-ctl: Introduce lttng_log_level_rule

This object corresponds to the criteria a event-rule tracepoint must
respect for an event to be consired under the event-rule tracepoint
criteria.

The lttng tracepoint event rule object now have the following API
function in regards to log level rule:

  lttng_event_rule_tracepoint_set_log_level_rule
  lttng_event_rule_tracepoint_get_log_level_rule

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iefd361d1b7d85c6803e891166429a2830e2404a2

3 years agoClean-up: sort noinst_PROGRAMS in test/unit/Makefile.am
Jonathan Rajotte [Fri, 6 Nov 2020 15:16:28 +0000 (10:16 -0500)] 
Clean-up: sort noinst_PROGRAMS in test/unit/Makefile.am

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I99cb52748495cd7cc364af7ea04ae95a75bb5759

3 years agoClean-up: sort TESTS in test/unit/Makefile.am
Jonathan Rajotte [Fri, 6 Nov 2020 15:06:36 +0000 (10:06 -0500)] 
Clean-up: sort TESTS in test/unit/Makefile.am

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id4d245eef4f0b99038c7ee76d9c783f40d8b849a

3 years agoClean-up: sort files in include/Markefile.am
Jonathan Rajotte [Thu, 5 Nov 2020 20:03:29 +0000 (15:03 -0500)] 
Clean-up: sort files in include/Markefile.am

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Idcdd023916084610669472a55164a3d6e0192496

3 years agoevent-rule: userspace probe: force location on create
Jonathan Rajotte [Thu, 5 Nov 2020 19:59:58 +0000 (14:59 -0500)] 
event-rule: userspace probe: force location on create

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I5775184c62249c642af0ca0315103e040cb2502d

3 years agoevent-rule: userspace probe: rename get/set_name to get/set_event_name
Jonathan Rajotte [Thu, 5 Nov 2020 19:04:33 +0000 (14:04 -0500)] 
event-rule: userspace probe: rename get/set_name to get/set_event_name

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4a7fbd26b4dfe352100a6fa78b828c1da0fa9928

3 years agoevent-rule: kernel probe: force location on create
Jonathan Rajotte [Thu, 5 Nov 2020 17:02:32 +0000 (12:02 -0500)] 
event-rule: kernel probe: force location on create

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I485ab3bb32317d97ad46f7de71c72a37afcd64c2

3 years agoevent-rule: kernel probe: rename set/get_name to set/get_event_name
Jonathan Rajotte [Thu, 5 Nov 2020 16:32:35 +0000 (11:32 -0500)] 
event-rule: kernel probe: rename set/get_name to set/get_event_name

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I14950a663a4db37fe0f120d8f06c01cae241a871

3 years agoevent-rule: syscall: set the default pattern to '*'
Jonathan Rajotte [Thu, 5 Nov 2020 16:28:03 +0000 (11:28 -0500)] 
event-rule: syscall: set the default pattern to '*'

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8456f7f125b9341d31bc7bc2b8474abbc44b5467

3 years agoevent-rule: tracepoint: set default pattern to '*'
Jonathan Rajotte [Thu, 5 Nov 2020 16:24:10 +0000 (11:24 -0500)] 
event-rule: tracepoint: set default pattern to '*'

'*' is set on tracepoint creation.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id20b5e3924a11a336fb08ac6ce10f08ad7fcd80a

3 years agoRename files for condition event-rule to on-event
Jonathan Rajotte [Thu, 5 Nov 2020 02:46:11 +0000 (21:46 -0500)] 
Rename files for condition event-rule to on-event

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8bde2f15674be16c0a21c670affff4c4503ed846

3 years agoRename lttng_condition_event_rule to lttng_condition_on_event
Jonathan Rajotte [Thu, 5 Nov 2020 01:48:56 +0000 (20:48 -0500)] 
Rename lttng_condition_event_rule to lttng_condition_on_event

Files renaming is following.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Icf74aa7cc84b46b1f23bbe1418b7e1241d8dc081

3 years agoRename uprobe files to userspace-probe
Jonathan Rajotte [Thu, 5 Nov 2020 00:18:17 +0000 (19:18 -0500)] 
Rename uprobe files to userspace-probe

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ide5aeca0d56b8a368fa26bf7cc082098e349d8d9

3 years agoRename uprobe to userspace-probe
Jonathan Rajotte [Thu, 5 Nov 2020 00:08:10 +0000 (19:08 -0500)] 
Rename uprobe to userspace-probe

Renaming of associated files follows-up.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iabb6f3599efbac25a4c31b892b791b98ed4f5990

3 years agoRename kprobe file to kernel-probe
Jonathan Rajotte [Wed, 4 Nov 2020 20:45:31 +0000 (15:45 -0500)] 
Rename kprobe file to kernel-probe

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I379bd8d88b4fa4a7d5638dc5bee4d7dd86426dc9

3 years agoRename kprobe to kernel_probe
Jonathan Rajotte [Wed, 4 Nov 2020 20:23:30 +0000 (15:23 -0500)] 
Rename kprobe to kernel_probe

Renaming of the kprobe based file follows.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If9f500234bdb1a97752ffeff8c8549500a5f841a

3 years agoTests: Implement trigger capture test cases
Jonathan Rajotte [Thu, 7 May 2020 15:08:34 +0000 (11:08 -0400)] 
Tests: Implement trigger capture test cases

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I661fd8f72c871c4c38b941e9c9c5f6054383354c
Depends-on: lttng-ust: I8423c510bf6af2f9bf85256e8d6f931d36f7054b

3 years agoman: lttng-add-trigger: document --capture option
Jonathan Rajotte [Wed, 27 May 2020 18:31:13 +0000 (14:31 -0400)] 
man: lttng-add-trigger: document --capture option

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id4041c6647ee9b6ea19896d5a926f910fbf1d378
Depends-on: lttng-ust: I8423c510bf6af2f9bf85256e8d6f931d36f7054b

3 years agoCLI: make list-triggers command print capture expressions
Simon Marchi [Thu, 21 May 2020 02:42:00 +0000 (22:42 -0400)] 
CLI: make list-triggers command print capture expressions

When printing an event rule condition, in the `list-triggers` command,
print the capture expressions associated with that condition.

The result looks like:

    - id: T1
      condition: event rule hit
        rule: allo (type: tracepoint, domain: ust)
        captures:
          - $ctx.foo
      actions:
        notify
    - id: T2
      condition: event rule hit
        rule: allo (type: tracepoint, domain: ust)
        captures:
          - $app.iga:active_clients
      actions:
        notify

Change-Id: Iaa902369a2df3edf2928a935f7565a7c21acb861
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Depends-on: lttng-ust: I8423c510bf6af2f9bf85256e8d6f931d36f7054b

3 years agoSupport capture for kernel tracer
Jonathan Rajotte [Wed, 13 May 2020 23:02:43 +0000 (19:02 -0400)] 
Support capture for kernel tracer

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I26167d259daa8e356a1bb03831ccf6e570b8e305
Depends-on: lttng-ust: I8423c510bf6af2f9bf85256e8d6f931d36f7054b

3 years agolttng: Capture is only supported by tracepoint and syscall event-rules
Jonathan Rajotte [Wed, 13 May 2020 20:24:23 +0000 (16:24 -0400)] 
lttng: Capture is only supported by tracepoint and syscall event-rules

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Idfe07be4e12e0531dfdb778cdb4c011780af7a26
Depends-on: lttng-ust: I8423c510bf6af2f9bf85256e8d6f931d36f7054b

3 years agosessiond: notification-thread: Missing action executor status handling
Jonathan Rajotte [Wed, 23 Sep 2020 20:14:40 +0000 (16:14 -0400)] 
sessiond: notification-thread: Missing action executor status handling

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8666c0728ca140c45d47ac1ecf252bdbf0526e46

3 years agosessiond: notification-thread: Missing domain internal header
Jonathan Rajotte [Wed, 23 Sep 2020 20:14:17 +0000 (16:14 -0400)] 
sessiond: notification-thread: Missing domain internal header

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I0fbd0cd8bd688b1983430c9036351ca501f5abd7

3 years agosessiond: action-executor: Missing notify header
Jonathan Rajotte [Wed, 23 Sep 2020 20:08:05 +0000 (16:08 -0400)] 
sessiond: action-executor: Missing notify header

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6d00f41d1560a0fc73127aca1e37cd9e100f20ee

3 years agoMake captured field values available to event rule cond. evaluation
Philippe Proulx [Fri, 1 May 2020 20:33:26 +0000 (16:33 -0400)] 
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

3 years agonotification: fetch capture payload on notification reception
Jonathan Rajotte [Mon, 8 Mar 2021 20:59:01 +0000 (15:59 -0500)] 
notification: fetch capture payload on notification reception

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id52749b59969276b5390f4494df48940662d5d8c

3 years agoFix: set_ust_capture: missing ABI rename
Mathieu Desnoyers [Mon, 15 Mar 2021 19:58:13 +0000 (15:58 -0400)] 
Fix: set_ust_capture: missing ABI rename

struct lttng_ust_object_data has become struct
lttng_ust_abi_object_data. It gives a compiler warning.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia29eac5903b43a15c02df7204cf5344226d30381

3 years agotests: perf: UNHALTED_REFERENCE_CYCLES might not be actionable on a host
Jonathan Rajotte [Mon, 15 Mar 2021 15:25:07 +0000 (11:25 -0400)] 
tests: perf: UNHALTED_REFERENCE_CYCLES might not be actionable on a host

This patch does NOT address the root problem and only addresses the
validation of the context to be added during the test suite.

Observed issue
==============

The system_tests jobs for master hangs on the perf event test suites.

Cause
=====

The hang is caused by a cleanup problem (reference counting of the trace
chunk on session destroy/rotation) when the activation of a context
fails on a ust app channel.

This patch does NOT address the root problem and only addresses the
validation of the context to be added during the test suite. In all
cases we need to handle when a context fail, but for this test we need
to validate that the context can be added and skip the tests as
necessary based on the host.

The perf tests depend on the presence and accessibility of the
UNHALTED_REFERENCE_CYCLES PMU counter. This test suite was previously
run "manually" and since it required the presence and access to that
PMU. Since that the perf test suite is now run on `make check` when
libpfm is present, we need to automate the discovery of
UNHALTED_REFERENCE_CYCLES and validate that we can access it.

There are three major scenarios were we want to skip the tests.

1) UNHALTED_REFERENCE_CYCLES is simply not present in the PMU sets for
that hosts.

2) UNHALTED_REFERENCE_CYCLES is present in the PMU sets but not
actionable. This can happen on qemu guests.

3) UNHALTED_REFERENCE_CYCLES is present but not accessible. This can be
happen if the `/proc/sys/kernel/perf_event_paranoid` prevents the usage
of the PMU.

Solution
========

Two problems were found with `find_event.c`.

 1) It took the first event matching the passed name even if it was in a
 PMU not supported by the host. In our use case it worked since the only
 platform that does not use `r300` is not currently in our testing set.

 -> = PMU set currently choosen
 -* = The correct PMU set

 e.g:
 -> Intel Core
      r300
    Intel Atom
      r300
    Intel Nehalem
      r300
    Intel Nehalem EX
      r300
    Intel X86 architectural PMU
      r13c
    ...
 -* Intel Skylake
     r300

 On my system only the following are "detected" as per libpfm example
 found here [1].

   [18, ix86arch, "Intel X86 architectural PMU"]
   [51, perf, "perf_events generic PMU"]
   [110, rapl, "Intel RAPL"]
   [114, perf_raw, "perf_events raw PMU"]
   [200, skl, "Intel Skylake"]

 Hence the `skl` PMU set should be used.

 2) libpfm does not perform any validation as to if the event is actually
 usable or not.

To fix those two problems, we use pfm_get_os_event_encoding and
perf_event_open.

pfm_get_os_event_encoding [2] is responsible for performing the query
across valid PMU sets and encoding it to the perf struct format.

perf_event_open is used to validate that the event can be used. It tests
the availability on the running host and the accessibility of the PMU.

Based on the result of `find_event` the tests are skipped or failed as
necessary.

Known drawbacks
========

The only drawback is that the tests, albeit having libpfm as a
dependency, are not guarantee to run on all hosts. There is not much we
can do here. We can only validate that it is indeed run on our CI, most
probably using lava hardware-based workers.

References
==========

[1] https://sourceforge.net/p/perfmon2/libpfm4/ci/288483932c3eb83202b0d8762aa0ed8534982c3f/tree/examples/check_events.c
[2] https://man7.org/linux/man-pages/man3/pfm_get_os_event_encoding.3.html
[3] https://man7.org/linux/man-pages/man2/perf_event_open.2.html

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iea7794dc28d019953930992a2237a1b606368d1f

This page took 0.04653 seconds and 4 git commands to generate.