summaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_ksym.c
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2009-07-07 13:53:18 +0800
committerIngo Molnar <mingo@elte.hu>2009-07-10 11:59:41 +0200
commitf088e5471297cc78d7465e1fd997cb1a91a48019 (patch)
treef3e03e2cf1a83621b9005ff72298845791160e6b /kernel/trace/trace_ksym.c
parentbe9742e6cb107fe1d77db7a081ea4eb25e79e1ad (diff)
ksym_tracer: Fix validation of access type
# echo 'pid_max:rw-' > ksym_trace_filter # cat ksym_trace_filter pid_max:rw- # echo 'pid_max:ww-' > ksym_trace_filter (should return -EINVAL) # cat ksym_trace_filter (but it ended up removing filter entry) Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: "K.Prasad" <prasad@linux.vnet.ibm.com> Cc: Alan Stern <stern@rowland.harvard.edu> Cc: Steven Rostedt <rostedt@goodmis.org> LKML-Reference: <4A52E2CE.6080409@cn.fujitsu.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace_ksym.c')
-rw-r--r--kernel/trace/trace_ksym.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/kernel/trace/trace_ksym.c b/kernel/trace/trace_ksym.c
index b6710d31bdf..95560092990 100644
--- a/kernel/trace/trace_ksym.c
+++ b/kernel/trace/trace_ksym.c
@@ -114,24 +114,22 @@ void ksym_hbp_handler(struct hw_breakpoint *hbp, struct pt_regs *regs)
* --x : Set Execution Break points (Not available yet)
*
*/
-static int ksym_trace_get_access_type(char *access_str)
+static int ksym_trace_get_access_type(char *str)
{
- int pos, access = 0;
+ int access = 0;
- for (pos = 0; pos < KSYM_TRACER_OP_LEN; pos++) {
- switch (access_str[pos]) {
- case 'r':
- access += (pos == 0) ? 4 : -1;
- break;
- case 'w':
- access += (pos == 1) ? 2 : -1;
- break;
- case '-':
- break;
- default:
- return -EINVAL;
- }
- }
+ if (str[0] == 'r')
+ access += 4;
+ else if (str[0] != '-')
+ return -EINVAL;
+
+ if (str[1] == 'w')
+ access += 2;
+ else if (str[1] != '-')
+ return -EINVAL;
+
+ if (str[2] != '-')
+ return -EINVAL;
switch (access) {
case 6:
@@ -140,8 +138,6 @@ static int ksym_trace_get_access_type(char *access_str)
case 2:
access = HW_BREAKPOINT_WRITE;
break;
- case 0:
- access = 0;
}
return access;