From 5728ab7df45a2e4b84a709ad2e87712213ab21a9 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Mon, 6 Jun 2022 15:48:16 -0400 Subject: [PATCH] Fix: sessiond: uninitialized bytes sent to lttng-ust MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Valgrind reports: ==3421594== Thread 9 UST registratio: ==3421594== Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s) ==3421594== at 0x4DCA12D: __libc_sendmsg (sendmsg.c:28) ==3421594== by 0x4DCA12D: sendmsg (sendmsg.c:25) ==3421594== by 0x4B6BDE2: ustcomm_send_unix_sock (ustcomm.c:323) ==3421594== by 0x4B31549: lttng_ust_ctl_send_counter_data_to_ust (ustctl.c:3167) ==3421594== by 0x18E8D8: send_counter_data_to_ust(ust_app*, lttng_ust_abi_object_data*) (event-notifier-error-accounting.cpp:535) ==3421594== by 0x18EDE4: event_notifier_error_accounting_register_app(ust_app*) (event-notifier-error-accounting.cpp:647) ==3421594== by 0x1AA796: ust_app_setup_event_notifier_group(ust_app*) (ust-app.cpp:4252) ==3421594== by 0x184AC1: thread_dispatch_ust_registration(void*) (dispatch.cpp:420) ==3421594== by 0x178192: launch_thread(void*) (thread.cpp:68) ==3421594== by 0x4DBE608: start_thread (pthread_create.c:477) ==3421594== by 0x4EF8162: clone (clone.S:95) ==3421594== Address 0x6f3e2fc is 28 bytes inside a block of size 192 alloc'd ==3421594== at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==3421594== by 0x4B2BC3F: zmalloc (macros.h:23) ==3421594== by 0x4B2BC3F: lttng_ust_ctl_duplicate_ust_object_data (ustctl.c:1332) ==3421594== by 0x18ED4F: event_notifier_error_accounting_register_app(ust_app*) (event-notifier-error-accounting.cpp:638) ==3421594== by 0x1AA796: ust_app_setup_event_notifier_group(ust_app*) (ust-app.cpp:4252) ==3421594== by 0x184AC1: thread_dispatch_ust_registration(void*) (dispatch.cpp:420) ==3421594== by 0x178192: launch_thread(void*) (thread.cpp:68) ==3421594== by 0x4DBE608: start_thread (pthread_create.c:477) ==3421594== by 0x4EF8162: clone (clone.S:95) ==3421594== Uninitialised value was created by a stack allocation ==3421594== at 0x18DCF3: ust_error_accounting_entry_create(ust_app const*) (event-notifier-error-accounting.cpp:377) The underflow/overflow indices are left uninitialized and are ultimately sent. Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: I6dfff2e39a8fda0e74dd874ab34be66845629069 --- src/bin/lttng-sessiond/event-notifier-error-accounting.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp b/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp index 70ffb86ef..85327c216 100644 --- a/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp +++ b/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp @@ -378,7 +378,7 @@ struct ust_error_accounting_entry *ust_error_accounting_entry_create( struct lttng_ust_ctl_daemon_counter *daemon_counter; struct lttng_ust_abi_object_data *counter, **cpu_counters; struct ust_error_accounting_entry *entry = NULL; - lttng_ust_ctl_counter_dimension dimension; + lttng_ust_ctl_counter_dimension dimension = {}; dimension.size = ust_state.number_indices; dimension.has_underflow = false; -- 2.34.1