lttng-tools.git
3 years agoTests: test_notification_ust: reduce number of event generated
Francis Deslauriers [Fri, 14 Feb 2020 16:26:55 +0000 (11:26 -0500)] 
Tests: test_notification_ust: reduce number of event generated

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie5f05a7b3d2d9ff2b990e0d1f5e59a350a854b30
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: notification: make testcases manage the test app
Francis Deslauriers [Tue, 11 Feb 2020 03:37:03 +0000 (22:37 -0500)] 
Tests: notification: make testcases manage the test app

Each testcase should resume the application if needed. They must ensure
they suspend it before returning.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I5d4f5f43886af676163ab6190b90181bfb575170
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: Cleanup: apply coding style to `test_notification_channel()`
Francis Deslauriers [Thu, 6 Feb 2020 17:37:24 +0000 (12:37 -0500)] 
Tests: Cleanup: apply coding style to `test_notification_channel()`

I also ran clang-format on this patch.

No behavior changes intented.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I7089a288b626e94bed2543f5b13de0537b4d5e4d
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoTests: Cleanup: extract duplicated code to `setup_buffer_usage_condition()`
Francis Deslauriers [Thu, 6 Feb 2020 17:24:08 +0000 (12:24 -0500)] 
Tests: Cleanup: extract duplicated code to `setup_buffer_usage_condition()`

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I401751d6ae92fb96b532972257a9a8127919778d
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoFix: lttng: add-trigger: leak of argpar state
Jérémie Galarneau [Fri, 26 Feb 2021 19:09:16 +0000 (14:09 -0500)] 
Fix: lttng: add-trigger: leak of argpar state

1447049 Resource leak

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

In handle_action_simple_session: Leak of memory or pointers to system resources (CWE-404)

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

3 years agoFix: lttng: add-trigger: leak of error string
Jérémie Galarneau [Fri, 26 Feb 2021 19:06:57 +0000 (14:06 -0500)] 
Fix: lttng: add-trigger: leak of error string

argpar_state_parse_next allocates an error string on
`ARGPAR_STATE_PARSE_NEXT_STATUS_ERROR_UNKNOWN_OPT` which we choose not
to handle as an error. Still, the error must be free'd.

1447048 Resource leak

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

In handle_action_simple_session: Leak of memory or pointers to system resources (CWE-404)

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

3 years agoFix: lttng: add-trigger: leak of max_size_arg argument
Jérémie Galarneau [Fri, 26 Feb 2021 19:02:55 +0000 (14:02 -0500)] 
Fix: lttng: add-trigger: leak of max_size_arg argument

1447046 Resource leak

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

In handle_action_snapshot_session: Leak of memory or pointers to system resources (CWE-404)

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

3 years agoFix: lttng: add-trigger: leak of source argument
Jérémie Galarneau [Fri, 26 Feb 2021 19:02:06 +0000 (14:02 -0500)] 
Fix: lttng: add-trigger: leak of source argument

1447045 Resource leak

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

In parse_event_rule: Leak of memory or pointers to system resources (CWE-404)

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

3 years agoClean-up: uri_parse_str_urls: assert on invalid uri_parse() return values
Jérémie Galarneau [Fri, 26 Feb 2021 18:58:16 +0000 (13:58 -0500)] 
Clean-up: uri_parse_str_urls: assert on invalid uri_parse() return values

uri_parse() can only ever return values [-1, 2] and callers only handle
those values. This causes Coverity to report possible leaks and other
errors when analyzing callers.

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

3 years agoFix: lttng: add-trigger: leak of argpar_item
Jérémie Galarneau [Fri, 26 Feb 2021 18:47:22 +0000 (13:47 -0500)] 
Fix: lttng: add-trigger: leak of argpar_item

1447047 Resource leak

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

In handle_action_simple_session: Leak of memory or pointers to system resources (CWE-404)

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

3 years agoFix: lttng: add-trigger: erroneous null check
Jérémie Galarneau [Fri, 26 Feb 2021 18:43:42 +0000 (13:43 -0500)] 
Fix: lttng: add-trigger: erroneous null check

1447042 Dereference before null check

There may be a null pointer dereference, or else the comparison against null is unnecessary.

In parse_kernel_probe_opts: All paths that lead to this null pointer comparison already dereference the pointer earlier (CWE-476)

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

3 years agoFix: lttng: include lttng-list-trigger missing an 's'
Anders Wallin via lttng-dev [Wed, 3 Mar 2021 08:38:01 +0000 (09:38 +0100)] 
Fix: lttng: include lttng-list-trigger missing an 's'

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

3 years agoClean-up: lttng: logging: use ARRAY_SIZE macro
Jérémie Galarneau [Tue, 16 Feb 2021 20:47:28 +0000 (15:47 -0500)] 
Clean-up: lttng: logging: use ARRAY_SIZE macro

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

3 years agosessiond: notification-thread: Use lttng_domain_type_str()
Jonathan Rajotte [Wed, 3 Jun 2020 20:14:28 +0000 (16:14 -0400)] 
sessiond: notification-thread: Use lttng_domain_type_str()

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

3 years agolttng: Add remove-trigger command
Simon Marchi [Mon, 20 Jan 2020 21:39:56 +0000 (16:39 -0500)] 
lttng: Add remove-trigger command

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

3 years agolttng: Add list-triggers command
Simon Marchi [Mon, 20 Jan 2020 22:25:19 +0000 (17:25 -0500)] 
lttng: Add list-triggers command

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

3 years agoDocs: document --condition and --action in add-trigger's OPTIONS section
Simon Marchi [Fri, 14 Feb 2020 17:42:15 +0000 (12:42 -0500)] 
Docs: document --condition and --action in add-trigger's OPTIONS section

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

3 years agoDocs: Add lttng-add-trigger man page
Simon Marchi [Fri, 17 Jan 2020 19:06:39 +0000 (14:06 -0500)] 
Docs: Add lttng-add-trigger man page

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

3 years agolttng: Add add-trigger command
Simon Marchi [Tue, 3 Dec 2019 21:05:21 +0000 (16:05 -0500)] 
lttng: Add add-trigger command

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

3 years agoTests: Add add-trigger CLI tests
Jonathan Rajotte [Thu, 29 Oct 2020 17:59:05 +0000 (13:59 -0400)] 
Tests: Add add-trigger CLI tests

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

3 years agoTests: add raw perf test to the test list when building with libpfm support
Jérémie Galarneau [Tue, 16 Feb 2021 16:33:48 +0000 (11:33 -0500)] 
Tests: add raw perf test to the test list when building with libpfm support

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

3 years agoClean-up: lttng: only include lttng.h
Jérémie Galarneau [Wed, 24 Feb 2021 19:59:49 +0000 (14:59 -0500)] 
Clean-up: lttng: only include lttng.h

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

3 years agolttng.h: add missing public headers and sort them
Jérémie Galarneau [Wed, 24 Feb 2021 19:49:16 +0000 (14:49 -0500)] 
lttng.h: add missing public headers and sort them

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

3 years agoClean-up: lttng: replace manual string comparison code by strcasecmp
Jérémie Galarneau [Thu, 18 Feb 2021 22:04:46 +0000 (17:04 -0500)] 
Clean-up: lttng: replace manual string comparison code by strcasecmp

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

3 years agoFix: lttng-ctl: appending to dynamic buffer invalidates its data member
Jérémie Galarneau [Thu, 18 Feb 2021 23:13:19 +0000 (18:13 -0500)] 
Fix: lttng-ctl: appending to dynamic buffer invalidates its data member

`lttng_register_trigger` samples the address of the lsm header in the
message payload. However, it does so before calling
`lttng_trigger_serialize()` which may increase the underlying buffer's
size (and cause a realloc()).

Most of the time the message buffer is large enough _or_ its realloc
yields the same address which hid the problem. However, I stumbled on
a case (a trigger which snapshots to a long location) where the realloc
ends-up returning a completely different address, causing invalid data
to be sent to the session daemon.

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

3 years agoImplement list_cmd_options_argpar
Jonathan Rajotte [Thu, 27 Aug 2020 19:56:43 +0000 (15:56 -0400)] 
Implement list_cmd_options_argpar

Small utility allowing the printing of argpar options.

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

3 years agoCLI: Import argpar
Simon Marchi [Thu, 5 Dec 2019 19:12:16 +0000 (14:12 -0500)] 
CLI: Import argpar

This patch imports the argpar code into lttng-tools.  At first, it will
be used to implement the create-trigger command, but if it proves
useful, it could help to implement all other commands too.

Synced with the upstream argpar code as of 1ae22b5e.

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

3 years agoImplement utils_parse_unsigned_long_long
Jonathan Rajotte [Thu, 27 Aug 2020 19:39:26 +0000 (15:39 -0400)] 
Implement utils_parse_unsigned_long_long

To be used for trigger creation.

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

3 years agolttng: move parse_userspace_probe_opts to a common util
Jonathan Rajotte [Thu, 27 Aug 2020 19:07:06 +0000 (15:07 -0400)] 
lttng: move parse_userspace_probe_opts to a common util

parse_userspace_probe_opts will be reused for trigger creation.

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

3 years agoClean-up: lttng: silence bogus warning
Jérémie Galarneau [Fri, 12 Feb 2021 18:34:47 +0000 (13:34 -0500)] 
Clean-up: lttng: silence bogus warning

clang warns that `name_search_ret` may be used unitiliazed if the domain
is none of {ust, python, log4j, jul}. However, those branches are only
accessible when one of these domains is used.

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

3 years agolttng: move log level name to numerical value conversions to a common util
Jérémie Galarneau [Thu, 27 Aug 2020 19:16:29 +0000 (15:16 -0400)] 
lttng: move log level name to numerical value conversions to a common util

Move the utils used by the `enable-event` command to convert log level
names (textual) to their values (entries in their respective enums).

Since these utils will be used by other commands in the future, the code
is cleaned-up, notably to maintain type-safety by returning specific
enums rather than casting to `int`.

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

3 years agosessiond: action-executor: log trigger name rather than its address
Jérémie Galarneau [Thu, 11 Feb 2021 16:43:51 +0000 (11:43 -0500)] 
sessiond: action-executor: log trigger name rather than its address

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

3 years agoFix: action-executor: address of trigger name logged instead of trigger name
Jérémie Galarneau [Thu, 11 Feb 2021 16:42:10 +0000 (11:42 -0500)] 
Fix: action-executor: address of trigger name logged instead of trigger name

The "%p" was left in place when some logging statements of action
executor were changed to log trigger names rather than their address.

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

3 years agosessiond: docs: document action_executor_enqueue() parameter ownership
Jérémie Galarneau [Thu, 11 Feb 2021 16:37:33 +0000 (11:37 -0500)] 
sessiond: docs: document action_executor_enqueue() parameter ownership

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

3 years agosessiond: defer tracer notification jobs to the action executor
Jonathan Rajotte [Fri, 24 Jan 2020 22:37:54 +0000 (17:37 -0500)] 
sessiond: defer tracer notification jobs to the action executor

Create an event rule evaluation and enqueue a job to execute the
actions associated with the corresponding trigger on the action executor
work queue.

Clients are notified that a notification was dropped if the action
executor queue is full at the time of invocation.

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

3 years agoFix: consumer: timer: uninitialized sigevent fields
Jérémie Galarneau [Thu, 11 Feb 2021 15:28:54 +0000 (10:28 -0500)] 
Fix: consumer: timer: uninitialized sigevent fields

Coverity reports:
1445769 Uninitialized scalar variable
The variable will contain an arbitrary value left from earlier computations.
In consumer_channel_timer_start: Use of an uninitialized variable (CWE-457)

CID 1445769 (#1 of 1): Uninitialized scalar variable (UNINIT)7.
uninit_use_in_call: Using uninitialized value sev. Field sev._sigev_un
is uninitialized when calling timer_create.

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

3 years agoFix: sessiond: notification: unreachable code in switch-case
Jérémie Galarneau [Wed, 10 Feb 2021 22:24:21 +0000 (17:24 -0500)] 
Fix: sessiond: notification: unreachable code in switch-case

A copy paste error introduced in bc8daafb causes the initialization
of the session credentials to not be initialized.

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

3 years agoFix: sessiond: client: leak of trigger object on invalid client message
Jérémie Galarneau [Wed, 10 Feb 2021 19:33:11 +0000 (14:33 -0500)] 
Fix: sessiond: client: leak of trigger object on invalid client message

Coverity reports:
1445927 Resource leak
The system resource will not be reclaimed and reused, reducing the future availability of the resource.
In receive_lttng_trigger: Leak of memory or pointers to system resources (CWE-404)

lttng_trigger_create_from_payload() can return a trigger (positive
return value) that doesn't match the advertised trigger size. In that
case, a trigger reference was still returned and must be released.

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

3 years agoFix: sessiond: timer: unitiliazed sigevent fields
Jérémie Galarneau [Wed, 10 Feb 2021 19:25:57 +0000 (14:25 -0500)] 
Fix: sessiond: timer: unitiliazed sigevent fields

Coverity reports:
1445773 Uninitialized scalar variable
The variable will contain an arbitrary value left from earlier computations.
In timer_start: Use of an uninitialized variable (CWE-457)

CID 1445773 (#1 of 1): Uninitialized scalar variable (UNINIT)2.
uninit_use_in_call: Using uninitialized value sev. Field sev._sigev_un
is uninitialized when calling timer_create

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

3 years agoFix: sessiond: ust-registry: dereference of NULL pointer on allocation failure
Jérémie Galarneau [Wed, 10 Feb 2021 19:20:34 +0000 (14:20 -0500)] 
Fix: sessiond: ust-registry: dereference of NULL pointer on allocation failure

Coverity reports:
1445771 Dereference after null check
Either the check against null is unnecessary, or there may be a null pointer dereference.
In ust_registry_channel_add: 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: I3976e0d7b059b47ca233bc9a20585eff2e1290fc

3 years agoFix: sessiond: kernel: leak of notifier rule on failure to init notifier
Jérémie Galarneau [Wed, 10 Feb 2021 19:08:55 +0000 (14:08 -0500)] 
Fix: sessiond: kernel: leak of notifier rule on failure to init notifier

Coverity reports:
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: Ica3f414fb7640ecddf9affbcc359121b04a82277

3 years agolttng-ctl: health: remove unreachable condition
Jérémie Galarneau [Wed, 10 Feb 2021 19:04:09 +0000 (14:04 -0500)] 
lttng-ctl: health: remove unreachable condition

Coverity reports:
1442789 Logically dead code
The indicated dead code may have performed some action; that action will never occur.
In lttng_health_create_relayd: Code can never be reached because of a logical contradiction (CWE-561)

`path` is already checked for NULL before reaching the lttng_strncpy
call.

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

3 years agoFix: sessiond: uninitialized credentials set for unbound trigger
Jérémie Galarneau [Wed, 10 Feb 2021 18:59:48 +0000 (13:59 -0500)] 
Fix: sessiond: uninitialized credentials set for unbound trigger

The bound-object credentials should be left unset when the trigger
doesn't have to bind to an object.

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

3 years agobuffer-view: improve logging on creation failure
Jérémie Galarneau [Tue, 9 Feb 2021 22:09:37 +0000 (17:09 -0500)] 
buffer-view: improve logging on creation failure

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

3 years agoFix: sessiond: leak of trigger on registration error
Jérémie Galarneau [Tue, 9 Feb 2021 22:08:45 +0000 (17:08 -0500)] 
Fix: sessiond: leak of trigger on registration error

The caller of cmd_register_trigger assumes that no triggers are returned
on error. This causes a leak of the reference to the returned trigger.

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

3 years agosessiond: kernel: misleading log message on event rule creation failure
Jérémie Galarneau [Tue, 9 Feb 2021 21:10:18 +0000 (16:10 -0500)] 
sessiond: kernel: misleading log message on event rule creation failure

A logging message referring to "triggers" is emitted when failing to
create an event notifier rule in the kernel domain.

The name trigger was left-over since the terminology used to refer to
those internal objects changed.

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

3 years agoFix: sessiond: trace-kernel: function return code overwritten
Jérémie Galarneau [Tue, 9 Feb 2021 21:04:05 +0000 (16:04 -0500)] 
Fix: sessiond: trace-kernel: function return code overwritten

A string copy, performed using `lttng_strncpy` is performed at the end
of trace_kernel_init_event_notifier_from_event_rule() and its return
value is stored in the function's `ret` variable, which is of type `enum
lttng_error_code`.

Since LTTNG_OK is not == 0, the return value is interpreted as an error,
which causes the registration of kernel-domain on-event-hit triggers
to fail.

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

3 years agosessiond: convert invalid command return codes to LTTNG_ERR_UNK
Jérémie Galarneau [Tue, 9 Feb 2021 23:36:16 +0000 (18:36 -0500)] 
sessiond: convert invalid command return codes to LTTNG_ERR_UNK

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

3 years agolttng-ctl: convert invalid command return codes to LTTNG_ERR_UNK
Jérémie Galarneau [Tue, 9 Feb 2021 23:36:30 +0000 (18:36 -0500)] 
lttng-ctl: convert invalid command return codes to LTTNG_ERR_UNK

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

3 years agoClean-up: ust-consumer: replace manual metadata cache buffer allocation
Jérémie Galarneau [Tue, 9 Feb 2021 00:01:15 +0000 (19:01 -0500)] 
Clean-up: ust-consumer: replace manual metadata cache buffer allocation

Replace the hand-rolled buffer allocation management code of the
metadata cache by the lttng_dynamic_buffer utility.

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

3 years agoClean-up: ust-consumer: pass metadata cache to its write method
Jérémie Galarneau [Mon, 8 Feb 2021 23:04:20 +0000 (18:04 -0500)] 
Clean-up: ust-consumer: pass metadata cache to its write method

The consumer_metadata_cache_write function doesn't need access to the
metadata channel; it can operate on the metadata cache itself and
doesn't need to access its channel.

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

3 years agoFix: ust-consumer: metadata thread not woken-up after version change
Jérémie Galarneau [Mon, 8 Feb 2021 19:40:33 +0000 (14:40 -0500)] 
Fix: ust-consumer: metadata thread not woken-up after version change

Issue observed
==============

The metadata regeneration test fails, very rarely, in the "streaming"
case on the CI. The interesting part of the test boils down to:
  1) start session
  2) launch an app tracing one event
  3) stop session
  4) delete metadata file
  5) start session
  6) regenerate metadata
  7) stop session
  8) destroy session
  9) read trace: babeltrace fails on an invalid metadata file.

The problem is hard to capture, but modifying the test allows us to see
that there appears to be a short window between steps 7 and 8 where the
metadata file is empty or doesn't exist.

Cause
=====

When metadata is regenerated, its version is bumped and the metadata
cache is "reset". In some cases, such as in this test, the new metadata
will have exactly the same size as it had prior as nothing happened to
change that (e.g. no new apps/probes were registered).

When this occurs, the metadata thread is not woken-up by
consumer_metadata_cache_write() as it sees that max_offset of the
metadata cache didn't change; the data was replaced but it has the same
size.

The metadata consumption thread also checks for version bumps and
resets the amount of consumed metadata. Hence, if the "cache write"
operation woke up the metadata consumption thread, the stream's
"ust metadata pushed" state would be reset and the new contents would
be consumed.

Solution
========

The metadata stream's "ust metadata pushed" position is directly reset
to zero when a metadata version change is detected by the metadata
cache. The metadata poll thread is also woken up to resume the
consumption of the newly-available data.

It is unclear why the change to the consumption position was only done
on the metadata consumption thread's code path and not directly by the
session daemon command handling.

Note that a session rotation will also result in a reset of the pushed
position and a wake-up of the metadata poll thread from the command
handling thread. I am speculating that this couldn't be done due to the
design of the locking at the time of the original
implementation (I haven't checked).

In implementing this change, the metadata reception code path is
untangled a bit to separate the logic that affects the metadata stream
from the logic that manages the metadata cache. I suspect the original
error stems from a mix-up/confusion between both concerns.

When a metadata version change happens, the metadata cache resets its
'max_offset' (in other words, it's current size) and notifies the
caller. The caller then resets the "ust pushed metadata" position to
zero and wakes-up the metadata thread to consume the new contents of the
metadata cache.

Known drawbacks
===============

None.

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

3 years agoFix: ust-consumer: metadata cache lock not taken when sampling max offset
Jérémie Galarneau [Mon, 8 Feb 2021 18:03:20 +0000 (13:03 -0500)] 
Fix: ust-consumer: metadata cache lock not taken when sampling max offset

Found by inspecting the code while searching for an unrelated problem.
The 'max_offset' field is probably only accessed by the sessiond
poll thread, but this isn't a documented (nor reasonably maintainable)
guarantee.

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

3 years agoClean-up: ust-consumer: simplify metadata cache unlock on error path
Jérémie Galarneau [Mon, 8 Feb 2021 18:00:56 +0000 (13:00 -0500)] 
Clean-up: ust-consumer: simplify metadata cache unlock on error path

The metadata cache lock can be released directly after the call to
consumer_metadata_cache_write() since nothing depends on the cache
being locked after.

This simplifies the unlocking of the metadata cache by removing an
extra "unlock" that is specific to an error path.

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

3 years agoFix: sessiond: acquire session list lock when updating event notifiers
Jérémie Galarneau [Thu, 4 Feb 2021 23:18:32 +0000 (18:18 -0500)] 
Fix: sessiond: acquire session list lock when updating event notifiers

Registering triggers with an on-event hit condition affects event
notifiers, imposing a synchronization of enablers with the user space
tracers.

As noted in the comments of session.h, the session list lock protects
those updates and is, ultimately, ill-named. The comment is adjusted to
mention "tracer configurations" rather than "session configurations"
since event notifiers are not part of a session, making the comment
imprecise.

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

3 years agosessiond: agent: enable events matching event notifiers
Jonathan Rajotte [Tue, 11 Feb 2020 20:59:02 +0000 (15:59 -0500)] 
sessiond: agent: enable events matching event notifiers

Per event notifier domain agents
--------------------------------

A `struct agent` instance encapsulates the agent events of an agent
domain for a given session. In the context of event notifiers, there is
no session involved to scope the agent instance.

Hence, per-domain instances are maintained to control event-notifiers
enabled by triggers.

Agent event enable count
------------------------

Agents act as a pre-filter on user space tracer events. In order to
honor triggers use event notifiers (on-event-hit conditions), the
register/unregister trigger commands are modified to ensure 'agent'
domain events are created and enabled/disabled suitably for the user
space tracer to be invoked.

Note that since agent events are a "filter" before event enablers, an
event-rule targetting a ring buffer and an identical event-rule
targetting an event notifier can be enabled. The action to take when the
event is hit is completely opaque to the agents. In such cases, the same
agent event instance needs to be enabled and the current implementation
doesn't allow duplicate agent events.

Hence, `struct agent_event`'s enabled state is now a counter which
accounts for all enabled event-rules that require this agent event to be
enabled. The agent event is enabled when one or more event rules
matching it are enabled and it is disabled when that count reached zero.

To ensure no code checks for the agent_event's enabled state by
comparing to '1', a new `AGENT_EVENT_IS_ENABLED` macro is introduced.
The existing code using the `enabled` attribute directly is modified to
use it.

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

3 years agoFix: sessiond: assertion fails when getting name of trigger
Jérémie Galarneau [Wed, 3 Feb 2021 22:00:06 +0000 (17:00 -0500)] 
Fix: sessiond: assertion fails when getting name of trigger

Left-over debug code assumes that a trigger is named and logs
registration/unregistration failures as errors, resulting in a spammy
sessiond output.

Reduce the logging verbodity of those statements to DBG and handle
unnamed triggers.

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

3 years agosessiond: client commands: print command enum as a string
Francis Deslauriers [Thu, 22 Oct 2020 15:32:15 +0000 (11:32 -0400)] 
sessiond: client commands: print command enum as a string

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

3 years agoCleanup: add `notification_command_type_str()`
Francis Deslauriers [Mon, 14 Dec 2020 22:37:42 +0000 (17:37 -0500)] 
Cleanup: add `notification_command_type_str()`

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

3 years agoFix: lttng-sessiond: Taking sizeof of a pointer
Francis Deslauriers [Wed, 13 Jan 2021 17:04:49 +0000 (12:04 -0500)] 
Fix: lttng-sessiond: Taking sizeof of a pointer

Reported by clang-tidy:
  bugprone-sizeof-expression: Suspicious usage of `sizeof(A*)`

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

3 years agoUse MT-safe strtok_r in spawn viewer library helper
Mathieu Desnoyers [Wed, 3 Feb 2021 15:26:03 +0000 (10:26 -0500)] 
Use MT-safe strtok_r in spawn viewer library helper

Even though its current callers are all in single-threaded context
(lttng view and lttng-crash commands), it is a good practice to use
MT-safe APIs in library functions, in case those are ever used within a
multithreaded context in the future.

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

3 years agoFix: use MT-safe strtok_r in multithreaded context
Mathieu Desnoyers [Wed, 3 Feb 2021 15:21:42 +0000 (10:21 -0500)] 
Fix: use MT-safe strtok_r in multithreaded context

append_list_to_probes uses the non-multithread-safe "strtok" while in
multithreaded context.

It is called by modprobe_lttng_data(), which is called from
init_kernel_tracer().

init_kernel_tracer is used from main() after other threads are created,
and also from process_client_msg() when a user attempts to interact with
the kernel domain if the kernel tracer has not yet been successfully
initialized.

Fixed by using the MT-safe strtok_r() instead.

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

3 years agosessiond: synchronize event notifiers for UST tracers and the kernel tracer
Jonathan Rajotte [Fri, 10 Jan 2020 20:29:52 +0000 (15:29 -0500)] 
sessiond: synchronize event notifiers for UST tracers and the kernel tracer

Synchronize event notifiers when registering or unregistering a trigger
which has a condition that implies the use of an event notifier.

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

3 years agoFix: sessiond: ust-app: account for the event notification pipes fds
Jérémie Galarneau [Thu, 21 Jan 2021 17:30:38 +0000 (12:30 -0500)] 
Fix: sessiond: ust-app: account for the event notification pipes fds

The file descriptors of the event notifier group's event pipe are not
accounted by the lttng_fd_*() module, which tracks the use the file
descriptors by the userspace tracer.

Add the necessary lttng_fd_*() uses to account for the pipe's file
descriptors over their lifetime.

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

3 years agosessiond: ust-app: close the event notifier group's pipe write-end
Jérémie Galarneau [Thu, 21 Jan 2021 17:28:59 +0000 (12:28 -0500)] 
sessiond: ust-app: close the event notifier group's pipe write-end

The write-end of the event notifier group's pipe can be closed after
it is passed to the application. This reduces the amount of file
descriptors used by the session daemon on a per-application basis.

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

3 years agosessiond: notification: receive incoming notifications from tracers
Jonathan Rajotte [Tue, 31 Mar 2020 18:33:18 +0000 (14:33 -0400)] 
sessiond: notification: receive incoming notifications from tracers

Receive and discard notifications received by tracers. This simply puts
in place the basic tracer notification reception mechanisms.

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

3 years agosessiond: unregister triggers during clean-up on shutdown
Jérémie Galarneau [Tue, 26 Jan 2021 23:15:15 +0000 (18:15 -0500)] 
sessiond: unregister triggers during clean-up on shutdown

Triggers should be unregistered on sessiond clean-up. This allows the
kernel and user space tracer control code to assume that all event
notifiers have already been destroyed on tear-down and that any
remaining event notifier is the result of a leak.

Moreover, it simplifies the tear down as it is simply handled in the
way a regular trigger unregistration would be.

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

3 years agosessiond: trigger: decouple reception of triggers from commands
Jérémie Galarneau [Tue, 26 Jan 2021 23:13:11 +0000 (18:13 -0500)] 
sessiond: trigger: decouple reception of triggers from commands

The trigger to register/unregister is received in the body of the
register and unregister commands.

Isolate the reception of the trigger from the command payload in
a util in client.c (receive_lttng_trigger()) which allows the commands
to only operate on fully-formed objects.

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

3 years agosessiond: clean-up: trigger to unregister can be 'const'
Jérémie Galarneau [Tue, 26 Jan 2021 21:14:33 +0000 (16:14 -0500)] 
sessiond: clean-up: trigger to unregister can be 'const'

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

3 years agoFix: sessiond: double free on duplicate removal of tracer source
Jérémie Galarneau [Thu, 28 Jan 2021 19:39:37 +0000 (14:39 -0500)] 
Fix: sessiond: double free on duplicate removal of tracer source

An unrelated bug (fixed in a separate commit) can cause an event source
to be removed from the notification thread's monitored sources twice.

The event source removal starts by searching for the source to remove
based on the source pipe's read-end fd number and assumes that it will
always be found. After iterating on the list, an assertion that
`source_element` is not NULL is done in the assumption that NULL would
mean that the source was not found.

This is incorrect since, if the source is not found, `source_element`
will simply point to the last element of the list, causing the assertion
to succeed.

Then, the last source in the list is torn down, but not removed from the
list. This causes that event source to be free'd twice when it is
actually removed later on.

The assumption that an event source can always be found does not hold
for the moment. For instance, when an application can exit, closing its
end of the notification pipe, the notification thread could wake-up
before the application management thread.

In that case, the notification thread will react to the event by
removing the application's source from its monitored sources. Then, when
the application management thread wakes up, it will ask the notification
thread to (again) remove the event source, which will fail as it will
not be found.

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

3 years agosessiond: kernel triggers: add infrastructure to create event notifiers
Jonathan Rajotte [Mon, 23 Mar 2020 21:09:18 +0000 (17:09 -0400)] 
sessiond: kernel triggers: add infrastructure to create event notifiers

Add the infrastructure to initialize the kernel tracer event notifier
group and individual event notifiers from event rules issued from
triggers.

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

3 years agokernel: event notifier: kernel-ctl interface
Jonathan Rajotte [Mon, 23 Mar 2020 21:03:37 +0000 (17:03 -0400)] 
kernel: event notifier: kernel-ctl interface

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

3 years agokernel: load lttng-ring-buffer-event-notifier-client module
Jonathan Rajotte [Mon, 3 Feb 2020 19:03:25 +0000 (14:03 -0500)] 
kernel: load lttng-ring-buffer-event-notifier-client module

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

3 years agosessiond: kernel: make modules required/optional property per-module
Jérémie Galarneau [Tue, 19 Jan 2021 19:56:49 +0000 (14:56 -0500)] 
sessiond: kernel: make modules required/optional property per-module

Modules are considered required or optional based on their
category (control or data probes). Make the load policy per-probe since
optional control probes will be introduced in a follow-up change.

No change in behaviour is intended by this change.

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

3 years agoFix: add rcu_barrier() after sessiond_cleanup()
Francis Deslauriers [Mon, 14 Dec 2020 22:30:12 +0000 (17:30 -0500)] 
Fix: add rcu_barrier() after sessiond_cleanup()

This is to ensure that tracer event source (event notifier socket) are
removed from the notification thread list.

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

3 years agoust-app: implement event notifier support
Jonathan Rajotte [Mon, 13 Jan 2020 18:59:39 +0000 (13:59 -0500)] 
ust-app: implement event notifier support

Event notifier support mostly resemble how it is done for regular event.

We end up implementing ust_app_synchronize_event_notifier_rules which is
used in a similar fashion to ust_app_synchronize minus the dependency on
a ltt_ust_session session.

The lttng_event_rule_generate_bytecode interface is modified to return a
status code since it could fail (return NULL) for reasons other than not
having exclusions (e.g. an allocation failure).

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

3 years agoFix: liblttng-ctl: unreported truncations when copying strings
Jérémie Galarneau [Tue, 12 Jan 2021 22:41:54 +0000 (17:41 -0500)] 
Fix: liblttng-ctl: unreported truncations when copying strings

gcc 10.2 reports a large number of string truncation warning in
liblttng-ctl. Replace the uses of lttng_ctl_copy_string() util by
lttng_strncpy() (handling the null source case when applicable) and
report the truncations when they occur.

Example gcc warning:
  lttng-ctl.c:86:3: warning: ‘strncpy’ output may be truncated copying 254 bytes from a string of length 254 [-Wstringop-truncation]

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

3 years agoFix: sessiond: event name truncation during listing
Jérémie Galarneau [Tue, 12 Jan 2021 22:08:56 +0000 (17:08 -0500)] 
Fix: sessiond: event name truncation during listing

The use of strncpy can lead to silently-truncated event names. Replace
its use by the internal lttng_strncpy which fails on truncation.

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

3 years agoClean-up: replace erroneous of empty parameter list by void
Jérémie Galarneau [Tue, 12 Jan 2021 20:36:00 +0000 (15:36 -0500)] 
Clean-up: replace erroneous of empty parameter list by void

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

3 years agosessiond: setup event notifier group for registering app
Jonathan Rajotte [Fri, 10 Jan 2020 21:05:48 +0000 (16:05 -0500)] 
sessiond: setup event notifier group for registering app

Create a pipe for each application and setup an event notifier group
associated with that pipe. Transfer the write side to the app, and
transfer the read side to the notification thread as an application
event source ([...]_ADD_TRACER_EVENT_SOURCE)

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

3 years agoFix: configure: support Autoconf 2.70
Jérémie Galarneau [Mon, 11 Jan 2021 23:11:46 +0000 (18:11 -0500)] 
Fix: configure: support Autoconf 2.70

The newly-released autoconf 2.70 introduces a number of breaking
changes [1] and is being rolled-out by some distros.

Amongst those changes, the AC_PROG_CC_STDC macro is marked as obsolete
and was merged into AC_PROG_CC, which we already use. On 2.70, this
results in a warning which we handle as an error.

A version check is added to invoke the AC_PROG_CC_STDC macro only when
running a pre-2.70 version of autoconf, fixing the issue.

A single use of the AC_HELP_STRING macro is replaced by AS_HELP_STRING
as the former was marked as obsolete.

The AC_PROG_LEX now takes an argument, and the argument-less version is
marked as obsolete. The macro is invoked with the `noyywrap` option, as
recommended in the documentation.

Also, the AX_PTHREAD macro makes use of the $as_echo built-in shell
variable which no longer exists in 2.70. A patch was submitted to the
GNU Autoconf archive in March, but there have been no signs of life
given since then [2].

As such, our local copy is updated to the latest version and the patch
(which looks fairly straight-forward / safe) is applied. This should
minimize changes once we go back to an "official" version of the macro.

[1] https://lwn.net/Articles/839395/
[2] https://savannah.gnu.org/patch/?9906

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Reviewed-by: Michael Jeanson <michael.jeanson@efficios.com>
Change-Id: Ie949de73442770f60cbef55300265205527731c6

3 years agoFix: different pthread_getname_np signature() on macOS causes build failure
Michael Jeanson [Wed, 16 Dec 2020 17:40:53 +0000 (12:40 -0500)] 
Fix: different pthread_getname_np signature() on macOS causes build failure

macOS likes to be special so it has pthread_setname_np() without a
thread id parameter, but a pthread_getname_np() with it. Split the
detection macro in two and modifiy the compat layer to handle it.

Change-Id: I8034c54057d68eef59546960c75afe8fbe07f5ad
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agolttng-ust abi: sync _UST_CMD() values
Francis Deslauriers [Fri, 18 Dec 2020 22:00:40 +0000 (17:00 -0500)] 
lttng-ust abi: sync _UST_CMD() values

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

3 years agohashtable: silence -fsanitize=address warning for `hashlittle()` function
Francis Deslauriers [Fri, 4 Dec 2020 18:47:32 +0000 (13:47 -0500)] 
hashtable: silence -fsanitize=address warning for `hashlittle()` function

Issue
=====
The code of this function triggers the following heap-buffer-overflow
warning when compiled with `-fsanitize=address` in specific situation:

  ==247225==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000001310 at pc 0x5559db6c575a bp 0x7f193e6faeb0 sp 0x7f193e6faea0
  READ of size 4 at 0x602000001310 thread T4 (Notification)
      #0 0x5559db6c5759 in hashlittle /home/frdeso/projets/lttng/tools/src/common/hashtable/utils.c:315
      #1 0x5559db6c6df4 in hash_key_str /home/frdeso/projets/lttng/tools/src/common/hashtable/utils.c:490
      #2 0x5559db5e3282 in hash_trigger_by_name_uid /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread-events.c:378
      #3 0x5559db5ecbe3 in trigger_name_taken /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread-events.c:2333
      #4 0x5559db5ecd7c in generate_trigger_name /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread-events.c:2362
      #5 0x5559db5ed6e0 in handle_notification_thread_command_register_trigger /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread-events.c:2491
      #6 0x5559db5ef967 in handle_notification_thread_command /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread-events.c:2927
      #7 0x5559db5ddbb7 in thread_notification /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/notification-thread.c:693
      #8 0x5559db60e56d in launch_thread /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/thread.c:66
      #9 0x7f19456ec608 in start_thread /build/glibc-ZN95T4/glibc-2.31/nptl/pthread_create.c:477
      #10 0x7f1945602292 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x122292)

Given that the `k` pointer used in this loop is a `uint32_t *` we might
read bytes outside of the allocated key if the key is less than 4 bytes
long. As the comment about Valgrind explains, this is not a real problem
because memory protections are typically word bounded.

I tried to use the `__SANITIZE_ADDRESS__` define to select the
Valgrind implementation of this code when building with AddressSanitizer
but that still triggers the same head-buffer-overflow warning.

Why wasn't that a problem before?
=======================================
The trigger feature will use small default names like "T0".

Workaround
==========
Exclude this function from the sanitizing using the compiler attribute
"no_sanitize_address".

Drawback
========
This removes our sanitizing coverage 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: I82d0d3539916ed889faa93871f9b700064f2c52a

3 years agoTests: Fail test if sessiond is not running when it should
Francis Deslauriers [Wed, 9 Dec 2020 03:05:22 +0000 (22:05 -0500)] 
Tests: Fail test if sessiond is not running when it should

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

3 years agoCleanup: erroneous use of CDS_INIT_LIST_HEAD() on node
Francis Deslauriers [Thu, 10 Dec 2020 20:42:22 +0000 (15:42 -0500)] 
Cleanup: erroneous use of CDS_INIT_LIST_HEAD() on node

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

3 years agoUST: update ABI for event notifier
Jonathan Rajotte [Fri, 10 Jan 2020 22:03:05 +0000 (17:03 -0500)] 
UST: update ABI for event notifier

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

3 years agouserspace-probe: Decouple `userspace_probe_add_callsite()` from event and session
Francis Deslauriers [Wed, 22 Jan 2020 16:15:10 +0000 (11:15 -0500)] 
userspace-probe: Decouple `userspace_probe_add_callsite()` from event and session

Currently this function takes event and session pointers:
  - The event is used to get the location type of the probe,
  - the session is used to get the uid and gid of the user to used them
    with the `run_as_*()` functions.

With the incoming trigger support, we want to reuse this function to add
trigger userspace-probe callsites.

This commit extracts what will be common in both event and trigger
implementations by creating a specialized
`userspace_probe_event_add_callsite()` function that uses a generalized
`userspace_probe_add_callsite()`.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia3b90050a7bd227a30af0c11395dcdf5aca13583
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

3 years agoGeneralize disable_ust_event to support multiple types of ust object
Jonathan Rajotte [Mon, 23 Mar 2020 15:56:05 +0000 (11:56 -0400)] 
Generalize disable_ust_event to support multiple types of ust object

This will allow us to pass a trigger object later.

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

3 years agoGeneralize enable_ust_event to support multiple types of ust object
Jonathan Rajotte [Fri, 10 Jan 2020 19:47:30 +0000 (14:47 -0500)] 
Generalize enable_ust_event to support multiple types of ust object

This will allow us to pass a trigger object later.

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

3 years agoGeneralize set_ust_event_exclusion to support multiple types of ust object
Jonathan Rajotte [Mon, 16 Dec 2019 21:01:03 +0000 (16:01 -0500)] 
Generalize set_ust_event_exclusion to support multiple types of ust object

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

3 years agoGeneralize set_ust_event_filter to support multiple types of ust object
Jonathan Rajotte [Mon, 16 Dec 2019 20:48:40 +0000 (15:48 -0500)] 
Generalize set_ust_event_filter to support multiple types of ust object

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

3 years agonotification: mark tracer source element as out of poll set
Jérémie Galarneau [Fri, 18 Dec 2020 21:15:18 +0000 (16:15 -0500)] 
notification: mark tracer source element as out of poll set

Mark the tracer source element as being out of the notification thread's
poll set once it has been removed. This has no effect right now, but it
is less error-prone considering future changes to this function.

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

3 years agoIntroduce trigger hash table with tracer token as key
Jonathan Rajotte [Mon, 13 Jan 2020 18:52:51 +0000 (13:52 -0500)] 
Introduce trigger hash table with tracer token as key

This will allow easy lookup on reception of the tracer token coming
from the tracer.

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

3 years agonotification: add/remove tracer event source
Jonathan Rajotte [Wed, 25 Mar 2020 22:49:32 +0000 (18:49 -0400)] 
notification: add/remove tracer event source

The notification thread will be responsible of consuming the tracer
notification event coming from the UST tracers and kernel tracer.

On a 'add' operation, the tracer event source (i.e read side of a pipe)
is added to the notification poll set. Book-keeping is also done via a
list for later lookup.

On 'remove', the event source is removed from the pollset and from the
list.

On cleanup (notification_thread_handle_destroy), it is expected that all
added tracer event sources be removed by their respective "adder". No
bulk cleanup is performed.

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

3 years agoDBG: add debug statement for trigger not bound to any object
Jonathan Rajotte [Mon, 17 Aug 2020 22:24:35 +0000 (18:24 -0400)] 
DBG: add debug statement for trigger not bound to any object

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

3 years agosessiond: Extract condition hashing functions
Francis Deslauriers [Wed, 9 Sep 2020 21:36:12 +0000 (17:36 -0400)] 
sessiond: Extract condition hashing functions

Extract these functions so it can be used by other files.

The lttng_condition hashing code is kept in this (rather than
common/condition/condition.c) since it makes use of GPLv2 code
(hashtable utils), which we don't want to link in liblttng-ctl.

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

3 years agoCleanup: misplaced white space in `ERR()` statement
Francis Deslauriers [Wed, 9 Dec 2020 13:43:58 +0000 (08:43 -0500)] 
Cleanup: misplaced white space in `ERR()` statement

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

3 years agoAdd base support for event rule hit
Jonathan Rajotte [Mon, 17 Aug 2020 22:23:27 +0000 (18:23 -0400)] 
Add base support for event rule hit

Add some of the scafolding to support event-rule hit conditions.
This includes the hashing of event rule conditions and, consequently,
of event rules and the various probe location types.

The kernel module ABI is checked to verity that the kernel tracer
supports event notifiers.

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

3 years agosessiond: return 'invalid protocol' error on reception error
Jérémie Galarneau [Thu, 26 Nov 2020 20:36:03 +0000 (15:36 -0500)] 
sessiond: return 'invalid protocol' error on reception error

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

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