Project

General

Profile

Actions

Bug #1301

closed

lttng-ust erroneously truncates sequences by NULL-terminating them

Added by Jérémie Galarneau about 3 years ago. Updated about 3 years ago.

Status:
Resolved
Priority:
High
Target version:
-
Start date:
03/24/2021
Due date:
% Done:

100%

Estimated time:

Description

The following commit introduces a regression that causes lttng-tools' test suite to fail:

commit 2792781482a58865c7504100d8c1ba6db41193d1
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Date:   Mon Mar 22 16:59:38 2021 -0400

    ABI refactoring: sequence and array of text: copy input as string

    Within the lttng-modules writeback instrumentation, which exposes a
    tracepoint probe API similar to LTTng-UST, we had a long standing issue
    where a fixed-size array of text was used to copy a string input into
    the trace.

    This is fine as long as the input string is actually backed by a
    fixed-size array, but if the input string is variable-size, and may be
    smaller than the array size, this led to out-of-bound memory reads
    beyond the input string NULL terminating character.

    Change the behavior of the array/sequence of text to stop copying the
    input as soon as the array/sequence size limit (-1) or the input's NULL
    terminating character is found, and add zeroed padding for the rest of
    the array/sequence within the ring buffer.

    Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
    Change-Id: Icc3f31c12bdd8018e5e4b7ea146fe842371054d6
❯ ./tests/regression/ust/linking/test_linking
1..32
ok 1 - Running application dynamically linked to providers, no preload
ok 2 - No events logged when running demo application without preloading providers
ok 3 - demo_static, resulting trace found
ok 4 - demo_static, total number of events logged is correct
ok 5 - demo_static, ust_tests_demo:starting event found in trace with a correct integer argument
not ok 6 - demo_static, ust_tests_demo2:loop event found in trace and arguments are correct, iteration 1
not ok 7 - demo_static, ust_tests_demo2:loop event found in trace and arguments are correct, iteration 2
not ok 8 - demo_static, ust_tests_demo2:loop event found in trace and arguments are correct, iteration 3
not ok 9 - demo_static, ust_tests_demo2:loop event found in trace and arguments are correct, iteration 4
not ok 10 - demo_static, ust_tests_demo2:loop event found in trace and arguments are correct, iteration 5
ok 11 - demo_static, ust_tests_demo:done event found in resulting trace with a correct integer argument
ok 12 - demo_static, ust_tests_demo3:done event found in resulting trace with a correct integer argument
ok 13 - demo_builtin, resulting trace found
ok 14 - demo_builtin, total number of events logged is correct
ok 15 - demo_builtin, ust_tests_demo:starting event found in trace with a correct integer argument
not ok 16 - demo_builtin, ust_tests_demo2:loop event found in trace and arguments are correct, iteration 1
not ok 17 - demo_builtin, ust_tests_demo2:loop event found in trace and arguments are correct, iteration 2
not ok 18 - demo_builtin, ust_tests_demo2:loop event found in trace and arguments are correct, iteration 3
not ok 19 - demo_builtin, ust_tests_demo2:loop event found in trace and arguments are correct, iteration 4
not ok 20 - demo_builtin, ust_tests_demo2:loop event found in trace and arguments are correct, iteration 5
ok 21 - demo_builtin, ust_tests_demo:done event found in resulting trace with a correct integer argument
ok 22 - demo_builtin, ust_tests_demo3:done event found in resulting trace with a correct integer argument
ok 23 - demo_preload, resulting trace found
ok 24 - demo_preload, total number of events logged is correct
ok 25 - demo_preload, ust_tests_demo:starting event found in trace with a correct integer argument
not ok 26 - demo_preload, ust_tests_demo2:loop event found in trace and arguments are correct, iteration 1
not ok 27 - demo_preload, ust_tests_demo2:loop event found in trace and arguments are correct, iteration 2
not ok 28 - demo_preload, ust_tests_demo2:loop event found in trace and arguments are correct, iteration 3
not ok 29 - demo_preload, ust_tests_demo2:loop event found in trace and arguments are correct, iteration 4
not ok 30 - demo_preload, ust_tests_demo2:loop event found in trace and arguments are correct, iteration 5
ok 31 - demo_preload, ust_tests_demo:done event found in resulting trace with a correct integer argument
ok 32 - demo_preload, ust_tests_demo3:done event found in resulting trace with a correct integer argument
# Killing (signal SIGTERM) lttng-sessiond and lt-lttng-sessiond pids: 1322178 1322179 

This test runs an application that makes use of a ctf_sequence_text to trace the "test" string.
Before applying this change, readers correctly interpret the field as "test". After, they only see "tes".

The change introduced in the commit appears to assume that text sequences are null-terminated, which they are not (they are effectively P-strings).

All our published usage examples of ctf_sequence_text show that the length provided should not include the null terminator.

Actions #1

Updated by Mathieu Desnoyers about 3 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF