From c41d8071a57f5443a76dc5c9334048f49f43b82b Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 26 Apr 2016 18:41:04 -0400 Subject: [PATCH] Fix: endianness of integers received by filter We need to byteswap integers passed to the filter when they are tagged as being in an endianness which differs from the architecture endianness, so the integer comparisons make sense in terms of value rather than raw bytes for those fields. Signed-off-by: Mathieu Desnoyers --- probes/lttng-events.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/probes/lttng-events.h b/probes/lttng-events.h index adef299b..86c13bbe 100644 --- a/probes/lttng-events.h +++ b/probes/lttng-events.h @@ -31,6 +31,8 @@ #include "../wrapper/rcu.h" #include "../lttng-events.h" #include "../lttng-tracer-core.h" +#include +#include /* * Macro declarations used for all stages. @@ -397,18 +399,24 @@ static inline size_t __event_get_size__##_name(size_t *__dynamic_len, \ case 2: \ { \ union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != __BYTE_ORDER) \ + __swab16s(&__tmp.v); \ __ctf_tmp_int64 = (int64_t) __tmp.v; \ break; \ } \ case 4: \ { \ union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != __BYTE_ORDER) \ + __swab32s(&__tmp.v); \ __ctf_tmp_int64 = (int64_t) __tmp.v; \ break; \ } \ case 8: \ { \ union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != __BYTE_ORDER) \ + __swab64s(&__tmp.v); \ __ctf_tmp_int64 = (int64_t) __tmp.v; \ break; \ } \ @@ -428,18 +436,24 @@ static inline size_t __event_get_size__##_name(size_t *__dynamic_len, \ case 2: \ { \ union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != __BYTE_ORDER) \ + __swab16s(&__tmp.v); \ __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ break; \ } \ case 4: \ { \ union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != __BYTE_ORDER) \ + __swab32s(&__tmp.v); \ __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ break; \ } \ case 8: \ { \ union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \ + if (_byte_order != __BYTE_ORDER) \ + __swab64s(&__tmp.v); \ __ctf_tmp_uint64 = (uint64_t) __tmp.v; \ break; \ } \ -- 2.34.1