diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2010-04-21 23:05:45 -0400 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2010-04-30 22:32:07 -0400 |
commit | 73266fc1df2f94cf72b3beba3eee3b88ed0b0664 (patch) | |
tree | 876f6ab9c85715665e5c5562d70d9ea2c10facea | |
parent | d00a47cce569a3e660a8c9de5d57af28d6a9f0f7 (diff) |
hw-breakpoints: Tag ptrace breakpoint as exclude_kernel
Tag ptrace breakpoints with the exclude_kernel attribute set. This
will make it easier to set generic policies on breakpoints, when it
comes to ensure nobody unpriviliged try to breakpoint on the kernel.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Cc: K. Prasad <prasad@linux.vnet.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | arch/sh/kernel/ptrace_32.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/ptrace.c | 2 | ||||
-rw-r--r-- | include/linux/hw_breakpoint.h | 6 |
3 files changed, 8 insertions, 2 deletions
diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c index 7759a9a93211..d4104ce9fe53 100644 --- a/arch/sh/kernel/ptrace_32.c +++ b/arch/sh/kernel/ptrace_32.c | |||
@@ -85,7 +85,7 @@ static int set_single_step(struct task_struct *tsk, unsigned long addr) | |||
85 | 85 | ||
86 | bp = thread->ptrace_bps[0]; | 86 | bp = thread->ptrace_bps[0]; |
87 | if (!bp) { | 87 | if (!bp) { |
88 | hw_breakpoint_init(&attr); | 88 | ptrace_breakpoint_init(&attr); |
89 | 89 | ||
90 | attr.bp_addr = addr; | 90 | attr.bp_addr = addr; |
91 | attr.bp_len = HW_BREAKPOINT_LEN_2; | 91 | attr.bp_len = HW_BREAKPOINT_LEN_2; |
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index 055be0afd330..70c4872cd8aa 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c | |||
@@ -688,7 +688,7 @@ static int ptrace_set_breakpoint_addr(struct task_struct *tsk, int nr, | |||
688 | struct perf_event_attr attr; | 688 | struct perf_event_attr attr; |
689 | 689 | ||
690 | if (!t->ptrace_bps[nr]) { | 690 | if (!t->ptrace_bps[nr]) { |
691 | hw_breakpoint_init(&attr); | 691 | ptrace_breakpoint_init(&attr); |
692 | /* | 692 | /* |
693 | * Put stub len and type to register (reserve) an inactive but | 693 | * Put stub len and type to register (reserve) an inactive but |
694 | * correct bp | 694 | * correct bp |
diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h index c70d27af03f9..a0aa5a9cfb0e 100644 --- a/include/linux/hw_breakpoint.h +++ b/include/linux/hw_breakpoint.h | |||
@@ -34,6 +34,12 @@ static inline void hw_breakpoint_init(struct perf_event_attr *attr) | |||
34 | attr->sample_period = 1; | 34 | attr->sample_period = 1; |
35 | } | 35 | } |
36 | 36 | ||
37 | static inline void ptrace_breakpoint_init(struct perf_event_attr *attr) | ||
38 | { | ||
39 | hw_breakpoint_init(attr); | ||
40 | attr->exclude_kernel = 1; | ||
41 | } | ||
42 | |||
37 | static inline unsigned long hw_breakpoint_addr(struct perf_event *bp) | 43 | static inline unsigned long hw_breakpoint_addr(struct perf_event *bp) |
38 | { | 44 | { |
39 | return bp->attr.bp_addr; | 45 | return bp->attr.bp_addr; |