All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] trace-cmd: Have tracecmd_msg_data_send() return zero on zero size
@ 2019-03-21 23:41 Steven Rostedt
  2019-03-22 11:49 ` Slavomir Kaslev
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2019-03-21 23:41 UTC (permalink / raw)
  To: Linux Trace Devel; +Cc: Slavomir Kaslev

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

If tracecmd_msg_data_send() is passed a size of zero, the loop is not
entered, nothing is sent, but the ret variable is not initialized and
garbage can be sent out. The option code can call this with a size of zero,
which can cause an error report.

Just don't do anything in this case, and return a success.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tracecmd/trace-msg.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tracecmd/trace-msg.c b/tracecmd/trace-msg.c
index 51d0ac8b..382bd766 100644
--- a/tracecmd/trace-msg.c
+++ b/tracecmd/trace-msg.c
@@ -590,6 +590,10 @@ int tracecmd_msg_data_send(struct tracecmd_msg_handle *msg_handle,
 	int ret;
 	int count = 0;
 
+	/* Don't bother doing anything if there's nothing to do */
+	if (!size)
+		return 0;
+
 	tracecmd_msg_init(MSG_SEND_DATA, &msg);
 
 	msg.buf = malloc(MSG_MAX_DATA_LEN);
-- 
2.20.1


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

* Re: [PATCH] trace-cmd: Have tracecmd_msg_data_send() return zero on zero size
  2019-03-21 23:41 [PATCH] trace-cmd: Have tracecmd_msg_data_send() return zero on zero size Steven Rostedt
@ 2019-03-22 11:49 ` Slavomir Kaslev
  2019-03-22 12:17   ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Slavomir Kaslev @ 2019-03-22 11:49 UTC (permalink / raw)
  To: rostedt, linux-trace-devel

On Thu, 2019-03-21 at 19:41 -0400, Steven Rostedt wrote:
> From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
> 
> If tracecmd_msg_data_send() is passed a size of zero, the loop is not
> entered, nothing is sent, but the ret variable is not initialized and
> garbage can be sent out. The option code can call this with a size of
> zero,
> which can cause an error report.
> 
> Just don't do anything in this case, and return a success.
> 
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
>  tracecmd/trace-msg.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tracecmd/trace-msg.c b/tracecmd/trace-msg.c
> index 51d0ac8b..382bd766 100644
> --- a/tracecmd/trace-msg.c
> +++ b/tracecmd/trace-msg.c
> @@ -590,6 +590,10 @@ int tracecmd_msg_data_send(struct
> tracecmd_msg_handle *msg_handle,
>  	int ret;
>  	int count = 0;
>  
> +	/* Don't bother doing anything if there's nothing to do */
> +	if (!size)
> +		return 0;
> +
>  	tracecmd_msg_init(MSG_SEND_DATA, &msg);
>  
>  	msg.buf = malloc(MSG_MAX_DATA_LEN);

Nice catch. Definitely a latent bug waiting for someone to step on it.

Reviewed-by: Slavomir Kaslev <kaslevs@vmware.com>

-- Slavi

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

* Re: [PATCH] trace-cmd: Have tracecmd_msg_data_send() return zero on zero size
  2019-03-22 11:49 ` Slavomir Kaslev
@ 2019-03-22 12:17   ` Steven Rostedt
  0 siblings, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2019-03-22 12:17 UTC (permalink / raw)
  To: Slavomir Kaslev; +Cc: linux-trace-devel

On Fri, 22 Mar 2019 11:49:29 +0000
Slavomir Kaslev <kaslevs@vmware.com> wrote:

> > diff --git a/tracecmd/trace-msg.c b/tracecmd/trace-msg.c
> > index 51d0ac8b..382bd766 100644
> > --- a/tracecmd/trace-msg.c
> > +++ b/tracecmd/trace-msg.c
> > @@ -590,6 +590,10 @@ int tracecmd_msg_data_send(struct
> > tracecmd_msg_handle *msg_handle,
> >  	int ret;
> >  	int count = 0;
> >  
> > +	/* Don't bother doing anything if there's nothing to do */
> > +	if (!size)
> > +		return 0;
> > +
> >  	tracecmd_msg_init(MSG_SEND_DATA, &msg);
> >  
> >  	msg.buf = malloc(MSG_MAX_DATA_LEN);  
> 
> Nice catch. Definitely a latent bug waiting for someone to step on it.
> 
> Reviewed-by: Slavomir Kaslev <kaslevs@vmware.com>

Yeah, it tripped me up, as I had a box that crashed because of it.
Delaying the finishing of the testing. Which I'm rerunning now.

-- Steve

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

end of thread, other threads:[~2019-03-22 12:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-21 23:41 [PATCH] trace-cmd: Have tracecmd_msg_data_send() return zero on zero size Steven Rostedt
2019-03-22 11:49 ` Slavomir Kaslev
2019-03-22 12:17   ` Steven Rostedt

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.