lttng-tools.git
4 years agoUpdate version to v2.9.15 stable-2.9 v2.9.15
Jérémie Galarneau [Thu, 16 Apr 2020 20:41:02 +0000 (16:41 -0400)] 
Update version to v2.9.15

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agodoc: Fix bind address example for lttng-relayd
Benjamin Poirier [Mon, 6 Jan 2020 05:19:54 +0000 (14:19 +0900)] 
doc: Fix bind address example for lttng-relayd

INADDR_ANY is 0.0.0.0

Fixes: c93eadade277 ("doc/man: use propagated default values in man pages")
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Benjamin Poirier <benjamin.poirier@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6e908adca66b829128ea31cf392bccad3f96d63d

4 years agoUpdate version to v2.9.14 v2.9.14
Jérémie Galarneau [Thu, 17 Oct 2019 19:37:18 +0000 (15:37 -0400)] 
Update version to v2.9.14

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: sessiond: TOCTOU error on save of session configuration
Jérémie Galarneau [Tue, 8 Oct 2019 18:18:31 +0000 (14:18 -0400)] 
Fix: sessiond: TOCTOU error on save of session configuration

The session_save() function checks for the existance and access rights
on the target session configuration filename before opening it. This
results in a TOCTOU (Time of check, time of use) problem.

Defer the check and error reporting to the run_as_open() call.

1191754 Time of check time of use
An attacker could change the filename's file association or other
attributes between the check and use.  In save_session: A check occurs
on a file's attributes before the file is used in a privileged
operation, but things may have changed (CWE-367)

Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: tests: replace truncation-prone logging helper
Jérémie Galarneau [Tue, 8 Oct 2019 18:01:54 +0000 (14:01 -0400)] 
Fix: tests: replace truncation-prone logging helper

The printerr() error logging scheme in test_utils_expand_path
is prone to unexpected truncations which results in a lot of
warnings when building using GCC 9.2.

It is replaced by a variable-argument macro that uses fprintf()
directly.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoUpdate version to v2.9.13 v2.9.13
Jérémie Galarneau [Tue, 1 Oct 2019 20:40:13 +0000 (16:40 -0400)] 
Update version to v2.9.13

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: lttng: out-of-bound copy of arguments in 'view' command handler
Jérémie Galarneau [Thu, 19 Sep 2019 18:24:34 +0000 (14:24 -0400)] 
Fix: lttng: out-of-bound copy of arguments in 'view' command handler

The 'size' operand of memcpy() does not indicate the length of the
opts array; it is the size of the resulting array once the opts array
is concatenated with the options being added in this function. This
results in out-of-bound read(s) in the opts array.

Use 'sizeof(char *) * opts_len' as the length to copy at the beginning
of the resulting array.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agosessiond: fix: strncpy called with source length
Jérémie Galarneau [Sun, 15 Sep 2019 18:27:40 +0000 (14:27 -0400)] 
sessiond: fix: strncpy called with source length

strncpy is called with the source's length in two cases in the
session save code. Use the destination and remaining destination
length as intended by the API.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agosessiond: fix: possible unaligned access in packed structure
Jérémie Galarneau [Sat, 14 Sep 2019 20:02:33 +0000 (16:02 -0400)] 
sessiond: fix: possible unaligned access in packed structure

'&rsock->sock.fd' is passed to consumer_send_fds and may result in an
unaligned pointer value. Use the ALIGNED_CONST_PTR macro to create
an aligned copy of the fd that is being passed.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoinet: fix: possible unaligned access in packed structure (inet/inet6)
Jérémie Galarneau [Thu, 12 Sep 2019 15:51:52 +0000 (11:51 -0400)] 
inet: fix: possible unaligned access in packed structure (inet/inet6)

Fix the warnings that unaligned pointers can be passed as parameters
emitted when building inet.c and inet6.c.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoconsumer: fix: unaligned accesses to index fields
Jérémie Galarneau [Fri, 13 Sep 2019 20:48:18 +0000 (16:48 -0400)] 
consumer: fix: unaligned accesses to index fields

The ctf_index structure, being part of the ABI, is explicitly packed
using the LTTNG_PACKED macro. However, populating it by using pointers
to its members is not acceptable as it may cause the ust and kernel
tracer APIs to populate write their return values using unaligned
pointers.

Use automatic storage variables to fetch the various index fields and
populate the index at-once using a compound literal.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agolttng: fix: potential 0-length allocation in pid list parsing
Jérémie Galarneau [Thu, 12 Sep 2019 14:17:41 +0000 (10:17 -0400)] 
lttng: fix: potential 0-length allocation in pid list parsing

Check that count is > 0 before allocating pid list. This would
only happen after a prior error, but check it anyway.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoTests: fix: uninitialized session_id used on list_sessions failure
Jérémie Galarneau [Thu, 12 Sep 2019 14:12:41 +0000 (10:12 -0400)] 
Tests: fix: uninitialized session_id used on list_sessions failure

Stop live test when list_sessions() fails since the session_id used
further on would be uninitialized.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoTests: fix: uninitialized values passed to close() on error
Jérémie Galarneau [Thu, 12 Sep 2019 14:08:44 +0000 (10:08 -0400)] 
Tests: fix: uninitialized values passed to close() on error

The fds array is not initialized resulting in uninitialized file
descriptors being passed to close() when an error is encountered in
the epoll-setting loop.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agolttng-ctl: fix: lttng_data_pending confuses communication status
Jérémie Galarneau [Wed, 11 Sep 2019 16:18:15 +0000 (12:18 -0400)] 
lttng-ctl: fix: lttng_data_pending confuses communication status

lttng_ctl_ask_sessiond can return a positive value even though it
failed to receive the variable length payload of a session message
reply. In this case, lttng_ctl_ask_sessiond ends up calling into
lttng_ctl_ask_sessiond_fds_varlen() which will return the (negated)
error code returned by the session daemon if it was not LTTNG_OK.

