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)
commitaa52c9865e22402a2e310b5b770ae0352b6a0be0
tree769d46140c83a5c4db9106179777015a5daa4fbc
parenta8d119b5ea8e40cde5f5e70c1ae4cfc86cb35a80
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 \<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
This page took 0.027562 seconds and 5 git commands to generate.