linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Yordan Karadzhov <ykaradzhov@vmware.com>
Cc: "linux-trace-devel@vger.kernel.org" <linux-trace-devel@vger.kernel.org>
Subject: Re: [PATCH 01/11] kernel-shark-qt: Protect all calls of tep_read_number_field()
Date: Tue, 27 Nov 2018 15:34:33 -0500	[thread overview]
Message-ID: <20181127153433.5eee37ac@gandalf.local.home> (raw)
In-Reply-To: <20181121151356.16901-3-ykaradzhov@vmware.com>

On Wed, 21 Nov 2018 15:14:19 +0000
Yordan Karadzhov <ykaradzhov@vmware.com> wrote:

> tep_read_number_field() is being used to retrieve the value of a data
> field and this value has being used without checking if the function
> succeeded. This is a potential bug because tep_read_number_field() may
> fail and in such a case the retrieved field value will be arbitrary.
> 
> Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
> ---
>  kernel-shark-qt/src/plugins/sched_events.c | 52 +++++++++++++---------
>  1 file changed, 30 insertions(+), 22 deletions(-)
> 
> diff --git a/kernel-shark-qt/src/plugins/sched_events.c b/kernel-shark-qt/src/plugins/sched_events.c
> index 1851569..c22e198 100644
> --- a/kernel-shark-qt/src/plugins/sched_events.c
> +++ b/kernel-shark-qt/src/plugins/sched_events.c
> @@ -97,10 +97,12 @@ int plugin_get_next_pid(struct tep_record *record)
>  	struct plugin_sched_context *plugin_ctx =
>  		plugin_sched_context_handler;
>  	unsigned long long val;
> +	int ret;
>  
> -	tep_read_number_field(plugin_ctx->sched_switch_next_field,
> -			      record->data, &val);
> -	return val;
> +	ret = tep_read_number_field(plugin_ctx->sched_switch_next_field,
> +				    record->data, &val);
> +
> +	return (ret == 0) ? val : ret;

BTW, here's a little optimization trick:

	return ret ? : val;

We should change the rest to do that.

-- Steve

>  }
>  

  reply	other threads:[~2018-11-28  7:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-21 15:14 [PATCH 00/11] Small modifications and bug fixes toward KS 1.0 Yordan Karadzhov
2018-11-21 15:14 ` [PATCH 01/11] kernel-shark-qt: protect all calls of tep_read_number_field() Yordan Karadzhov
2018-11-21 15:14 ` [PATCH 01/11] kernel-shark-qt: Protect " Yordan Karadzhov
2018-11-27 20:34   ` Steven Rostedt [this message]
2018-11-21 15:14 ` [PATCH 02/11] kernel-shark-qt: Fix the returned error value of kshark_get_event_id_easy() Yordan Karadzhov
2018-11-21 15:14 ` [PATCH 03/11] kernel-shark-qt: Avoid race condition in kshark_get_event_name_easy() Yordan Karadzhov
2018-11-27 20:37   ` Steven Rostedt
2018-11-21 15:14 ` [PATCH 04/11] kernel-shark-qt: Optimize the search in the text data Yordan Karadzhov
2018-11-21 15:14 ` [PATCH 05/11] kernel-shark-qt: Add iterator index to the search panel Yordan Karadzhov
2018-11-21 15:14 ` [PATCH 06/11] kernel-shark-qt: Update search iterator when marker is changed Yordan Karadzhov
2018-11-21 15:14 ` [PATCH 07/11] kernel-shark-qt: Optimize the search in a case of a small data-set Yordan Karadzhov
2018-11-21 15:14 ` [PATCH 08/11] kernel-shark qt: No error when Record authentication dialog is closed Yordan Karadzhov
2018-11-27 20:45   ` Steven Rostedt
2018-11-21 15:14 ` [PATCH 09/11] kernel-shark-qt: Remove all system=ftrace events from Record dialog Yordan Karadzhov
2018-11-27 23:02 ` [PATCH 00/11] Small modifications and bug fixes toward KS 1.0 Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181127153433.5eee37ac@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=ykaradzhov@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).