Fix: Handle SIGBUS in sessiond and consumerd
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 7 Oct 2020 20:42:05 +0000 (16:42 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 14 May 2021 18:10:22 +0000 (14:10 -0400)
There is an issue with the security model of lib ring buffer (lttng-ust)
vs SIGBUS handling by consumer daemon. We do not handle SIGBUS in the
consumer daemon. An application using ftruncate on a ring buffer shm
could cause the consumer to be killed with SIGBUS.

Wire up SIGBUS handling in the session daemon as well given that it also
uses liblttng-ust-ctl.

This depends on "liblttng-ust-ctl: Implement SIGBUS handling" in
lttng-ust, which extends the API of liblttng-ust-ctl, which requires
the user application to define the TLS sigbus state with
DEFINE_LTTNG_UST_SIGBUS_STATE(). It therefore needs to be introduced in
locked-step between lttng-ust and lttng-tools.

Considering that this change in liblttng-ust-ctl modifies the ABI, it is
done with a major soname version bump of the library, so it is allowed
to break the API.

Depends-on: lttng-ust: I7ade988e3e68a87930fbcee3e14e59c3fb66e755

Fixes: #1284
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I76a91616bd35b21c5e891c8306c73ed5e8725ebb

17 files changed:
include/lttng/lttng-error.h
src/bin/lttng-consumerd/lttng-consumerd.c
src/bin/lttng-sessiond/Makefile.am
src/bin/lttng-sessiond/main.c
src/bin/lttng-sessiond/ust-ctl-internal.h
src/bin/lttng-sessiond/ust-sigbus.c [new file with mode: 0644]
src/bin/lttng-sessiond/ust-sigbus.h [new file with mode: 0644]
src/common/consumer/consumer-stream.c
src/common/consumer/consumer-timer.c
src/common/consumer/consumer.c
src/common/consumer/consumer.h
src/common/error.c
src/common/ust-consumer/ust-consumer.c
src/common/ust-consumer/ust-consumer.h
tests/unit/Makefile.am
tests/unit/test_ust_data.c
tests/unit/ust-sigbus.c [new file with mode: 0644]

index d955e143a0055dd90e52891c4b4d2c5366c05e42..aadf2f45ba9aaf8cd42a6fc7385b31dd8ca4c8bb 100644 (file)
@@ -180,6 +180,7 @@ enum lttng_error_code {
        LTTNG_ERR_EVENT_NOTIFIER_ERROR_ACCOUNTING = 167, /* Error initializing event notifier error accounting. */
        LTTNG_ERR_EVENT_NOTIFIER_ERROR_ACCOUNTING_FULL = 168, /* Error event notifier error accounting full. */
        LTTNG_ERR_INVALID_ERROR_QUERY_TARGET = 169, /* Invalid error query target. */
+       LTTNG_ERR_BUFFER_FLUSH_FAILED        = 170, /* Buffer flush failed */
 
        /* MUST be last element of the manually-assigned section of the enum */
        LTTNG_ERR_NR,
index bd53db5897d3861b42da7e43f8d86b046027ee10..5fffa20e92a4c830df46c78ae6f250c3e363f26f 100644 (file)
@@ -83,13 +83,30 @@ enum lttng_consumer_type lttng_consumer_get_type(void)
 /*
  * Signal handler for the daemon
  */
-static void sighandler(int sig)
+static void sighandler(int sig, siginfo_t *siginfo, void *arg)
 {
        if (sig == SIGINT && sigintcount++ == 0) {
                DBG("ignoring first SIGINT");
                return;
        }
 
+       if (sig == SIGBUS) {
+               int write_ret;
+               const char msg[] = "Received SIGBUS, aborting program.\n";
+
+               lttng_consumer_sigbus_handle(siginfo->si_addr);
+               /*
+                * If ustctl did not catch this signal (triggering a
+                * siglongjmp), abort the program. Otherwise, the execution
+                * will resume from the ust-ctl call which caused this error.
+                *
+                * The return value is ignored since the program aborts anyhow.
+                */
+               write_ret = write(STDERR_FILENO, msg, sizeof(msg));
+               (void) write_ret;
+               abort();
+       }
+
        if (ctx) {
                lttng_consumer_should_exit(ctx);
        }
@@ -97,7 +114,7 @@ static void sighandler(int sig)
 
 /*
  * Setup signal handler for :
- *      SIGINT, SIGTERM, SIGPIPE
+ *      SIGINT, SIGTERM, SIGPIPE, SIGBUS
  */
 static int set_signal_handler(void)
 {
@@ -111,9 +128,9 @@ static int set_signal_handler(void)
        }
 
        sa.sa_mask = sigset;
-       sa.sa_flags = 0;
+       sa.sa_flags = SA_SIGINFO;
 
-       sa.sa_handler = sighandler;
+       sa.sa_sigaction = sighandler;
        if ((ret = sigaction(SIGTERM, &sa, NULL)) < 0) {
                PERROR("sigaction");
                return ret;
@@ -124,6 +141,12 @@ static int set_signal_handler(void)
                return ret;
        }
 
+       if ((ret = sigaction(SIGBUS, &sa, NULL)) < 0) {
+               PERROR("sigaction");
+               return ret;
+       }
+
+       sa.sa_flags = 0;
        sa.sa_handler = SIG_IGN;
        if ((ret = sigaction(SIGPIPE, &sa, NULL)) < 0) {
                PERROR("sigaction");
index 07aaa821ca19a9c4f83613ebca7dcb4505c14aa6..d0033a01924b20dae84a7f90bec1eff9d1460080 100644 (file)
@@ -12,7 +12,7 @@ bin_PROGRAMS = lttng-sessiond
 lttng_sessiond_SOURCES = utils.c utils.h \
                        trace-kernel.c trace-kernel.h \
                        kernel.c kernel.h \
-                       ust-app.h trace-ust.h notify-apps.h \
+                       ust-app.h ust-sigbus.h trace-ust.h notify-apps.h \
                        lttng-ust-ctl.h lttng-ust-abi.h lttng-ust-error.h \
                        ust-ctl-internal.h ust-abi-internal.h ust-error-internal.h \
                        ust-registry.h \
@@ -65,7 +65,8 @@ if HAVE_LIBLTTNG_UST_CTL
 lttng_sessiond_SOURCES += trace-ust.c ust-registry.c ust-app.c \
                        ust-consumer.c ust-consumer.h notify-apps.c \
                        ust-metadata.c ust-clock.h agent-thread.c agent-thread.h \
-                       ust-field-utils.h ust-field-utils.c
+                       ust-field-utils.h ust-field-utils.c \
+                       ust-sigbus.c
 endif
 
 # Add main.c at the end for compile order
index 1174162aa9ac8df25b4dcfc23994a95ac09e50bb..ee4d0c78ec499800cd5e149c95a02afa4f3a53e4 100644 (file)
@@ -75,6 +75,7 @@
 #include "manage-apps.h"
 #include "manage-kernel.h"
 #include "modprobe.h"
+#include "ust-sigbus.h"
 
 static const char *help_msg =
 #ifdef LTTNG_EMBED_HELP
@@ -1170,7 +1171,7 @@ error:
  * Simply stop all worker threads, leaving main() return gracefully after
  * joining all threads and calling cleanup().
  */
-static void sighandler(int sig)
+static void sighandler(int sig, siginfo_t *siginfo, void *arg)
 {
        switch (sig) {
        case SIGINT:
@@ -1184,6 +1185,23 @@ static void sighandler(int sig)
        case SIGUSR1:
                CMM_STORE_SHARED(recv_child_signal, 1);
                break;
+       case SIGBUS:
+       {
+               int write_ret;
+               const char msg[] = "Received SIGBUS, aborting program.\n";
+
+               lttng_ust_handle_sigbus(siginfo->si_addr);
+               /*
+                * If ustctl did not catch this signal (triggering a
+                * siglongjmp), abort the program. Otherwise, the execution
+                * will resume from the ust-ctl call which caused this error.
+                *
+                * The return value is ignored since the program aborts anyhow.
+                */
+               write_ret = write(STDERR_FILENO, msg, sizeof(msg));
+               (void) write_ret;
+               abort();
+       }
        default:
                break;
        }
@@ -1205,9 +1223,9 @@ static int set_signal_handler(void)
        }
 
        sa.sa_mask = sigset;
-       sa.sa_flags = 0;
+       sa.sa_flags = SA_SIGINFO;
 
-       sa.sa_handler = sighandler;
+       sa.sa_sigaction = sighandler;
        if ((ret = sigaction(SIGTERM, &sa, NULL)) < 0) {
                PERROR("sigaction");
                return ret;
@@ -1223,13 +1241,19 @@ static int set_signal_handler(void)
                return ret;
        }
 
+       if ((ret = sigaction(SIGBUS, &sa, NULL)) < 0) {
+               PERROR("sigaction");
+               return ret;
+       }
+
+       sa.sa_flags = 0;
        sa.sa_handler = SIG_IGN;
        if ((ret = sigaction(SIGPIPE, &sa, NULL)) < 0) {
                PERROR("sigaction");
                return ret;
        }
 
-       DBG("Signal handler set for SIGTERM, SIGUSR1, SIGPIPE and SIGINT");
+       DBG("Signal handler set for SIGTERM, SIGUSR1, SIGPIPE, SIGINT, and SIGBUS");
 
        return ret;
 }
index 96cbf79bc88efb85fadca521717cc326af44ad2a..ff3023380924b555b754b79d44f0f1cb5f01e30d 100644 (file)
@@ -251,9 +251,9 @@ int lttng_ust_ctl_get_subbuf(struct lttng_ust_ctl_consumer_stream *stream,
                unsigned long *pos);
 int lttng_ust_ctl_put_subbuf(struct lttng_ust_ctl_consumer_stream *stream);
 
-void lttng_ust_ctl_flush_buffer(struct lttng_ust_ctl_consumer_stream *stream,
+int lttng_ust_ctl_flush_buffer(struct lttng_ust_ctl_consumer_stream *stream,
                int producer_active);
-void lttng_ust_ctl_clear_buffer(struct lttng_ust_ctl_consumer_stream *stream);
+int lttng_ust_ctl_clear_buffer(struct lttng_ust_ctl_consumer_stream *stream);
 
 /* index */
 
@@ -653,4 +653,6 @@ int lttng_ust_ctl_counter_aggregate(struct lttng_ust_ctl_daemon_counter *counter
 int lttng_ust_ctl_counter_clear(struct lttng_ust_ctl_daemon_counter *counter,
                const size_t *dimension_indexes);
 
+void ustctl_sigbus_handle(void *addr);
+
 #endif /* LTTNG_UST_CTL_INTERNAL_H */
diff --git a/src/bin/lttng-sessiond/ust-sigbus.c b/src/bin/lttng-sessiond/ust-sigbus.c
new file mode 100644 (file)
index 0000000..52a7ac2
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2021 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <lttng/ust-sigbus.h>
+#include <lttng/ust-ctl.h>
+#include "ust-sigbus.h"
+
+DEFINE_LTTNG_UST_SIGBUS_STATE();
+
+void lttng_ust_handle_sigbus(void *address)
+{
+        lttng_ust_ctl_sigbus_handle(address);
+}
diff --git a/src/bin/lttng-sessiond/ust-sigbus.h b/src/bin/lttng-sessiond/ust-sigbus.h
new file mode 100644 (file)
index 0000000..110ef7f
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2021 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#ifndef LTTNG_UST_SIGBUS_H
+#define LTTNG_UST_SIGBUS_H
+
+#ifdef HAVE_LIBLTTNG_UST_CTL
+
+void lttng_ust_handle_sigbus(void *address);
+
+#else /* HAVE_LIBLTTNG_UST_CTL */
+
+static inline
+void lttng_ust_handle_sigbus(void *address)
+{
+}
+
+#endif /* HAVE_LIBLTTNG_UST_CTL */
+
+#endif /* LTTNG_UST_SIGBUS_H */
index d68077855531d4e1adab9bb3ba27c8391b32b036..37b2d505057c9c470f8892626d211ff634195a39 100644 (file)
@@ -1317,7 +1317,7 @@ int consumer_stream_flush_buffer(struct lttng_consumer_stream *stream,
                break;
        case LTTNG_CONSUMER32_UST:
        case LTTNG_CONSUMER64_UST:
-               lttng_ustconsumer_flush_buffer(stream, (int) producer_active);
+               ret = lttng_ustconsumer_flush_buffer(stream, (int) producer_active);
                break;
        default:
                ERR("Unknown consumer_data type");
index cbb0062781f3393d927a5af44842388b3e9d4fec..d0cf170dacf1b08f88dcdc77ba1b541d0ede23c6 100644 (file)
@@ -237,7 +237,11 @@ int consumer_flush_ust_index(struct lttng_consumer_stream *stream)
                ERR("Failed to get the current timestamp");
                goto end;
        }
-       lttng_ustconsumer_flush_buffer(stream, 1);
+       ret = lttng_ustconsumer_flush_buffer(stream, 1);
+       if (ret < 0) {
+               ERR("Failed to flush buffer while flushing index");
+               goto end;
+       }
        ret = lttng_ustconsumer_take_snapshot(stream);
        if (ret < 0) {
                if (ret != -EAGAIN) {
index 4519944e851f10e4f04e083a73302349eb51feae..a903ff9d2a643cda5c090f23ea84829416a55292 100644 (file)
@@ -4399,7 +4399,11 @@ int consumer_clear_buffer(struct lttng_consumer_stream *stream)
                break;
        case LTTNG_CONSUMER32_UST:
        case LTTNG_CONSUMER64_UST:
-               lttng_ustconsumer_clear_buffer(stream);
+               ret = lttng_ustconsumer_clear_buffer(stream);
+               if (ret < 0) {
+                       ERR("Failed to clear ust stream (ret = %d)", ret);
+                       goto end;
+               }
                break;
        default:
                ERR("Unknown consumer_data type");
@@ -5249,3 +5253,8 @@ error_unlock:
        pthread_mutex_unlock(&stream->lock);
        goto end_rcu_unlock;
 }
+
+void lttng_consumer_sigbus_handle(void *addr)
+{
+       lttng_ustconsumer_sigbus_handle(addr);
+}
index 5fb812c08edb377f213f26b91e53dc74a2364d9a..0c83baa8cec451fce5671c1bc51e0c2cd3970e5e 100644 (file)
@@ -1059,5 +1059,6 @@ int lttng_consumer_clear_channel(struct lttng_consumer_channel *channel);
 enum lttcomm_return_code lttng_consumer_open_channel_packets(
                struct lttng_consumer_channel *channel);
 int consumer_metadata_wakeup_pipe(const struct lttng_consumer_channel *channel);
+void lttng_consumer_sigbus_handle(void *addr);
 
 #endif /* LIB_CONSUMER_H */
index 9070131638bb6d19f6054260d72b9df655d27453..611967b86f19101d6204799b78f270b65f17c727 100644 (file)
@@ -244,6 +244,7 @@ static const char *error_string_array[] = {
        [ ERROR_INDEX(LTTNG_ERR_EVENT_NOTIFIER_REGISTRATION) ] = "Failed to create event notifier",
        [ ERROR_INDEX(LTTNG_ERR_EVENT_NOTIFIER_ERROR_ACCOUNTING) ] = "Failed to initialize event notifier error accounting",
        [ ERROR_INDEX(LTTNG_ERR_EVENT_NOTIFIER_ERROR_ACCOUNTING_FULL) ] = "No index available in event notifier error accounting",
+       [ ERROR_INDEX(LTTNG_ERR_BUFFER_FLUSH_FAILED) ] = "Failed to flush stream buffer",
 
        /* Last element */
        [ ERROR_INDEX(LTTNG_ERR_NR) ] = "Unknown error code"
index 87ca3192775a2b4c4bedaee75e0ef661ca6e6b11..2948fda5043ad7b8aa4dd177e0beb04b25d38d48 100644 (file)
@@ -10,6 +10,7 @@
 #define _LGPL_SOURCE
 #include <assert.h>
 #include <lttng/ust-ctl.h>
+#include <lttng/ust-sigbus.h>
 #include <poll.h>
 #include <pthread.h>
 #include <stdlib.h>
@@ -47,6 +48,8 @@
 extern struct lttng_consumer_global_data the_consumer_data;
 extern int consumer_poll_timeout;
 
+DEFINE_LTTNG_UST_SIGBUS_STATE();
+
 /*
  * Free channel object and all streams associated with it. This MUST be used
  * only and only if the channel has _NEVER_ been added to the global channel
@@ -727,7 +730,14 @@ static int flush_channel(uint64_t chan_key)
                }
 
                if (!stream->quiescent) {
-                       lttng_ust_ctl_flush_buffer(stream->ustream, 0);
+                       ret = lttng_ust_ctl_flush_buffer(stream->ustream, 0);
+                       if (ret) {
+                               ERR("Failed to flush buffer while flushing channel: channel key = %" PRIu64 ", channel name = '%s'",
+                                               chan_key, channel->name);
+                               ret = LTTNG_ERR_BUFFER_FLUSH_FAILED;
+                               pthread_mutex_unlock(&stream->lock);
+                               goto error;
+                       }
                        stream->quiescent = true;
                }
 next:
@@ -1128,7 +1138,12 @@ static int snapshot_channel(struct lttng_consumer_channel *channel,
                 * Else, if quiescent, it has already been done by the prior stop.
                 */
                if (!stream->quiescent) {
-                       lttng_ust_ctl_flush_buffer(stream->ustream, 0);
+                       ret = lttng_ust_ctl_flush_buffer(stream->ustream, 0);
+                       if (ret < 0) {
+                               ERR("Failed to flush buffer during snapshot of channel: channel key = %" PRIu64 ", channel name = '%s'",
+                                               channel->key, channel->name);
+                               goto error_unlock;
+                       }
                }
 
                ret = lttng_ustconsumer_take_snapshot(stream);
@@ -2314,13 +2329,13 @@ end:
        return ret_func;
 }
 
-void lttng_ust_flush_buffer(
-               struct lttng_consumer_stream *stream, int producer_active)
+int lttng_ust_flush_buffer(struct lttng_consumer_stream *stream,
+               int producer_active)
 {
        assert(stream);
        assert(stream->ustream);
 
-       lttng_ust_ctl_flush_buffer(stream->ustream, producer_active);
+       return lttng_ust_ctl_flush_buffer(stream->ustream, producer_active);
 }
 
 /*
@@ -2380,21 +2395,21 @@ int lttng_ustconsumer_get_consumed_snapshot(
        return lttng_ust_ctl_snapshot_get_consumed(stream->ustream, pos);
 }
 
-void lttng_ustconsumer_flush_buffer(struct lttng_consumer_stream *stream,
+int lttng_ustconsumer_flush_buffer(struct lttng_consumer_stream *stream,
                int producer)
 {
        assert(stream);
        assert(stream->ustream);
 
-       lttng_ust_ctl_flush_buffer(stream->ustream, producer);
+       return lttng_ust_ctl_flush_buffer(stream->ustream, producer);
 }
 
-void lttng_ustconsumer_clear_buffer(struct lttng_consumer_stream *stream)
+int lttng_ustconsumer_clear_buffer(struct lttng_consumer_stream *stream)
 {
        assert(stream);
        assert(stream->ustream);
 
-       lttng_ust_ctl_clear_buffer(stream->ustream);
+       return lttng_ust_ctl_clear_buffer(stream->ustream);
 }
 
 int lttng_ustconsumer_get_current_timestamp(
@@ -2427,8 +2442,11 @@ void lttng_ustconsumer_on_stream_hangup(struct lttng_consumer_stream *stream)
 
        pthread_mutex_lock(&stream->lock);
        if (!stream->quiescent) {
-               lttng_ust_ctl_flush_buffer(stream->ustream, 0);
-               stream->quiescent = true;
+               if (lttng_ust_ctl_flush_buffer(stream->ustream, 0) < 0) {
+                       ERR("Failed to flush buffer on stream hang-up");
+               } else {
+                       stream->quiescent = true;
+               }
        }
        pthread_mutex_unlock(&stream->lock);
        stream->hangup_flush_done = 1;
@@ -2589,8 +2607,12 @@ int commit_one_metadata_packet(struct lttng_consumer_stream *stream)
         * a metadata packet. Since the subbuffer is fully filled (with padding,
         * if needed), the stream is "quiescent" after this commit.
         */
-       lttng_ust_ctl_flush_buffer(stream->ustream, 1);
-       stream->quiescent = true;
+       if (lttng_ust_ctl_flush_buffer(stream->ustream, 1)) {
+               ERR("Failed to flush buffer while commiting one metadata packet");
+               ret = -EIO;
+       } else {
+               stream->quiescent = true;
+       }
 end:
        pthread_mutex_unlock(&stream->chan->metadata_cache->lock);
        return ret;
@@ -3410,3 +3432,8 @@ int lttng_ustconsumer_get_stream_id(struct lttng_consumer_stream *stream,
 
        return lttng_ust_ctl_get_stream_id(stream->ustream, stream_id);
 }
+
+void lttng_ustconsumer_sigbus_handle(void *addr)
+{
+       lttng_ust_ctl_sigbus_handle(addr);
+}
index 7ddcb112affb34b1a1234f54a0f0eb2457883751..e2507a7f441da932809adb3220e22bb803e9ec32 100644 (file)
@@ -39,10 +39,10 @@ int lttng_ustconsumer_on_recv_stream(struct lttng_consumer_stream *stream);
 
 void lttng_ustconsumer_on_stream_hangup(struct lttng_consumer_stream *stream);
 
-void lttng_ust_flush_buffer(
-               struct lttng_consumer_stream *stream, int producer_active);
-int lttng_ustconsumer_get_stream_id(
-               struct lttng_consumer_stream *stream, uint64_t *stream_id);
+int lttng_ust_flush_buffer(struct lttng_consumer_stream *stream,
+               int producer_active);
+int lttng_ustconsumer_get_stream_id(struct lttng_consumer_stream *stream,
+               uint64_t *stream_id);
 int lttng_ustconsumer_data_pending(struct lttng_consumer_stream *stream);
 void lttng_ustconsumer_close_all_metadata(struct lttng_ht *ht);
 void lttng_ustconsumer_close_metadata(struct lttng_consumer_channel *metadata);
@@ -55,13 +55,14 @@ int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx,
 enum sync_metadata_status lttng_ustconsumer_sync_metadata(
                struct lttng_consumer_local_data *ctx,
                struct lttng_consumer_stream *metadata);
-void lttng_ustconsumer_flush_buffer(struct lttng_consumer_stream *stream,
+int lttng_ustconsumer_flush_buffer(struct lttng_consumer_stream *stream,
                int producer);
-void lttng_ustconsumer_clear_buffer(struct lttng_consumer_stream *stream);
+int lttng_ustconsumer_clear_buffer(struct lttng_consumer_stream *stream);
 int lttng_ustconsumer_get_current_timestamp(
                struct lttng_consumer_stream *stream, uint64_t *ts);
 int lttng_ustconsumer_get_sequence_number(
                struct lttng_consumer_stream *stream, uint64_t *seq);
+void lttng_ustconsumer_sigbus_handle(void *addr);
 
 #else /* HAVE_LIBLTTNG_UST_CTL */
 
@@ -168,9 +169,10 @@ int lttng_ustconsumer_data_pending(struct lttng_consumer_stream *stream)
        return -ENOSYS;
 }
 static inline
-void lttng_ust_flush_buffer(struct lttng_consumer_stream *stream,
+int lttng_ust_flush_buffer(struct lttng_consumer_stream *stream,
                int producer_active)
 {
+       return -ENOSYS;
 }
 static inline
 void lttng_ustconsumer_close_all_metadata(struct lttng_ht *ht)
@@ -204,13 +206,15 @@ enum sync_metadata_status lttng_ustconsumer_sync_metadata(struct lttng_consumer_
        return SYNC_METADATA_STATUS_ERROR;
 }
 static inline
-void lttng_ustconsumer_flush_buffer(struct lttng_consumer_stream *stream,
+int lttng_ustconsumer_flush_buffer(struct lttng_consumer_stream *stream,
                int producer)
 {
+       return -ENOSYS;
 }
 static inline
-void lttng_ustconsumer_clear_buffer(struct lttng_consumer_stream *stream)
+int lttng_ustconsumer_clear_buffer(struct lttng_consumer_stream *stream)
 {
+       return -ENOSYS;
 }
 static inline
 int lttng_ustconsumer_get_current_timestamp(
@@ -230,6 +234,10 @@ int lttng_ustconsumer_get_stream_id(struct lttng_consumer_stream *stream,
 {
        return -ENOSYS;
 }
+static inline
+void lttng_ustconsumer_sigbus_handle(void *addr)
+{
+}
 #endif /* HAVE_LIBLTTNG_UST_CTL */
 
 #endif /* _LTTNG_USTCONSUMER_H */
index 401e89f25a5e7936eef74852077e38ea9789b791..ff49a56e4806c6ec16697df312e56703e0cd5f90 100644 (file)
@@ -149,6 +149,7 @@ test_session_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBRELAYD) $(LIBSESSIOND_COMM) \
 test_session_LDADD += $(SESSIOND_OBJS)
 
 if HAVE_LIBLTTNG_UST_CTL
+test_session_SOURCES += ust-sigbus.c
 test_session_LDADD += $(UST_CTL_LIBS)
 endif
 
index f92b1f802b7481b415aae1834ae2475b02e070c3..87da5b4b6953a7a935b2e01016366b80fa8ab4a0 100644 (file)
@@ -21,6 +21,8 @@
 #include <bin/lttng-sessiond/ust-app.h>
 #include <bin/lttng-sessiond/notification-thread.h>
 
+#include <lttng/ust-sigbus.h>
+
 #include <tap/tap.h>
 
 /* This path will NEVER be created in this test */
@@ -31,6 +33,8 @@
 /* Number of TAP tests in this file */
 #define NUM_TESTS 16
 
+DEFINE_LTTNG_UST_SIGBUS_STATE();
+
 /* For error.h */
 int lttng_opt_quiet = 1;
 int lttng_opt_verbose;
diff --git a/tests/unit/ust-sigbus.c b/tests/unit/ust-sigbus.c
new file mode 100644 (file)
index 0000000..4dbddde
--- /dev/null
@@ -0,0 +1,10 @@
+/*
+ * Copyright (C) 2021 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ */
+
+#include <lttng/ust-sigbus.h>
+
+DEFINE_LTTNG_UST_SIGBUS_STATE();
This page took 0.03994 seconds and 4 git commands to generate.