public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@elte.hu>, Tony Lindgren <tony@atomide.com>
Subject: Re: [PATCH] sched: fix string comparison in features
Date: Mon, 13 Sep 2010 17:34:32 -0400	[thread overview]
Message-ID: <1284413672.5701.12.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <20100911174400.GA13462@Krystal>

On Sat, 2010-09-11 at 13:44 -0400, Mathieu Desnoyers wrote:
> Incorrect handling of the following case:
> 
> INTERACTIVE
> INTERACTIVE_SOMETHING_ELSE
> 
> The comparison only checks up to each element's length.

Replace all your changes with mine, and you have the same effect ;-)

-- Steve

> 
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> ---
>  kernel/sched.c |   11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> Index: linux-2.6-lttng.git/kernel/sched.c
> ===================================================================
> --- linux-2.6-lttng.git.orig/kernel/sched.c
> +++ linux-2.6-lttng.git/kernel/sched.c
> @@ -722,7 +722,7 @@ sched_feat_write(struct file *filp, cons
>  {
>  	char buf[64];
>  	char *cmp = buf;

-	char *cmp = buf;
+	char *cmp;

> -	int neg = 0;
> +	int neg = 0, cmplen;
>  	int i;
>  
>  	if (cnt > 63)
> @@ -732,15 +732,24 @@ sched_feat_write(struct file *filp, cons
>  		return -EFAULT;
>  
>  	buf[cnt] = 0;
> +	for (i = 0; i < cnt; i++) {
> +		if (buf[i] == '\n' || buf[i] == ' ') {
> +			buf[i] = 0;
> +			break;
> +		}
> +	}

+	cmp = strstrip(buf);

>  
>  	if (strncmp(buf, "NO_", 3) == 0) {
>  		neg = 1;
>  		cmp += 3;
>  	}
>  
> +	cmplen = strlen(cmp);
>  	for (i = 0; sched_feat_names[i]; i++) {
>  		int len = strlen(sched_feat_names[i]);

-		int len = strlen(sched_feat_names[i]);

>  
> +		if (cmplen != len)
> +			continue;
>  		if (strncmp(cmp, sched_feat_names[i], len) == 0) {

-		if (strncmp(cmp, sched_feat_names[i], len) == 0) {
+		if (strcmp(cmp, sched_feat_names[i]) == 0) {

>  			if (neg)
>  				sysctl_sched_features &= ~(1UL << i);



  reply	other threads:[~2010-09-13 21:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-11 17:44 [PATCH] sched: fix string comparison in features Mathieu Desnoyers
2010-09-13 21:34 ` Steven Rostedt [this message]
2010-09-13 21:40   ` Mathieu Desnoyers

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=1284413672.5701.12.camel@gandalf.stny.rr.com \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=tony@atomide.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