From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:53516 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751954AbdFLNoj (ORCPT ); Mon, 12 Jun 2017 09:44:39 -0400 Subject: Patch "arm64: hw_breakpoint: fix watchpoint matching for tagged pointers" has been added to the 4.9-stable tree To: kristina.martsenko@arm.com, catalin.marinas@arm.com, gregkh@linuxfoundation.org, mark.rutland@arm.com, will.deacon@arm.com Cc: , From: Date: Mon, 12 Jun 2017 15:44:29 +0200 In-Reply-To: <1496776450-8731-2-git-send-email-kristina.martsenko@arm.com> Message-ID: <149727506916134@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled arm64: hw_breakpoint: fix watchpoint matching for tagged pointers to the 4.9-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: arm64-hw_breakpoint-fix-watchpoint-matching-for-tagged-pointers.patch and it can be found in the queue-4.9 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From kristina.martsenko@arm.com Mon Jun 12 15:05:21 2017 From: Kristina Martsenko Date: Tue, 6 Jun 2017 20:14:09 +0100 Subject: arm64: hw_breakpoint: fix watchpoint matching for tagged pointers To: stable@vger.kernel.org Cc: Will Deacon , Catalin Marinas Message-ID: <1496776450-8731-2-git-send-email-kristina.martsenko@arm.com> From: Kristina Martsenko commit 7dcd9dd8cebe9fa626af7e2358d03a37041a70fb upstream. This backport has a small difference from the upstream commit: - The address tag is removed in watchpoint_handler() instead of get_distance_from_watchpoint(), because 4.9 does not have commit fdfeff0f9e3d ("arm64: hw_breakpoint: Handle inexact watchpoint addresses"). Original patch description: When we take a watchpoint exception, the address that triggered the watchpoint is found in FAR_EL1. We compare it to the address of each configured watchpoint to see which one was hit. The configured watchpoint addresses are untagged, while the address in FAR_EL1 will have an address tag if the data access was done using a tagged address. The tag needs to be removed to compare the address to the watchpoints. Currently we don't remove it, and as a result can report the wrong watchpoint as being hit (specifically, always either the highest TTBR0 watchpoint or lowest TTBR1 watchpoint). This patch removes the tag. Fixes: d50240a5f6ce ("arm64: mm: permit use of tagged pointers at EL0") Acked-by: Mark Rutland Acked-by: Will Deacon Signed-off-by: Kristina Martsenko Signed-off-by: Catalin Marinas Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/uaccess.h | 6 +++--- arch/arm64/kernel/hw_breakpoint.c | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -105,9 +105,9 @@ static inline void set_fs(mm_segment_t f }) /* - * When dealing with data aborts or instruction traps we may end up with - * a tagged userland pointer. Clear the tag to get a sane pointer to pass - * on to access_ok(), for instance. + * When dealing with data aborts, watchpoints, or instruction traps we may end + * up with a tagged userland pointer. Clear the tag to get a sane pointer to + * pass on to access_ok(), for instance. */ #define untagged_addr(addr) sign_extend64(addr, 55) --- a/arch/arm64/kernel/hw_breakpoint.c +++ b/arch/arm64/kernel/hw_breakpoint.c @@ -36,6 +36,7 @@ #include #include #include +#include /* Breakpoint currently in use for each BRP. */ static DEFINE_PER_CPU(struct perf_event *, bp_on_reg[ARM_MAX_BRP]); @@ -696,7 +697,7 @@ static int watchpoint_handler(unsigned l /* Check if the watchpoint value matches. */ val = read_wb_reg(AARCH64_DBG_REG_WVR, i); - if (val != (addr & ~alignment_mask)) + if (val != (untagged_addr(addr) & ~alignment_mask)) goto unlock; /* Possible match, check the byte address select to confirm. */ Patches currently in stable-queue which might be from kristina.martsenko@arm.com are queue-4.9/arm64-hw_breakpoint-fix-watchpoint-matching-for-tagged-pointers.patch queue-4.9/arm64-entry-improve-data-abort-handling-of-tagged-pointers.patch queue-4.9/arm64-traps-fix-userspace-cache-maintenance-emulation-on-a-tagged-pointer.patch