From: Jonathan Rajotte Date: Mon, 10 Jan 2022 22:27:13 +0000 (-0500) Subject: Fix: lttng-ctl: erroneous uses of LTTNG_PACKED X-Git-Tag: v2.12.9~32 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=bad7720255c69c06010ccec2a8f6fedf3387e51d;p=lttng-tools.git Fix: lttng-ctl: erroneous uses of LTTNG_PACKED The LTTNG_PACKED macro uses gcc attributes to indicate that a structure should be packed. Hence, this macro obeys the same rules as the gcc attribute. Various mis-uses of the LTTNG_PACKED macros may result in structure not being packed: - The LTTNG_PACKED macro should always be placed _before_ an identifier when a structure is declared in-place. - Adding LTTNG_PACKED at the definition site has no effect if the structure was declared elsewhere. Those mis-uses cause issues when mixing the bitness (32/64) of the session daemon and liblttng-ctl. Outstanding issues include the following structures that are not tagged as LTTNG_PACKED: - struct lttng_event - struct lttng_channel - struct lttng_event_context Unfortunately, those structures are exposed by the public API and can't be tagged as being "packed". Doing so would break the ABI of liblttng-ctl. These structures should be packed/unpacked explicitly. JORAJ CHERRY PICK: Change-Id: I095dc0dffc6bf9e15dc7a7ec797958a5780ef150 Change-Id: I33f026a613813af312de65adee23ac829a071cf8 Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau --- diff --git a/include/lttng/session-internal.h b/include/lttng/session-internal.h index b263377de..305c3f5f5 100644 --- a/include/lttng/session-internal.h +++ b/include/lttng/session-internal.h @@ -15,7 +15,7 @@ struct lttng_session_extended { struct { uint64_t value; uint8_t is_set; - } creation_time LTTNG_PACKED; + } LTTNG_PACKED creation_time; } LTTNG_PACKED; #endif /* LTTNG_SESSION_INTERNAL_H */ diff --git a/include/lttng/snapshot-internal.h b/include/lttng/snapshot-internal.h index 72d492237..1c6a43746 100644 --- a/include/lttng/snapshot-internal.h +++ b/include/lttng/snapshot-internal.h @@ -11,6 +11,7 @@ #include #include #include +#include /* * Object used for the snapshot API. This is opaque to the public library. @@ -33,7 +34,7 @@ struct lttng_snapshot_output { char ctrl_url[PATH_MAX]; /* Destination of the output. See lttng(1) for URL format. */ char data_url[PATH_MAX]; -}; +} LTTNG_PACKED; /* * Snapshot output list object opaque to the user. diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index b9758af00..b9ab05bcb 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -337,18 +337,18 @@ struct lttcomm_session_msg { uint32_t size; } LTTNG_PACKED uri; struct { - struct lttng_snapshot_output output LTTNG_PACKED; + struct lttng_snapshot_output output; } LTTNG_PACKED snapshot_output; struct { uint32_t wait; - struct lttng_snapshot_output output LTTNG_PACKED; + struct lttng_snapshot_output output; } LTTNG_PACKED snapshot_record; struct { uint32_t nb_uri; unsigned int timer_interval; /* usec */ } LTTNG_PACKED session_live; struct { - struct lttng_save_session_attr attr; /* struct already packed */ + struct lttng_save_session_attr attr; } LTTNG_PACKED save_session; struct { char shm_path[PATH_MAX];