The peer could return anything here, which lttng_data_pending will end
up interpreting as the length of the variable data that was received.

In this case, if the sessiond returns '-1', '1' will be returned to
lttng_data_pending, which it will interpret as being the length of the
'data_pending' byte flag. It will then dereference 'pending', which is
NULL, and (most likely) crash.

Check for NULL on top of checking for the return code. This
communication layer needs love as much as it needs a bulldozer.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix typo in regenerate statedump test util
Geneviève Bastien [Fri, 13 Apr 2018 19:51:28 +0000 (15:51 -0400)] 
Fix typo in regenerate statedump test util

Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: metadata stream is not marked as quiescent after packet commit
Jérémie Galarneau [Mon, 10 Jun 2019 17:31:31 +0000 (13:31 -0400)] 
Fix: metadata stream is not marked as quiescent after packet commit

When a metadata stream's wait fd is hung-up or enters an error state,
it is checked for quiescence in lttng_ustconsumer_on_stream_hangup().

If the stream is not quiescent, the current packet is closed through
the flush_buffer operation.

Currently, all commits to metadata streams are done on a packet
basis. The various code paths using the commit_one_metadata_packet
helper all perform a flush directly after the commit. Performing this
flush leaves the stream in a "quiescent" state, but does not mark it
as such.

This results in an extraneous flush being performed in the err/hup
handler, which leaves an empty packet to be consumed.  This packet is
then consumed during the execution of the err/hup handler.

This bug results in an empty packet being appended to metadata
streams. This packet is typically ignored by readers, but the fact
that it is written at the time of the destruction of a session
violates the immutability guarantee of the session stop
command. Moreover, following the introduction of trace chunks, this
results in the stream attempting to serialize the empty buffer to its
output file _after_ its trace chunk has been closed, causing an
assertion to hit.

Hence, this fix performs the buffer flush and sets the stream as
quiescent directly in commit_one_metadata_packet().

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: sessiond: fs.protected_regular sysctl breaks app registration
Jérémie Galarneau [Tue, 24 Sep 2019 05:10:58 +0000 (01:10 -0400)] 
Fix: sessiond: fs.protected_regular sysctl breaks app registration

I observed that userspace tracing no longer worked when an
instrumented application (linked against liblttng-ust) was launched
before the session daemon.

While investigating this, I noticed that the shm_open() of
'/lttng-ust-wait-8' failed with EACCES. As the permissions on the
'/dev/shm' directory and the file itself should have allowed the
session daemon to open the shm, this pointed to a change in kernel
behaviour.

Moreover, it appeared that this could only be reproduced on my
system (running Arch Linux) and not on other systems.

It turns out that Linux 4.19 introduces a new protected_regular sysctl
to allow the mitigation of a class of TOCTOU security issues related
to the creation of files and FIFOs in sticky directories.

When this sysctl is not set to '0', it specifically blocks the way the
session daemon attempts to open the app notification shm that an
application has already created.

To quote a comment added in linux's fs/namei.c as part of 30aba6656f:

```
Block an O_CREAT open of a FIFO (or a regular file) when:
  - sysctl_protected_fifos (or sysctl_protected_regular) is enabled
  - the file already exists
  - we are in a sticky directory
  - we don't own the file
  - the owner of the directory doesn't own the file
  - the directory is world writable
```

While the concerns that led to the inclusion of this patch are valid,
the risks that are being mitigated do not apply to the session
daemon's and instrumented application's use of this shm. This shm is
only used to wake-up applications and get them to attempt to connect
to the session daemon's application socket. The application socket is
the part that is security sensitive. At worst, an attacker controlling
this shm could wake up the UST thread in applications which would then
attempt to connect to the session daemon.

Unfortunately (for us, at least), systemd v241+ sets the
protected_regular sysctl to 1 by default (see systemd commit
27325875), causing the open of the shm by the session daemon to fail.

Introduce a fall-back to attempt a shm_open without the O_CREAT flag
when opening it with 'O_RDWR | O_CREAT' fails. The comments detail the
reason why those attempts are made in that specific order.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: lttng-crash: detect truncated files
Mathieu Desnoyers [Mon, 23 Sep 2019 18:31:33 +0000 (14:31 -0400)] 
Fix: lttng-crash: detect truncated files

Detect truncated files which size is smaller than the ring buffer
header.

This can be caused by a situation where sessiond is killed with SIGKILL
while doing a metadata regenerate command.

Without this fix, lttng-crash is killed with a "Bus error" when
encountering a truncated file.

Fixes: #1166
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: use newly created event filter for condition check
Jonathan Rajotte [Tue, 24 Sep 2019 15:24:17 +0000 (11:24 -0400)] 
Fix: use newly created event filter for condition check

The following commit introduced a regression while
fixing the filter and filter_expression ownership.

commit b0a23296344e57bd2e48e62ec2d7e0d8a38661bb
Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Date:   Sat Jan 12 14:53:56 2019 -0500

    Fix: leak of filter bytecode and expression on agent event re-enable

    The agent subsystem does not properly assume the clean-up of an
    event's filter bytecode and expression when a previously disabled
    event is re-enabled.

    This change ensures that the ownership of both the filter bytecode
    and expression is assumed by the agent subsystem and discarded
    when a matching event is found.

    Steps to reproduce the leak:
    $ lttng create
    $ lttng enable-event --python allo --filter 'a[42] == 241'
    $ lttng disable-event --python allo
    $ lttng enable-event --python allo --filter 'a[42] == 241'

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Setting the "filter" object to NULL prevents the call to
add_filter_app_ctx when needed.

We use the filter from the newly created event to
perform the check and the call to add_filter_app_ctx.

Fixes coverity #1399733

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: check validity of a stream before invoking ust flush command
Jonathan Rajotte [Wed, 28 Aug 2019 20:36:03 +0000 (16:36 -0400)] 
Fix: check validity of a stream before invoking ust flush command

