Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sched: Fix string comparison in /proc/sched_features

Fix incorrect handling of the following case:

INTERACTIVE
INTERACTIVE_SOMETHING_ELSE

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

Changelog since v1:
- Embellish using some Rostedtisms.
[ mingo: ^^ == smaller and cleaner ]

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Cc: <stable@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tony Lindgren <tony@atomide.com>
LKML-Reference: <20100913214700.GB16118@Krystal>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by

Mathieu Desnoyers and committed by
Ingo Molnar
7740191c 637bbdc5

+3 -4
+3 -4
kernel/sched.c
··· 721 721 size_t cnt, loff_t *ppos) 722 722 { 723 723 char buf[64]; 724 - char *cmp = buf; 724 + char *cmp; 725 725 int neg = 0; 726 726 int i; 727 727 ··· 732 732 return -EFAULT; 733 733 734 734 buf[cnt] = 0; 735 + cmp = strstrip(buf); 735 736 736 737 if (strncmp(buf, "NO_", 3) == 0) { 737 738 neg = 1; ··· 740 739 } 741 740 742 741 for (i = 0; sched_feat_names[i]; i++) { 743 - int len = strlen(sched_feat_names[i]); 744 - 745 - if (strncmp(cmp, sched_feat_names[i], len) == 0) { 742 + if (strcmp(cmp, sched_feat_names[i]) == 0) { 746 743 if (neg) 747 744 sysctl_sched_features &= ~(1UL << i); 748 745 else