From: Francis Deslauriers Date: Tue, 8 Dec 2020 23:28:32 +0000 (-0500) Subject: ustctl: Initialize counter_conf struct to zero X-Git-Tag: v2.13.0-rc1~415 X-Git-Url: http://git.lttng.org/?p=lttng-ust.git;a=commitdiff_plain;h=dca92811152dcefdec21204f39335ea68b95d6a3 ustctl: Initialize counter_conf struct to zero 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 Signed-off-by: Mathieu Desnoyers Change-Id: I8ce4753858a3ab3e12b94f26b94a200cef15cb06 --- diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c index e7978744..8460dbf4 100644 --- a/liblttng-ust-ctl/ustctl.c +++ b/liblttng-ust-ctl/ustctl.c @@ -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;