From: Jérémie Galarneau Date: Tue, 26 Mar 2019 15:50:41 +0000 (-0400) Subject: Fix: missing include can cause structures to not be packed X-Git-Tag: v2.11.0-rc2~61 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=f79a92e2660c031e8ed4c209114dbd5e65095925;p=lttng-tools.git Fix: missing include can cause structures to not be packed A number of files declaring "packed" structures (using the LTTNG_PACKED macro) do not include common/macros.h, which defines this macro. This results in structures being used in their "unpacked" form, or under both packed and unpacked forms, depending on the other files included at the point of definition and use of these structures. It is unclear which of the users of these structures were actually affected by the bug. Most of these structures are used for IPC over a UNIX socket. In these cases, it is reasonable to assume that lttng-tools will be rebuilt completely to take this change into account. However, the structures declared in common/sessiond-comm/relayd.h are more worrying as they are part of the relay daemon's network protocol. Fortunately, adding the following directive to common/sessiond-comm/relayd.h confirms that the header is included transitively where those structures are used. > #ifndef LTTNG_PACKED > #error Not defined! > #endif Instances of this issue were found using the following script. for file in $(ag -l LTTNG_PACKED); do ag "#include \" -l ${file} > /dev/null if [ $? -ne 0 ]; then echo "Missing include in" $file fi done Running this script produces the following output (annotated): Missing include in include/lttng/channel-internal.h Missing include in include/lttng/condition/buffer-usage-internal.h Missing include in include/lttng/condition/session-consumed-size-internal.h Missing include in include/lttng/condition/session-rotation-internal.h Missing include in src/common/sessiond-comm/sessiond-comm.h Missing include in src/common/sessiond-comm/relayd.h Missing include in src/common/sessiond-comm/agent.h > LTTNG_PACKED mentioned in comments Missing include in src/common/optional.h > Unneeded. Missing include in src/common/macros.h > lttng-ust-abi.h defines its own version of LTTNG_PACKED > and is included by lttng-ust-ctl.h Missing include in src/bin/lttng-sessiond/lttng-ust-ctl.h Missing include in src/bin/lttng-sessiond/lttng-ust-abi.h Missing include in src/lib/lttng-ctl/filter/filter-bytecode.h > False positives (not source files) Missing include in packed.sh Missing include in ChangeLog Signed-off-by: Jérémie Galarneau --- diff --git a/include/lttng/channel-internal.h b/include/lttng/channel-internal.h index 53171f42c..030b47015 100644 --- a/include/lttng/channel-internal.h +++ b/include/lttng/channel-internal.h @@ -18,6 +18,8 @@ #ifndef LTTNG_CHANNEL_INTERNAL_H #define LTTNG_CHANNEL_INTERNAL_H +#include + struct lttng_channel_extended { uint64_t discarded_events; uint64_t lost_packets; diff --git a/include/lttng/condition/buffer-usage-internal.h b/include/lttng/condition/buffer-usage-internal.h index 4b605d664..6efb0c4c8 100644 --- a/include/lttng/condition/buffer-usage-internal.h +++ b/include/lttng/condition/buffer-usage-internal.h @@ -23,6 +23,7 @@ #include #include #include "common/buffer-view.h" +#include struct lttng_condition_buffer_usage { struct lttng_condition parent; diff --git a/include/lttng/condition/session-consumed-size-internal.h b/include/lttng/condition/session-consumed-size-internal.h index 65ac70668..be9940502 100644 --- a/include/lttng/condition/session-consumed-size-internal.h +++ b/include/lttng/condition/session-consumed-size-internal.h @@ -21,7 +21,8 @@ #include #include #include -#include "common/buffer-view.h" +#include +#include struct lttng_condition_session_consumed_size { struct lttng_condition parent; diff --git a/include/lttng/condition/session-rotation-internal.h b/include/lttng/condition/session-rotation-internal.h index 0afac8dd0..6e1a410b3 100644 --- a/include/lttng/condition/session-rotation-internal.h +++ b/include/lttng/condition/session-rotation-internal.h @@ -23,6 +23,7 @@ #include #include "common/buffer-view.h" #include +#include struct lttng_condition_session_rotation { struct lttng_condition parent; diff --git a/src/common/sessiond-comm/agent.h b/src/common/sessiond-comm/agent.h index 11acc52f9..84c66b8b7 100644 --- a/src/common/sessiond-comm/agent.h +++ b/src/common/sessiond-comm/agent.h @@ -21,6 +21,7 @@ #include +#include #include /* diff --git a/src/common/sessiond-comm/relayd.h b/src/common/sessiond-comm/relayd.h index b09dd138d..579a41df1 100644 --- a/src/common/sessiond-comm/relayd.h +++ b/src/common/sessiond-comm/relayd.h @@ -25,6 +25,7 @@ #include #include #include +#include #define RELAYD_VERSION_COMM_MAJOR VERSION_MAJOR #define RELAYD_VERSION_COMM_MINOR VERSION_MINOR diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index f40db1fdd..c0c6a8bba 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include diff --git a/src/lib/lttng-ctl/filter/filter-bytecode.h b/src/lib/lttng-ctl/filter/filter-bytecode.h index c2e8c7839..26cabc408 100644 --- a/src/lib/lttng-ctl/filter/filter-bytecode.h +++ b/src/lib/lttng-ctl/filter/filter-bytecode.h @@ -23,6 +23,7 @@ */ #include +#include #include "filter-ast.h"