Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932333AbbHDIzu (ORCPT ); Tue, 4 Aug 2015 04:55:50 -0400 Received: from terminus.zytor.com ([198.137.202.10]:50093 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755845AbbHDIzn (ORCPT ); Tue, 4 Aug 2015 04:55:43 -0400 Date: Tue, 4 Aug 2015 01:54:55 -0700 From: tip-bot for Andy Lutomirski Message-ID: Cc: peterz@infradead.org, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, hpa@zytor.com, tglx@linutronix.de, rostedt@goodmis.org, luto@kernel.org, masami.hiramatsu.pt@hitachi.com, brgerst@gmail.com, mingo@kernel.org, bp@alien8.de Reply-To: brgerst@gmail.com, mingo@kernel.org, bp@alien8.de, torvalds@linux-foundation.org, hpa@zytor.com, peterz@infradead.org, linux-kernel@vger.kernel.org, masami.hiramatsu.pt@hitachi.com, luto@kernel.org, rostedt@goodmis.org, tglx@linutronix.de In-Reply-To: <136be387950e78f18cea60e9d1bef74465d0ee8f.1438312874.git.luto@kernel.org> References: <136be387950e78f18cea60e9d1bef74465d0ee8f.1438312874.git.luto@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf/x86/hw_breakpoints: Fix check for kernel-space breakpoints Git-Commit-ID: 27747f8bc355a2808ca9e490ab6866acd85b4c16 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2275 Lines: 55 Commit-ID: 27747f8bc355a2808ca9e490ab6866acd85b4c16 Gitweb: http://git.kernel.org/tip/27747f8bc355a2808ca9e490ab6866acd85b4c16 Author: Andy Lutomirski AuthorDate: Thu, 30 Jul 2015 20:32:42 -0700 Committer: Ingo Molnar CommitDate: Tue, 4 Aug 2015 10:16:55 +0200 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 Signed-off-by: Peter Zijlstra (Intel) Cc: Borislav Petkov Cc: Brian Gerst Cc: Linus Torvalds Cc: Masami Hiramatsu Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/136be387950e78f18cea60e9d1bef74465d0ee8f.1438312874.git.luto@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/kernel/hw_breakpoint.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c index 6f345d3..50a3fad 100644 --- a/arch/x86/kernel/hw_breakpoint.c +++ b/arch/x86/kernel/hw_breakpoint.c @@ -180,7 +180,11 @@ int arch_check_bp_in_kernelspace(struct perf_event *bp) va = info->address; len = bp->attr.bp_len; - return (va >= TASK_SIZE) && ((va + len - 1) >= TASK_SIZE); + /* + * We don't need to worry about va + len - 1 overflowing: + * we already require that va is aligned to a multiple of len. + */ + return (va >= TASK_SIZE_MAX) || ((va + len - 1) >= TASK_SIZE_MAX); } int arch_bp_generic_fields(int x86_len, int x86_type, -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/