提交 f088e547 编写于 作者: L Li Zefan 提交者: Ingo Molnar

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: NLi Zefan <lizf@cn.fujitsu.com>
Acked-by: NFrederic 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: NIngo Molnar <mingo@elte.hu>
上级 be9742e6
...@@ -114,24 +114,22 @@ void ksym_hbp_handler(struct hw_breakpoint *hbp, struct pt_regs *regs) ...@@ -114,24 +114,22 @@ void ksym_hbp_handler(struct hw_breakpoint *hbp, struct pt_regs *regs)
* --x : Set Execution Break points (Not available yet) * --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++) { if (str[0] == 'r')
switch (access_str[pos]) { access += 4;
case 'r': else if (str[0] != '-')
access += (pos == 0) ? 4 : -1; return -EINVAL;
break;
case 'w': if (str[1] == 'w')
access += (pos == 1) ? 2 : -1; access += 2;
break; else if (str[1] != '-')
case '-': return -EINVAL;
break;
default: if (str[2] != '-')
return -EINVAL; return -EINVAL;
}
}
switch (access) { switch (access) {
case 6: case 6:
...@@ -140,8 +138,6 @@ static int ksym_trace_get_access_type(char *access_str) ...@@ -140,8 +138,6 @@ static int ksym_trace_get_access_type(char *access_str)
case 2: case 2:
access = HW_BREAKPOINT_WRITE; access = HW_BREAKPOINT_WRITE;
break; break;
case 0:
access = 0;
} }
return access; return access;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册