At the time ustctl_flush_buffer is called the ustream object might have
already been freed on lttng-ust side.

This can happen following a lttng_consumer_cleanup_relayd and concurrent
consumer flush command (lttng stop).

The chain of events goes as follows.

An error on communication with lttng-relayd occurs.
lttng_consumer_cleanup_relayd flags the streams for deletion
(CONSUMER_ENDPOINT_INACTIVE). validate_endpoint_status_data_stream calls
consumer_del_stream.

At the same time the hash table of streams is iterated over in the
flush_channel function following a stop command. The loop is iterating on
a given stream. The current thread is unscheduled before taking the stream
lock.

In the initial thread, the same stream is the current iteration of
cds_lfht_for_each_entry in validate_endpoint_status_data_stream.

consumer_del_stream is called on it. The stream lock is acquired, and
destroy_close_stream is called. lttng_ustconsumer_del_stream is eventually
called and at this point the ustream is freed.

Going back to the iteration in flush_channel. The current stream is still
valid from the point of view of the iteration, ustctl_flush_buffer is then
called on a freed ustream object.

This can lead to unknown behaviour since there is no validation on the
lttng-ust side. The underlying memory of the ustream object is garbage at
this point.

To prevent such scenario, we check for the presence of the node in the
hash table via cds_lfht_is_node_deleted while holding the stream lock.
This is valid because the stream destruction removes the node from
the hash table and frees the ustream object with the stream lock held.

This duplicate similar "validation" check of the stream object. [1][2]

[1] src/common/consumer/consumer.c:consumer_close_channel_streams
[2] src/common/ust-consumer/ust-consumer.c:close_metadata

This issue can be reproduced by the following scenario:

    Modify flush_channel to sleep (i.e 10s) before acquiring the lock on
    a stream.

    Modify lttng-ust ustctl_destroy_stream to set the
    ring_buffer_clock_read callback to NULL.
      Note: An assert on !cds_lfht_is_node_deleted in flush channel
      after acquiring the lock can provide the same information. We are
      modifying the callback to simulate the original backtrace from our
      customer.

    lttng-relayd
    lttng-sessiond
    lttng create --live
    lttng enable-event -u -a
    lttng start
    Start some applications to generate data.
    lttng stop
      The stop command force a flush of the channel/streams.
    pkill -9 lttng-relayd
    Expect assert or segfault

The original customer backtrace:

  0  lib_ring_buffer_try_switch_slow (handle=<optimized out>, tsc=<synthetic pointer>, offsets=0x3fffa9b76c80, chan=0x3fff98006e90, buf=<optimized out>,
     mode=<optimized out>) at /usr/src/debug/lttng-ust/2.9.1/git/libringbuffer/ring_buffer_frontend.c:1834
  1  lib_ring_buffer_switch_slow (buf=0x3fff98016b40, mode=<optimized out>, handle=0x3fff98017670)
     at /usr/src/debug/lttng-ust/2.9.1/git/libringbuffer/ring_buffer_frontend.c:1952
  2  0x00003fffac680940 in ustctl_flush_buffer (stream=<optimized out>, producer_active=<optimized out>)
     at /usr/src/debug/lttng-ust/2.9.1/git/liblttng-ust-ctl/ustctl.c:1568
  3  0x0000000010031bc8 in flush_channel (chan_key=<optimized out>) at ust-consumer.c:772
  4  lttng_ustconsumer_recv_cmd (ctx=<optimized out>, sock=<optimized out>, consumer_sockpoll=<optimized out>) at ust-consumer.c:1651
  5  0x000000001000de50 in lttng_consumer_recv_cmd (ctx=<optimized out>, sock=<optimized out>, consumer_sockpoll=<optimized out>) at consumer.c:2011
  6  0x0000000010014208 in consumer_thread_sessiond_poll (data=0x10079430) at consumer.c:3192
  7  0x00003fffac608b30 in start_thread (arg=0x3fffa9b7bdb0) at pthread_create.c:462
  8  0x00003fffac530d0c in .__clone () at ../sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S:96

Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: initialize syscall table when kernel tracer is lazily initialized
Mathieu Desnoyers [Thu, 23 May 2019 16:56:57 +0000 (12:56 -0400)] 
Fix: initialize syscall table when kernel tracer is lazily initialized

How to reproduce:

start lttng-sessiond while lttng-modules are not installed, then install
lttng-modules. Then issue "lttng list --syscall -k". It will show an
empty syscall list because the system call list has not been
initialized.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoUpdate version to v2.9.12 v2.9.12
Jérémie Galarneau [Fri, 24 May 2019 19:25:40 +0000 (15:25 -0400)] 
Update version to v2.9.12

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoUpdate base test for binding
Jonathan Rajotte [Thu, 23 May 2019 18:11:35 +0000 (14:11 -0400)] 
Update base test for binding

This test is not run for now as it is not part of the test suite.

Use a temporary directory to store trace.
Split in 2 test suite, one for ust and the other for kernel.
Partially fix formatting.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: python binding: expose domain buffer type
Jonathan Rajotte [Thu, 23 May 2019 18:02:26 +0000 (14:02 -0400)] 
Fix: python binding: expose domain buffer type

On enable_channel the domain buffer type is used to create a temporary
channel. This currently fail for kernel channel since the buffer type is
not exposed at the binding level and default to LTTNG_BUFFER_PER_PID.
Channel for the kernel domain can only be created in LTTNG_BUFFER_GLOBAL
mode.

Exposing the buffer type also allow userpsace channel to use the per uid
buffering scheme.

The current bindings are in a rough state. This is to at least get them
to work with kernel domain.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: logging: log_add_time() save/restore errno
Mathieu Desnoyers [Tue, 2 Apr 2019 17:41:17 +0000 (13:41 -0400)] 
Fix: logging: log_add_time() save/restore errno

