All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH lttng-tools] Cleanup: initialize kernel ioctl ABI structures to 0
@ 2017-05-08 12:34 Mathieu Desnoyers
  0 siblings, 0 replies; 2+ messages in thread
From: Mathieu Desnoyers @ 2017-05-08 12:34 UTC (permalink / raw)
  To: jgalar; +Cc: lttng-dev

Valgrind complains that we pass uninitialized data to the kernel.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
---
 src/common/kernel-ctl/kernel-ctl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/common/kernel-ctl/kernel-ctl.c b/src/common/kernel-ctl/kernel-ctl.c
index fffa64c..4911d86 100644
--- a/src/common/kernel-ctl/kernel-ctl.c
+++ b/src/common/kernel-ctl/kernel-ctl.c
@@ -89,10 +89,12 @@ int kernctl_create_session(int fd)
 /* open the metadata global channel */
 int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops)
 {
-	struct lttng_kernel_old_channel old_channel;
 	struct lttng_kernel_channel channel;
 
 	if (lttng_kernel_use_old_abi) {
+		struct lttng_kernel_old_channel old_channel;
+
+		memset(&old_channel, 0, sizeof(old_channel));
 		old_channel.overwrite = chops->overwrite;
 		old_channel.subbuf_size = chops->subbuf_size;
 		old_channel.num_subbuf = chops->num_subbuf;
@@ -111,6 +113,7 @@ int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops)
 			        &old_channel);
 	}
 
+	memset(&channel, 0, sizeof(channel));
 	channel.overwrite = chops->overwrite;
 	channel.subbuf_size = chops->subbuf_size;
 	channel.num_subbuf = chops->num_subbuf;
@@ -246,6 +249,7 @@ int kernctl_create_event(int fd, struct lttng_kernel_event *ev)
 	if (lttng_kernel_use_old_abi) {
 		struct lttng_kernel_old_event old_event;
 
+		memset(&old_event, 0, sizeof(old_event));
 		memcpy(old_event.name, ev->name, sizeof(old_event.name));
 		old_event.instrumentation = ev->instrumentation;
 		switch (ev->instrumentation) {
@@ -283,6 +287,7 @@ int kernctl_add_context(int fd, struct lttng_kernel_context *ctx)
 	if (lttng_kernel_use_old_abi) {
 		struct lttng_kernel_old_context old_ctx;
 
+		memset(&old_ctx, 0, sizeof(old_ctx));
 		old_ctx.ctx = ctx->ctx;
 		/* only type that uses the union */
 		if (ctx->ctx == LTTNG_KERNEL_CONTEXT_PERF_CPU_COUNTER) {
-- 
2.1.4

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH lttng-tools] Cleanup: initialize kernel ioctl ABI structures to 0
       [not found] <1494246897-12111-1-git-send-email-mathieu.desnoyers@efficios.com>
@ 2017-05-09 12:37 ` Jérémie Galarneau
  0 siblings, 0 replies; 2+ messages in thread
From: Jérémie Galarneau @ 2017-05-09 12:37 UTC (permalink / raw)
  To: Mathieu Desnoyers; +Cc: lttng-dev, Jeremie Galarneau

Merged in master, stable-2.10, stable-2.9 and stable-2.8, thanks!

Jérémie

On 8 May 2017 at 08:34, Mathieu Desnoyers
<mathieu.desnoyers@efficios.com> wrote:
> Valgrind complains that we pass uninitialized data to the kernel.
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> ---
>  src/common/kernel-ctl/kernel-ctl.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/common/kernel-ctl/kernel-ctl.c b/src/common/kernel-ctl/kernel-ctl.c
> index fffa64c..4911d86 100644
> --- a/src/common/kernel-ctl/kernel-ctl.c
> +++ b/src/common/kernel-ctl/kernel-ctl.c
> @@ -89,10 +89,12 @@ int kernctl_create_session(int fd)
>  /* open the metadata global channel */
>  int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops)
>  {
> -       struct lttng_kernel_old_channel old_channel;
>         struct lttng_kernel_channel channel;
>
>         if (lttng_kernel_use_old_abi) {
> +               struct lttng_kernel_old_channel old_channel;
> +
> +               memset(&old_channel, 0, sizeof(old_channel));
>                 old_channel.overwrite = chops->overwrite;
>                 old_channel.subbuf_size = chops->subbuf_size;
>                 old_channel.num_subbuf = chops->num_subbuf;
> @@ -111,6 +113,7 @@ int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops)
>                                 &old_channel);
>         }
>
> +       memset(&channel, 0, sizeof(channel));
>         channel.overwrite = chops->overwrite;
>         channel.subbuf_size = chops->subbuf_size;
>         channel.num_subbuf = chops->num_subbuf;
> @@ -246,6 +249,7 @@ int kernctl_create_event(int fd, struct lttng_kernel_event *ev)
>         if (lttng_kernel_use_old_abi) {
>                 struct lttng_kernel_old_event old_event;
>
> +               memset(&old_event, 0, sizeof(old_event));
>                 memcpy(old_event.name, ev->name, sizeof(old_event.name));
>                 old_event.instrumentation = ev->instrumentation;
>                 switch (ev->instrumentation) {
> @@ -283,6 +287,7 @@ int kernctl_add_context(int fd, struct lttng_kernel_context *ctx)
>         if (lttng_kernel_use_old_abi) {
>                 struct lttng_kernel_old_context old_ctx;
>
> +               memset(&old_ctx, 0, sizeof(old_ctx));
>                 old_ctx.ctx = ctx->ctx;
>                 /* only type that uses the union */
>                 if (ctx->ctx == LTTNG_KERNEL_CONTEXT_PERF_CPU_COUNTER) {
> --
> 2.1.4
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-09 12:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-08 12:34 [PATCH lttng-tools] Cleanup: initialize kernel ioctl ABI structures to 0 Mathieu Desnoyers
     [not found] <1494246897-12111-1-git-send-email-mathieu.desnoyers@efficios.com>
2017-05-09 12:37 ` Jérémie Galarneau

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.