Skip to content

Commit 27747f8

Browse files
amlutoIngo Molnar
authored andcommitted
perf/x86/hw_breakpoints: Fix check for kernel-space breakpoints
The check looked wrong, although I think it was actually safe. TASK_SIZE is unnecessarily small for compat tasks, and it wasn't possible to make a range breakpoint so large it started in user space and ended in kernel space. Nonetheless, let's fix up the check for the benefit of future readers. A breakpoint is in the kernel if either end is in the kernel. Signed-off-by: Andy Lutomirski <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/136be387950e78f18cea60e9d1bef74465d0ee8f.1438312874.git.luto@kernel.org Signed-off-by: Ingo Molnar <[email protected]>
1 parent ab51392 commit 27747f8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

arch/x86/kernel/hw_breakpoint.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ int arch_check_bp_in_kernelspace(struct perf_event *bp)
180180
va = info->address;
181181
len = bp->attr.bp_len;
182182

183-
return (va >= TASK_SIZE) && ((va + len - 1) >= TASK_SIZE);
183+
/*
184+
* We don't need to worry about va + len - 1 overflowing:
185+
* we already require that va is aligned to a multiple of len.
186+
*/
187+
return (va >= TASK_SIZE_MAX) || ((va + len - 1) >= TASK_SIZE_MAX);
184188
}
185189

186190
int arch_bp_generic_fields(int x86_len, int x86_type,

0 commit comments

Comments
 (0)