hw-breakpoints: Tag ptrace breakpoint as exclude_kernel
authorFrederic Weisbecker <fweisbec@gmail.com>
Thu, 22 Apr 2010 03:05:45 +0000 (05:05 +0200)
committerFrederic Weisbecker <fweisbec@gmail.com>
Sat, 1 May 2010 02:32:07 +0000 (04:32 +0200)
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>
arch/sh/kernel/ptrace_32.c
arch/x86/kernel/ptrace.c
include/linux/hw_breakpoint.h

index 7759a9a93211279d8df3a3d4217b7d723146a195..d4104ce9fe53c8a01fc354c41e0d57c5359a1d68 100644 (file)
@@ -85,7 +85,7 @@ static int set_single_step(struct task_struct *tsk, unsigned long addr)
 
        bp = thread->ptrace_bps[0];
        if (!bp) {
-               hw_breakpoint_init(&attr);
+               ptrace_breakpoint_init(&attr);
 
                attr.bp_addr = addr;
                attr.bp_len = HW_BREAKPOINT_LEN_2;
index 055be0afd3305788c6fa529eb17cdfa1958a0a80..70c4872cd8aa0cc5a21cd3d7b1d9b8cc9a2575fb 100644 (file)
@@ -688,7 +688,7 @@ static int ptrace_set_breakpoint_addr(struct task_struct *tsk, int nr,
        struct perf_event_attr attr;
 
        if (!t->ptrace_bps[nr]) {
-               hw_breakpoint_init(&attr);
+               ptrace_breakpoint_init(&attr);
                /*
                 * Put stub len and type to register (reserve) an inactive but
                 * correct bp
index c70d27af03f9f081c4a434151f7634bb5eceb93a..a0aa5a9cfb0eebe890f8c84ea37f33d84b60ff91 100644 (file)
@@ -34,6 +34,12 @@ static inline void hw_breakpoint_init(struct perf_event_attr *attr)
        attr->sample_period = 1;
 }
 
+static inline void ptrace_breakpoint_init(struct perf_event_attr *attr)
+{
+       hw_breakpoint_init(attr);
+       attr->exclude_kernel = 1;
+}
+
 static inline unsigned long hw_breakpoint_addr(struct perf_event *bp)
 {
        return bp->attr.bp_addr;