Fix: bytecode interpreter context_get_index() leaves byte order uninitialized
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 30 Mar 2022 18:24:54 +0000 (14:24 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 3 Jun 2022 15:42:21 +0000 (11:42 -0400)
Observed Issue
==============

When using the event notification capture feature to capture a context
field, e.g. '$ctx.cpu_id', the captured value is often observed in
reverse byte order.

Cause
=====

Within the bytecode interpreter, context_get_index() leaves the "rev_bo"
field uninitialized in the top of stack.

This only affects the event notification capture bytecode because the
BYTECODE_OP_GET_SYMBOL bytecode instruction (as of lttng-tools 2.13)
is only generated for capture bytecode in lttng-tools. Therefore, only
capture bytecode targeting contexts are affected by this issue. The
reason why lttng-tools uses the "legacy" bytecode instruction to get
context (BYTECODE_OP_GET_CONTEXT_REF) for the filter bytecode is to
preserve backward compatibility of filtering when interacting with
applications linked against LTTng-UST 2.12.

Solution
========

Initialize the rev_bo field based on the context field type
reserve_byte_order field.

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

None.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1483642b0b8f6bc28d5b68be170a04fb419fd9b3

src/lttng-bytecode-interpreter.c

index a2a932c65f2d488d1f119741801cdbf0ef3c2456..4b100ab861761abb68993a93ad09f0a50004588d 100644 (file)
@@ -294,6 +294,7 @@ static int context_get_index(struct lttng_kernel_probe_ctx *lttng_probe_ctx,
                        ptr->u.u64 = v.u.s64;   /* Cast. */
                        ptr->ptr = &ptr->u.u64;
                }
+               ptr->rev_bo = lttng_kernel_get_type_integer(field->type)->reverse_byte_order;
                break;
        case lttng_kernel_type_enum:
        {
@@ -310,6 +311,7 @@ static int context_get_index(struct lttng_kernel_probe_ctx *lttng_probe_ctx,
                        ptr->u.u64 = v.u.s64;   /* Cast. */
                        ptr->ptr = &ptr->u.u64;
                }
+               ptr->rev_bo = integer_type->reverse_byte_order;
                break;
        }
        case lttng_kernel_type_array:
This page took 0.028493 seconds and 4 git commands to generate.