ustctl: Initialize counter_conf struct to zero
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 8 Dec 2020 23:28:32 +0000 (18:28 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 9 Dec 2020 14:03:22 +0000 (09:03 -0500)
Issue
=====
This struct is not initialize explicitly and is copied and sent through
a Unix socket to the application. This means we are currently sending
uninitialized data.

Valgrind reports the following:
  ==939806== Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s)
  ==939806==    at 0x519412D: __libc_sendmsg (sendmsg.c:28)
  ==939806==    by 0x519412D: sendmsg (sendmsg.c:25)
  ==939806==    by 0x514D2BF: ustcomm_send_unix_sock (in /usr/local/lib/liblttng-ust-ctl.so.4.0.0)
  ==939806==    by 0x514C0BC: ustctl_send_counter_data_to_ust (in /usr/local/lib/liblttng-ust-ctl.so.4.0.0)
  ==939806==    by 0x4A0B14: send_counter_data_to_ust (event-notifier-error-accounting.c:237)
  ==939806==    by 0x4A046D: event_notifier_error_accounting_register_app (event-notifier-error-accounting.c:311)
  ==939806==    by 0x4B0831: ust_app_setup_event_notifier_group (ust-app.c:3956)
  ==939806==    by 0x495603: thread_dispatch_ust_registration (dispatch.c:394)
  ==939806==    by 0x487552: launch_thread (thread.c:66)
  ==939806==    by 0x5188608: start_thread (pthread_create.c:477)
  ==939806==    by 0x52E2292: clone (clone.S:95)
  ==939806==  Address 0x750fb8e is 46 bytes inside a block of size 228 alloc'd
  ==939806==    at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==939806==    by 0x514988C: ustctl_duplicate_ust_object_data (in /usr/local/lib/liblttng-ust-ctl.so.4.0.0)
  ==939806==    by 0x4A0426: event_notifier_error_accounting_register_app (event-notifier-error-accounting.c:307)
  ==939806==    by 0x4B0831: ust_app_setup_event_notifier_group (ust-app.c:3956)
  ==939806==    by 0x495603: thread_dispatch_ust_registration (dispatch.c:394)
  ==939806==    by 0x487552: launch_thread (thread.c:66)
  ==939806==    by 0x5188608: start_thread (pthread_create.c:477)
  ==939806==    by 0x52E2292: clone (clone.S:95)

Fix
===
Initialize it to zero.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8ce4753858a3ab3e12b94f26b94a200cef15cb06

liblttng-ust-ctl/ustctl.c

index e7978744be681894d9cad7b769855597c09af0f1..8460dbf4f654ab06fc2954405b48ab6f6fb024bf 100644 (file)
@@ -2563,7 +2563,7 @@ int ustctl_create_counter_data(struct ustctl_daemon_counter *counter,
                struct lttng_ust_object_data **_counter_data)
 {
        struct lttng_ust_object_data *counter_data;
-       struct lttng_ust_counter_conf counter_conf;
+       struct lttng_ust_counter_conf counter_conf = {0};
        size_t i;
        int ret;
 
This page took 0.025863 seconds and 4 git commands to generate.