public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched: fix strncmp operation
@ 2011-01-06 12:58 Hillf Danton
  2011-01-06 23:47 ` Andrew Morton
  2011-01-07 15:37 ` [tip:sched/urgent] sched: Fix " tip-bot for Hillf Danton
  0 siblings, 2 replies; 4+ messages in thread
From: Hillf Danton @ 2011-01-06 12:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: Rik van Riel, Peter Zijlstra, Mike Galbraith

One of the operands, buf, is incorrect, since it is stripped and the
correct address for subsequent string comparing could change if
leading white spaces, if any, are removed from buf.

It is fixed by replacing buf with cmp.

Signed-off-by: Hillf Danton <dhillf@gmail.com>
---

--- a/kernel/sched.c	2010-11-01 19:54:12.000000000 +0800
+++ b/kernel/sched.c	2011-01-06 20:52:02.000000000 +0800
@@ -751,7 +751,7 @@ sched_feat_write(struct file *filp, cons
 	buf[cnt] = 0;
 	cmp = strstrip(buf);

-	if (strncmp(buf, "NO_", 3) == 0) {
+	if (strncmp(cmp, "NO_", 3) == 0) {
 		neg = 1;
 		cmp += 3;
 	}

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

* Re: [PATCH] sched: fix strncmp operation
  2011-01-06 12:58 [PATCH] sched: fix strncmp operation Hillf Danton
@ 2011-01-06 23:47 ` Andrew Morton
  2011-01-08  4:14   ` Hillf Danton
  2011-01-07 15:37 ` [tip:sched/urgent] sched: Fix " tip-bot for Hillf Danton
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2011-01-06 23:47 UTC (permalink / raw)
  To: Hillf Danton; +Cc: linux-kernel, Rik van Riel, Peter Zijlstra, Mike Galbraith

On Thu, 6 Jan 2011 20:58:12 +0800
Hillf Danton <dhillf@gmail.com> wrote:

> One of the operands, buf, is incorrect, since it is stripped and the
> correct address for subsequent string comparing could change if
> leading white spaces, if any, are removed from buf.
> 
> It is fixed by replacing buf with cmp.
> 
> Signed-off-by: Hillf Danton <dhillf@gmail.com>
> ---
> 
> --- a/kernel/sched.c	2010-11-01 19:54:12.000000000 +0800
> +++ b/kernel/sched.c	2011-01-06 20:52:02.000000000 +0800
> @@ -751,7 +751,7 @@ sched_feat_write(struct file *filp, cons
>  	buf[cnt] = 0;
>  	cmp = strstrip(buf);
> 
> -	if (strncmp(buf, "NO_", 3) == 0) {
> +	if (strncmp(cmp, "NO_", 3) == 0) {
>  		neg = 1;
>  		cmp += 3;
>  	}

Just remove the strstrip(), I'd say.  The kernel practically never
strips leading whitespace from sysfs input, so why do it here? 



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

* [tip:sched/urgent] sched: Fix strncmp operation
  2011-01-06 12:58 [PATCH] sched: fix strncmp operation Hillf Danton
  2011-01-06 23:47 ` Andrew Morton
@ 2011-01-07 15:37 ` tip-bot for Hillf Danton
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Hillf Danton @ 2011-01-07 15:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, dhillf, a.p.zijlstra, tglx, mingo

Commit-ID:  524429c31b486c05449666b94613f59f729c0a84
Gitweb:     http://git.kernel.org/tip/524429c31b486c05449666b94613f59f729c0a84
Author:     Hillf Danton <dhillf@gmail.com>
AuthorDate: Thu, 6 Jan 2011 20:58:12 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Fri, 7 Jan 2011 15:55:10 +0100

sched: Fix strncmp operation

One of the operands, buf, is incorrect, since it is stripped and the
correct address for subsequent string comparing could change if
leading white spaces, if any, are removed from buf.

It is fixed by replacing buf with cmp.

Signed-off-by: Hillf Danton <dhillf@gmail.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <AANLkTinOPuYsVovrZpbuCCmG5deEyc8WgA_A1RJx_YK7@mail.gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/sched.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index a8478a2..a0eb094 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -741,7 +741,7 @@ sched_feat_write(struct file *filp, const char __user *ubuf,
 	buf[cnt] = 0;
 	cmp = strstrip(buf);
 
-	if (strncmp(buf, "NO_", 3) == 0) {
+	if (strncmp(cmp, "NO_", 3) == 0) {
 		neg = 1;
 		cmp += 3;
 	}

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

* Re: [PATCH] sched: fix strncmp operation
  2011-01-06 23:47 ` Andrew Morton
@ 2011-01-08  4:14   ` Hillf Danton
  0 siblings, 0 replies; 4+ messages in thread
From: Hillf Danton @ 2011-01-08  4:14 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Rik van Riel, Peter Zijlstra, Mike Galbraith

On Fri, Jan 7, 2011 at 7:47 AM, Andrew Morton <akpm@linux-foundation.org> wrote:
> Just remove the strstrip(), I'd say.  The kernel practically never
> strips leading whitespace from sysfs input, so why do it here?
>

Would you please, Andrew, take another glance at the patch for
replacing ida in workqueue?

              https://lkml.org/lkml/2010/12/18/35

thanks
Hillf

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

end of thread, other threads:[~2011-01-08  4:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-06 12:58 [PATCH] sched: fix strncmp operation Hillf Danton
2011-01-06 23:47 ` Andrew Morton
2011-01-08  4:14   ` Hillf Danton
2011-01-07 15:37 ` [tip:sched/urgent] sched: Fix " tip-bot for Hillf Danton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox