lkml.org 
[lkml]   [2010]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[RFC PATCH 01/11] sched: fix string comparison in features
Incorrect handling of the following case:

INTERACTIVE
INTERACTIVE_SOMETHING_ELSE

The comparison only checks up to each element's length.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
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;
- 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;
+ }
+ }

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]);

+ if (cmplen != len)
+ continue;
if (strncmp(cmp, sched_feat_names[i], len) == 0) {
if (neg)
sysctl_sched_features &= ~(1UL << i);


\
 
 \ /
  Last update: 2010-08-26 20:17    [W:0.164 / U:3.068 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site