The debugging logging macros (e.g. DBG()) are used as printf in the
lttng-tools source files. The printf() implementation does not alter the
errno value, so the fact that log_add_time() (through clock_gettime())
can alter errno is unexpected. For instance, adding a logging statement
for debugging purposes within a function for which errno is expected to
stay unchanged on return will change the behavior between execution with
-vvv and non-verbose.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix relayd: initialize beacon to -1ULL
Mathieu Desnoyers [Wed, 24 Apr 2019 22:56:05 +0000 (18:56 -0400)] 
Fix relayd: initialize beacon to -1ULL

The relayd stream beacon_ts_end field is expected to have the value
-1ULL when unset (no beacon has been received since last index).

However, the initial state is wrong. It is left at the value 0, which
indicates that a live beacon has indeed been received (which is untrue),
which in turn causes a live beacon with ctf_stream_id of -1ULL to be
sent to babeltrace, which does not expect it, and fails.

This issue can be triggered with the following scenario:

1) create live session
2) setup UST per-uid buffers tracing
3) start tracing, without any active traced application
4) hook with babeltrace live client to view the trace
5) run a traced application

Step 5) will cause the babeltrace live client to receive a stream_id of
-1ULL, and error out.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix: relayd: handling of lttng_read errors >= 0
Mathieu Desnoyers [Wed, 3 Apr 2019 20:26:45 +0000 (16:26 -0400)] 
Fix: relayd: handling of lttng_read errors >= 0

errno is only set when lttng_read returns a negative value. Else, we
need to print a ERR() statement rather than use PERROR().

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix tests: NULL pointer dereference in ust channel unit tests
Jérémie Galarneau [Wed, 10 Apr 2019 20:37:42 +0000 (16:37 -0400)] 
Fix tests: NULL pointer dereference in ust channel unit tests

The test_create_ust_channel() test case erroneously checks for
a NULL session instead of a channel. This can result in a
NULL pointer dereference on failure to create a ust channel.

The scope of usess is reduced to prevent similar mistakes in the
future. Moving 'dom' has made it obvious that this variable is
unused. Hence, it is removed.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoFix tests: NULL pointer dereference in ltt_ust_context unit tests
Jérémie Galarneau [Wed, 10 Apr 2019 20:25:20 +0000 (16:25 -0400)] 
Fix tests: NULL pointer dereference in ltt_ust_context unit tests

The check for the expected context's type must be skipped when
trace_ust_create_context() fails. Otherwise, a NULL pointer
dereference will occur.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 years agoLog the wait-shm's path on shm_open failure
Jérémie Galarneau [Wed, 10 Apr 2019 19:28:15 +0000 (15:28 -0400)] 
Log the wait-shm's path on shm_open failure

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: skip test when ust doesn't have perf support
Michael Jeanson [Wed, 20 Mar 2019 21:49:00 +0000 (17:49 -0400)] 
Fix: skip test when ust doesn't have perf support

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: Properly sanitize input parameter
Yannick Lamarre [Tue, 26 Mar 2019 19:53:06 +0000 (15:53 -0400)] 
Fix: Properly sanitize input parameter

The lttng client uses the sizeof the containing buffer, defined as
LTTNG_SYMBOL_NAME_LEN, for input string sanitation instead of libc defined
macro NAME_MAX. lttng-enable_channel improperly verified user input
and wrongly discarded valid input in case NAME_MAX was less than the
sizeof the containing buffer for the channel's name.
This patch also fixes potential buffer overflow caused by an improperly
bounded strcpy in the case where NAME_MAX would have been greater than
LTTNG_SYMBOL_NAME_LEN.

Signed-off-by: Yannick Lamarre <ylamarre@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agotap-driver.sh: flush stdout after each test result
Michael Jeanson [Wed, 13 Mar 2019 21:50:55 +0000 (17:50 -0400)] 
tap-driver.sh: flush stdout after each test result

This is useful in a CI system where stdout is fully buffered and you
look at the console output to see which test is hanging.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix tests: snapshot size validation failure runs too many test cases
Jérémie Galarneau [Thu, 28 Mar 2019 15:18:38 +0000 (11:18 -0400)] 
Fix tests: snapshot size validation failure runs too many test cases

The snapshot max size test is reported as both passing and failing
when the test case fails.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix tests: the tree origin can be a symlink itself
Jonathan Rajotte [Tue, 12 Mar 2019 18:30:31 +0000 (14:30 -0400)] 
Fix tests: the tree origin can be a symlink itself

Problem:

The base tree is defined as "/tmp/.....XXXXXX".
On systems where "/tmp/" is itself a symlink utils_expand_path will
expand the tree origin itself.

For example on a base core-image-minimal Yocto build /tmp is a symlink
to "/var/tmp", which is a symlink to "/var/volatile".

utils_expand_path will return something like this for the symlink test:
"/var/volative/.....XXXXXX/...." which is the valid result.

Solution:

Simply use realpath on the tree_origin and use this path to perform the
test validation.

This work was performed in the effort to support yocto fully and be able
to run the test suite to detect problem as early as possible.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix tests: skip test_getcpu_override on single core systems
Jonathan Rajotte [Tue, 12 Mar 2019 18:30:30 +0000 (14:30 -0400)] 
Fix tests: skip test_getcpu_override on single core systems

There is no value in performing this test on single-core system
since the only valid value for the cpu field is 0.

This test currently fails on single-core systems (i.e yocto runqemu)
on the test_getcpu_override_fail test case.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: consumer snapshot: handle unsigned long overflow
Mathieu Desnoyers [Tue, 19 Feb 2019 22:47:49 +0000 (17:47 -0500)] 
Fix: consumer snapshot: handle unsigned long overflow

Comparing the consumed iterator and the produced position without
using a difference generates an empty snapshot when the iterator is
before unsigned long overflow and the produced position is after
unsigned long overflow.

