Fix: lttng-ctl: erroneous uses of LTTNG_PACKED
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 10 Jan 2022 22:27:13 +0000 (17:27 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 28 Feb 2022 22:12:03 +0000 (17:12 -0500)
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 <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/lttng/session-internal.h
include/lttng/snapshot-internal.h
src/common/sessiond-comm/sessiond-comm.h

index b263377de0c894653239efd9581202652d485a84..305c3f5f54ddd628f5803254c742a7e4fc876978 100644 (file)
@@ -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 */
index 72d4922375c1c029420184aeceeb291ee77bae3d..1c6a43746b6350091a431dd1542d71a4eda85a26 100644 (file)
@@ -11,6 +11,7 @@
 #include <limits.h>
 #include <stdint.h>
 #include <lttng/constant.h>
+#include <common/macros.h>
 
 /*
  * 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.
index b9758af006647b55c77b213aaf63b60a99e7847f..b9ab05bcb26e3e34b7c765dd93094ad8846541c7 100644 (file)
@@ -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];
This page took 0.026727 seconds and 4 git commands to generate.