aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorMathias Krause <minipli@googlemail.com>2013-07-03 18:05:39 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 19:07:46 -0400
commit10fb46d5f79147620d0afda7d3d51302a1e38191 (patch)
treeb8f6aa6f5c53b9166521bb66e6a8886014889448 /kernel
parentca75b4d8799d46842350596fdc5fce7711610326 (diff)
kprobes: handle empty/invalid input to debugfs "enabled" file
When writing invalid input to 'debug/kprobes/enabled' it'll silently be ignored. Even worse, when writing an empty string to this file, the outcome is purely random as the switch statement will make its decision based on the value of an uninitialized stack variable. Fix this by handling invalid/empty input as error returning -EINVAL. Signed-off-by: Mathias Krause <minipli@googlemail.com> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kprobes.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index bddf3b201a48..6e33498d665c 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -2332,6 +2332,7 @@ static ssize_t write_enabled_file_bool(struct file *file,
2332 if (copy_from_user(buf, user_buf, buf_size)) 2332 if (copy_from_user(buf, user_buf, buf_size))
2333 return -EFAULT; 2333 return -EFAULT;
2334 2334
2335 buf[buf_size] = '\0';
2335 switch (buf[0]) { 2336 switch (buf[0]) {
2336 case 'y': 2337 case 'y':
2337 case 'Y': 2338 case 'Y':
@@ -2343,6 +2344,8 @@ static ssize_t write_enabled_file_bool(struct file *file,
2343 case '0': 2344 case '0':
2344 disarm_all_kprobes(); 2345 disarm_all_kprobes();
2345 break; 2346 break;
2347 default:
2348 return -EINVAL;
2346 } 2349 }
2347 2350
2348 return count; 2351 return count;