This applies to both UST and kernel consumers.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: wrong error code returned by kernel_snapshot_record()
Jérémie Galarneau [Wed, 27 Mar 2019 19:42:19 +0000 (15:42 -0400)] 
Fix: wrong error code returned by kernel_snapshot_record()

On snapshot error, kernel_snapshot_record() can return
LTTNG_ERR_KERN_CONSUMER_FAIL which means that the kernel consumer
daemon failed to launch. In this path, the appropriate error to
return is LTTNG_ERR_KERN_META_FAIL.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoDocs: document the format of the lttng_session path member
Jérémie Galarneau [Fri, 22 Mar 2019 21:51:14 +0000 (17:51 -0400)] 
Docs: document the format of the lttng_session path member

Document that the path returned through a session listing operation
is not a path nor standard URL. While a UNIX path will be returned
when a session is configured to trace locally, a liblttng-ctl user
should not expect this field to contain a valid URL when a network
streaming (or live) output destination is configured. The "path"
field will hold a custom-formatted string describing the output.

This is arguably unexepected, but since this is currently the only
way to obtain the destination of an existing session, this format
will not be changed to preserve compatiblity with existing tools
which could rely on this format.

A description of the formating used by the session daemon is
added as part of this patch.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: check illegal combinations of ctrl-url/data-url/ouput/set-url
Jérémie Galarneau [Fri, 22 Mar 2019 21:51:40 +0000 (17:51 -0400)] 
Fix: check illegal combinations of ctrl-url/data-url/ouput/set-url

The lttng CLI must check for illegal combinations of the
--ctrl-url, --data-url, --set-url, and --output options.

The following combinations are mutually exclusive:
  1) --set-url
  2) --ctrl-url + --data-url
  3) --output

Combining these incompatible options resulted in unhelpful
generic error messages since the error is catched a lot farther
than it should.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTests: take multiple snapshots in streaming mode
Jonathan Rajotte [Fri, 8 Feb 2019 01:25:41 +0000 (20:25 -0500)] 
Tests: take multiple snapshots in streaming mode

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: don't destroy the sockets if the snapshot was successful
Jonathan Rajotte [Fri, 8 Feb 2019 01:25:42 +0000 (20:25 -0500)] 
Fix: don't destroy the sockets if the snapshot was successful

Missing a goto to skip the error condition that was destroying the
relayd sockets even if a snapshot was successful. We want to keep them
open to reuse them for the next snapshots.

This is verbatim from the fix 1371fc1228461eb532118280e67ab3e9de015757

It is also the same fix.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoUpdate version to v2.9.11 v2.9.11
Jérémie Galarneau [Tue, 22 Jan 2019 19:07:06 +0000 (14:07 -0500)] 
Update version to v2.9.11

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: worker structure is leaked in run_as process
Jérémie Galarneau [Thu, 6 Dec 2018 20:49:04 +0000 (15:49 -0500)] 
Fix: worker structure is leaked in run_as process

The run_as structure (handle) is allocated and initialized before
the fork() that spawns the run_as process. Currently, that structure
is only cleaned-up on the parent's end.

This fix performs the clean-up on the worker's side as well.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: leak of filter bytecode and expression on agent event re-enable
Jérémie Galarneau [Sat, 12 Jan 2019 19:53:56 +0000 (14:53 -0500)] 
Fix: leak of filter bytecode and expression on agent event re-enable

The agent subsystem does not properly assume the clean-up of an
event's filter bytecode and expression when a previously disabled
event is re-enabled.

This change ensures that the ownership of both the filter bytecode
and expression is assumed by the agent subsystem and discarded
when a matching event is found.

Steps to reproduce the leak:
$ lttng create
$ lttng enable-event --python allo --filter 'a[42] == 241'
$ lttng disable-event --python allo
$ lttng enable-event --python allo --filter 'a[42] == 241'

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: only free trace_path when it is dynamically allocated
Jérémie Galarneau [Mon, 14 Jan 2019 22:13:32 +0000 (17:13 -0500)] 
Fix: only free trace_path when it is dynamically allocated

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: tests: test_crash should start sessions
Mathieu Desnoyers [Fri, 16 Nov 2018 18:25:00 +0000 (13:25 -0500)] 
Fix: tests: test_crash should start sessions

test_crash expects side-effects of directory creation to happen while
tracing is still stopped. In preparation for changing that behavior,
ensure that tracing is started when those side-effects are expected.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd *.exe to gitignore for Cygwin
Michael Jeanson [Tue, 27 Nov 2018 19:24:27 +0000 (14:24 -0500)] 
Add *.exe to gitignore for Cygwin

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: warning 'fd' may be used uninitialized
Michael Jeanson [Thu, 29 Nov 2018 21:49:51 +0000 (16:49 -0500)] 
Fix: warning 'fd' may be used uninitialized

Initialize fd to invalid '-1' and remove unnecessary file_opened.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: max_t/min_t macros are missing cast on input
Mathieu Desnoyers [Tue, 13 Nov 2018 17:12:21 +0000 (12:12 -0500)] 
Fix: max_t/min_t macros are missing cast on input

The semantic expected from max_t and min_t is to perform the max/min
comparison in the type provided as first parameter.

Cast the input parameters to the proper type before comparing them,
rather than after. There is no more need to cast the result of the
expression now that both inputs are cast to the right type.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: Connect timeout arithmetic in inet/inet6 (v4)
Mathieu Desnoyers [Tue, 13 Nov 2018 17:12:20 +0000 (12:12 -0500)] 
Fix: Connect timeout arithmetic in inet/inet6 (v4)

The nanoseconds part of the timespec struct time_a is not always
bigger than time_b since it wraps around each second.

Use 64-bit arithmetic to compute the difference.

Merge/move duplicated code into utils.c.

This function is really doing two things. Split it into
timespec_to_ms() and timespec_abs_diff().

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: channel_ust_create: remove channel on agent error
Mathieu Desnoyers [Wed, 14 Nov 2018 22:45:38 +0000 (17:45 -0500)] 
Fix: channel_ust_create: remove channel on agent error

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAlways choose large event header for UST channels
Mathieu Desnoyers [Wed, 17 Oct 2018 21:16:12 +0000 (17:16 -0400)] 
Always choose large event header for UST channels

UST can receive the session start command before all probe provider
library constructors have completed running, therefore finding less
events than eventually enabled within the process. Moreover, with
per-uid buffers, many processes end up registering events into shared
buffers. Therefore, the guess based on number of events from the first
process to use the buffer is incorrect.

Considering that we typically have applications with more than 30
events, we will modify the session daemon so it selects the "large"
header type independently of the number of events.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: perform local data pending before checking data pending with relayd
Jonathan Rajotte [Tue, 11 Sep 2018 00:09:15 +0000 (20:09 -0400)] 
Fix: perform local data pending before checking data pending with relayd

Performing the data pending check in two phases, local and network,
reduces the total number network operations needed.

Doing the local check first enable early return in cases where data is
still pending locally.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: double put on error path
Jonathan Rajotte [Tue, 11 Sep 2018 00:09:11 +0000 (20:09 -0400)] 
Fix: double put on error path

Let relay_index_try_flush be responsible for the self-reference put on
error path.

Code flow of relay_index_try_flush is a bit tricky but the only error
flow (via relay_index_file_write) will always mark the index as flushed
and perform the self-reference put.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: holding the stream lock does not equate to having data pending
Jonathan Rajotte [Tue, 11 Sep 2018 00:09:14 +0000 (20:09 -0400)] 
Fix: holding the stream lock does not equate to having data pending

The live timer can hold the stream lock while sending empty beacon. An
empty beacon does not mean that data is still pending for the stream.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: skip uid registry when metadata key is 0
Jonathan Rajotte [Tue, 11 Sep 2018 00:09:13 +0000 (20:09 -0400)] 
Fix: skip uid registry when metadata key is 0

A value of zero for the metadata key indicate that metadata was never
created/pushed to the consumer.

This can occur in scenario were a tracker is present since metadata
might never be created/pushed.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoDocs: document the meaning of a ust app channel key set to 0
Jérémie Galarneau [Mon, 17 Sep 2018 22:15:11 +0000 (18:15 -0400)] 
Docs: document the meaning of a ust app channel key set to 0

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: acquire stream lock during kernel metadata snapshot
Jérémie Galarneau [Tue, 11 Sep 2018 00:09:12 +0000 (20:09 -0400)] 
Fix: acquire stream lock during kernel metadata snapshot

The stream lock is not taken when interacting with the kernel
metadata stream that is created at the time a snapshot is taken.

This was noticed while reviewing the code for an unrelated reason,
so there is no known problem caused by this. Nevertheless, this
is incorrect as the stream is globally visible in the consumer.

Moreover, the stream was not cleaned-up which can cause a leak
whenever a metadata snapshot fails.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
5 years agoFix: skip closed session on viewer listing
Jonathan Rajotte [Fri, 7 Sep 2018 19:18:38 +0000 (15:18 -0400)] 
Fix: skip closed session on viewer listing

There is  no value in listing  a closed session. A  viewer cannot hook
itself to a closed session in live mode and the session is about to be
removed from the sessions hash table.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: use LTTNG_VIEWER_ATTACH_UNK to report a closed session
Jonathan Rajotte [Fri, 7 Sep 2018 19:18:37 +0000 (15:18 -0400)] 
Fix: use LTTNG_VIEWER_ATTACH_UNK to report a closed session

LTTNG_VIEWER_NEW_STREAMS_HUP is not a valid error number for the
LTTNG_VIEWER_ATTACH_SESSION command. This result in erroneous error
reporting on the client side.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: expand load path to an absolute path before daemonizing
Jérémie Galarneau [Thu, 13 Sep 2018 22:43:28 +0000 (18:43 -0400)] 
Fix: expand load path to an absolute path before daemonizing

Relative paths must be expanded before the sessiond is daemonized
as the CWD is then changed to '/'.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: perform relayd socket pair cleanup on control socket error
Jonathan Rajotte [Wed, 6 Jun 2018 01:00:28 +0000 (21:00 -0400)] 
Fix: perform relayd socket pair cleanup on control socket error

A reference to the local context for the socket pair is used to "force" an
evaluation of the data and metadata streams since we changed the endpoint
status. This imitates what is currently done for the data socket.

This prevents hitting network timeouts multiple times in a row when an
error occurs. For now, there is no mechanism for retry hence
"terminating" all communication make sense and prevent unwanted delays
on operation.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: relayd control socket mutex is not destroyed
Jérémie Galarneau [Thu, 13 Sep 2018 21:04:45 +0000 (17:04 -0400)] 
Fix: relayd control socket mutex is not destroyed

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTests: do not bound test app iterations when in background mode
Jonathan Rajotte [Tue, 3 Jul 2018 18:49:23 +0000 (14:49 -0400)] 
Tests: do not bound test app iterations when in background mode

On systems with a high number of CPUs and slow disk, taking snapshots
can take a long time. When running a long regression test, the tests
sometimes outlive the test application.

The test application then exits since the required number of
iterations was completed
(NR_ITER=2000000).

