Fix: missing include can cause structures to not be packed
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 26 Mar 2019 15:50:41 +0000 (11:50 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 26 Mar 2019 18:41:05 +0000 (14:41 -0400)
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 \<common/macros\.h\>" -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 <jeremie.galarneau@efficios.com>
include/lttng/channel-internal.h
include/lttng/condition/buffer-usage-internal.h
include/lttng/condition/session-consumed-size-internal.h
include/lttng/condition/session-rotation-internal.h
src/common/sessiond-comm/agent.h
src/common/sessiond-comm/relayd.h
src/common/sessiond-comm/sessiond-comm.h
src/lib/lttng-ctl/filter/filter-bytecode.h

index 53171f42c639554d5ed432cca16e35964f3169c0..030b470153c23a8ce7bb67af155590c6b630de71 100644 (file)
@@ -18,6 +18,8 @@
 #ifndef LTTNG_CHANNEL_INTERNAL_H
 #define LTTNG_CHANNEL_INTERNAL_H
 
+#include <common/macros.h>
+
 struct lttng_channel_extended {
        uint64_t discarded_events;
        uint64_t lost_packets;
index 4b605d6647fb34095336f7da5f715928f6997833..6efb0c4c8841e2a3fd758d045ffbb06ac5d5c47a 100644 (file)
@@ -23,6 +23,7 @@
 #include <lttng/condition/evaluation-internal.h>
 #include <lttng/domain.h>
 #include "common/buffer-view.h"
+#include <common/macros.h>
 
 struct lttng_condition_buffer_usage {
        struct lttng_condition parent;
index 65ac706687fe9489f35a18defb8603da0c3ddd37..be9940502a260eb2c73a1f78a65ebfd5cd62eb33 100644 (file)
@@ -21,7 +21,8 @@
 #include <lttng/condition/session-consumed-size.h>
 #include <lttng/condition/condition-internal.h>
 #include <lttng/condition/evaluation-internal.h>
-#include "common/buffer-view.h"
+#include <common/buffer-view.h>
+#include <common/macros.h>
 
 struct lttng_condition_session_consumed_size {
        struct lttng_condition parent;
index 0afac8dd0ed93b82a24492c736f3452d18ce0f32..6e1a410b3efa27e9bc52df3b3d5251dc855ca897 100644 (file)
@@ -23,6 +23,7 @@
 #include <lttng/condition/evaluation-internal.h>
 #include "common/buffer-view.h"
 #include <lttng/location.h>
+#include <common/macros.h>
 
 struct lttng_condition_session_rotation {
        struct lttng_condition parent;
index 11acc52f9206cead181383771830ee2a9f9535c3..84c66b8b754a38358b832fc4dfd7233734cad38e 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <stdint.h>
 
+#include <common/macros.h>
 #include <lttng/lttng.h>
 
 /*
index b09dd138dfb4777f46b533a694e21f19f2e93c8e..579a41df19355261186691263893b1ed6298fbc4 100644 (file)
@@ -25,6 +25,7 @@
 #include <lttng/lttng.h>
 #include <common/defaults.h>
 #include <common/index/ctf-index.h>
+#include <common/macros.h>
 
 #define RELAYD_VERSION_COMM_MAJOR             VERSION_MAJOR
 #define RELAYD_VERSION_COMM_MINOR             VERSION_MINOR
index f40db1fddcd402d4569a2d596d2820b521ce9312..c0c6a8bba9f1ed64cbcd980769c2b16b2b353df8 100644 (file)
@@ -36,6 +36,7 @@
 #include <common/uri.h>
 #include <common/defaults.h>
 #include <common/compat/uuid.h>
+#include <common/macros.h>
 
 #include <arpa/inet.h>
 #include <netinet/in.h>
index c2e8c78398e4f0ea47167b74a39469ca9a1a105c..26cabc408b0aad55a5922e1f4f563ab8bc4e7b0b 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <common/sessiond-comm/sessiond-comm.h>
+#include <common/macros.h>
 
 #include "filter-ast.h"
 
This page took 0.028403 seconds and 4 git commands to generate.