Set the iterations parameter to -1 to ensure the application keeps
producing events for the duration of the test.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTests: add missing rotation and autoload tests to check target
Jérémie Galarneau [Tue, 11 Sep 2018 19:11:39 +0000 (15:11 -0400)] 
Tests: add missing rotation and autoload tests to check target

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTests: remove temporary folder
Jonathan Rajotte [Tue, 5 Jul 2016 19:23:42 +0000 (15:23 -0400)] 
Tests: remove temporary folder

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTests: remove mi result files when done
Jonathan Rajotte [Tue, 5 Jul 2016 18:38:46 +0000 (14:38 -0400)] 
Tests: remove mi result files when done

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTests: Remove unused set +x
Jonathan Rajotte [Wed, 14 Oct 2015 13:57:42 +0000 (09:57 -0400)] 
Tests: Remove unused set +x

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTests: Kill relayd after sessiond to ensure a clean tear down
Jonathan Rajotte [Tue, 6 Oct 2015 21:10:56 +0000 (17:10 -0400)] 
Tests: Kill relayd after sessiond to ensure a clean tear down

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTests: Remove unused variable
Jonathan Rajotte [Tue, 6 Oct 2015 16:07:41 +0000 (12:07 -0400)] 
Tests: Remove unused variable

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTests: Use stop relayd from utils.sh
Jonathan Rajotte [Wed, 30 Sep 2015 22:41:30 +0000 (18:41 -0400)] 
Tests: Use stop relayd from utils.sh

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTests: remove declaration already present in utils.sh
Jonathan Rajotte [Wed, 30 Sep 2015 22:38:13 +0000 (18:38 -0400)] 
Tests: remove declaration already present in utils.sh

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: incorrect error message on regenerate missing argument
Jérémie Galarneau [Thu, 30 Aug 2018 18:49:29 +0000 (14:49 -0400)] 
Fix: incorrect error message on regenerate missing argument

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: incorrect error message on metadata missing argument
Jérémie Galarneau [Thu, 30 Aug 2018 18:45:23 +0000 (14:45 -0400)] 
Fix: incorrect error message on metadata missing argument

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: snapshot command mishandles missing arguments
Jérémie Galarneau [Thu, 30 Aug 2018 18:32:10 +0000 (14:32 -0400)] 
Fix: snapshot command mishandles missing arguments

The snapshot command does not print explicit errors when
arguments are missing. This commit introduces more error
reporting and ensures that lttng_error_code and cmd_error_code
values are not freely mixed.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: passing null to closedir() on error
Jérémie Galarneau [Wed, 29 Aug 2018 21:28:36 +0000 (17:28 -0400)] 
Fix: passing null to closedir() on error

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: unchecked access to pids array
Jérémie Galarneau [Wed, 29 Aug 2018 21:25:04 +0000 (17:25 -0400)] 
Fix: unchecked access to pids array

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: returned pids may be uninitialized
Jérémie Galarneau [Wed, 29 Aug 2018 20:56:52 +0000 (16:56 -0400)] 
Fix: returned pids may be uninitialized

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: lttng-save command producing wrong XML fields
Francis Deslauriers [Thu, 5 Jul 2018 22:14:54 +0000 (18:14 -0400)] 
Fix: lttng-save command producing wrong XML fields

Saving a session configuration with a probe or a function event would
generate a XML file considered invalid by the lttng-load command.

This is due to the fact that for a probe event lttng-save would the
following xml event type field:
  <type>KPROBE</type>
but lttng-load command would be expecting the following field:
  <type>PROBE</type>.

As a fix, the lttng-save command now rightfully outputs the PROBE field.
Given that this usecase never worked, changing the field is not a
breaking change.

Also, the save command was wrongfully using FUNCTION xml event type for
the LTTNG_KERNEL_FUNCTION event type when it is in fact the
FUNCTION_ENTRY xml event type.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: possible NULL dereference in uri_parse_str_urls()
Jérémie Galarneau [Mon, 20 Aug 2018 20:45:09 +0000 (16:45 -0400)] 
Fix: possible NULL dereference in uri_parse_str_urls()

The data_url parsing of uri_parse_str_urls assumes that a ctrl
URL was provided to check that both URLs point to the same
destination. A check for 'ctrl_uris != NULL' is added, but this
function needs to be refactored at some point at it is not clear
what its role is (i.e. it's probably doing too much).

Reported-by: Coverity Scan (1378214 Explicit null dereferenced)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoSet consumer's verbosity to the max level on --verbose-consumer
Jérémie Galarneau [Fri, 20 Jul 2018 22:41:49 +0000 (18:41 -0400)] 
Set consumer's verbosity to the max level on --verbose-consumer

The consumer's verbosity is set to '1' when --verbose-consumer
is used when launching the session daemon. This means that all
DBG2/3() statements are ignored.

This commit always sets the consumer's verbosity to the maximal
level.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTests: added test_autoload to noinst_SCRIPTS
Anders Wallin [Thu, 26 Jul 2018 07:46:28 +0000 (09:46 +0200)] 
Tests: added test_autoload to noinst_SCRIPTS

Signed-off-by: Anders Wallin <wallinux@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoUpdate version to v2.9.10 v2.9.10
Jérémie Galarneau [Tue, 24 Jul 2018 00:19:29 +0000 (20:19 -0400)] 
Update version to v2.9.10

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: missing context enum values in session xml schema
Francis Deslauriers [Tue, 5 Jun 2018 14:57:48 +0000 (10:57 -0400)] 
Fix: missing context enum values in session xml schema

    Handling of the following enum are added:
        LTTNG_EVENT_CONTEXT_INTERRUPTIBLE
        LTTNG_EVENT_CONTEXT_PREEMPTIBLE
        LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE
        LTTNG_EVENT_CONTEXT_MIGRATABLE

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTests: add session auto-loading test cases
Anders Wallin [Thu, 17 May 2018 20:50:41 +0000 (22:50 +0200)] 
Tests: add session auto-loading test cases

lttng-sessiond can auto load sessions at startup;
- with "--load" option to lttng-sessiond, load one file
  or all sessions files in that directory
- from session files in $LTTNG_HOME/.lttng/sessions/auto/
- from session files in $sysconfdir/lttng/sessions/auto

This test case validates the two first scenarios.

Signed-off-by: Anders Wallin <wallinux@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoBash completion: ignore namespace for xmllint parsing
Jonathan Rajotte [Mon, 28 May 2018 21:31:48 +0000 (17:31 -0400)] 
Bash completion: ignore namespace for xmllint parsing

xmllint cli does not "easily" support namespace.

One can use the local_name() xpath function and other "trick".
The simplest trick for bash completion is to ignore the namespace
altogether.

Replacing "xmlns" by "ignore" does the job.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTypo in ust consumer log message (channek -> channel)
Jérémie Galarneau [Mon, 4 Jun 2018 21:28:56 +0000 (17:28 -0400)] 
Typo in ust consumer log message (channek -> channel)

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: use signed variable for refcounting of consumer_relayd_sock_pair
Jonathan Rajotte [Wed, 14 Mar 2018 18:54:21 +0000 (14:54 -0400)] 
Fix: use signed variable for refcounting of consumer_relayd_sock_pair

Otherwise refcount check after decreasing have no meaning as in
consumer_stream_relayd_close function.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: warning due to hash_key_str() being not const-correct
Jérémie Galarneau [Wed, 30 May 2018 22:09:19 +0000 (18:09 -0400)] 
Fix: warning due to hash_key_str() being not const-correct

Hash table utils do not enforce const-correct in lttng-tools prior
to 2.11. This results in a warning when pasing a const argument
to those utilities.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: calling ht_{hash, match}_enum with wrong argument
Francis Deslauriers [Fri, 9 Feb 2018 21:56:49 +0000 (16:56 -0500)] 
Fix: calling ht_{hash, match}_enum with wrong argument

ht_hash_enum and ht_match_enum are currently called with the address of the
pointer to a ust_registry_enum rather than the expected pointer to a
ust_registry_enum. This means that those function calls would end up
using garbage for hashing and comparing.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: probes should be compared strictly by events metadata
Francis Deslauriers [Fri, 9 Feb 2018 21:56:48 +0000 (16:56 -0500)] 
Fix: probes should be compared strictly by events metadata

Currently, events are compared using names and signatures. Events
with different payloads but identical name and signatures could
lead to corrupted trace because the Session Daemon would consider them
identical and give them the same event ID.

Events should be compared using the name, loglevel, fields and
model_emf_uri to ensure that their respective metadata is the same.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: test_ust-dl is generated at configure-time
Francis Deslauriers [Tue, 6 Feb 2018 17:04:27 +0000 (12:04 -0500)] 
Fix: test_ust-dl is generated at configure-time

This file should not be in EXTRA_DIST as it's generated by autoconf and
will thus be available directly in the out-of-tree build directory.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: perform the initialization memory barrier out of loop body
Jérémie Galarneau [Fri, 18 May 2018 19:08:14 +0000 (15:08 -0400)] 
Fix: perform the initialization memory barrier out of loop body

The memory barrier used by the client thread should be performed
after the lttng_sessiond_ready counter has been seen to have
reached zero.

This ensures that loads are not speculatively performed before
this point as the thread will interact with data structures
initialized by the support threads for which it was waiting for
the initialization to complete.

See the comment as to why this read barrier is promoted to a
full barrier.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoPort: fix format warnings on Cygwin
Michael Jeanson [Tue, 15 May 2018 20:19:49 +0000 (16:19 -0400)] 
Port: fix format warnings on Cygwin

On Cygwin, be64toh() returns a "long long unsigned int" while the
format specifier PRIu64 expects a "long unsigned int". Both types
are 64bits integers, just cast the result to uint64_t to silence
the warnings.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: don't wait for the load thread before serving client commands
Jérémie Galarneau [Wed, 16 May 2018 21:08:36 +0000 (17:08 -0400)] 
Fix: don't wait for the load thread before serving client commands

Since the session loading thread uses the same communication than
the external clients, it should not be included in the set of
threads that must be launched before the sessiond starts to serve
client commands.

Since the "load session" thread is guaranteed to be the last
essential thread to be initialized, it can explicitly signal
the parents that the sessiond is ready once it is done auto-loading
session configurations.

This commit also adds a lengthy comment explaining the initialization
of the session daemon.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: sessiond fails to launch on --without-ust configuration
Jérémie Galarneau [Wed, 9 May 2018 01:26:15 +0000 (21:26 -0400)] 
Fix: sessiond fails to launch on --without-ust configuration

The sessiond will never signal that it is ready (in daemonize or
background modes) if it was built without lttng-ust. The fix in
7eac7803 made the main thread wait for the agent thread to be
ready before signalling that the session daemon is ready.

When agent tracing is not possible due to the absence of lttng-ust,
a stub function is used to launch the agent thread. This stub
must call sessiond_notify_ready() in order to unblock the main
thread.

Note that it would be _incorrect_ to not wait for the agent
thread to be launched as users expect all tracing features to
be available as soon as 'lttng-sessiond --daemonize/--background'
returns.

Not waiting for the thread to be ready caused very rare failures
of the agent tracing tests on the CI, especially on ARM and
PowerPC targets.

Reported-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: agent thread poll set creation failure results in deadlock
Jérémie Galarneau [Wed, 9 May 2018 01:23:14 +0000 (21:23 -0400)] 
Fix: agent thread poll set creation failure results in deadlock

Failing to initialize the agent thread's pollset will cause
the thread to exit before calling sessiond_notify_ready().

This will cause the main thread to wait forever for all threads
to be launched when such an error occurs.

The agent thread is not needed for the sessiond to work (except
to enable the tracing of Java and Python applications). Such
a failure should leave the sessiond in a useable state.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: test uses sizeof() on the wrong operand of strncpy
Jérémie Galarneau [Wed, 9 May 2018 01:22:36 +0000 (21:22 -0400)] 
Fix: test uses sizeof() on the wrong operand of strncpy

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
This page took 0.045513 seconds and 4 git commands to generate.