From patchwork Fri Mar 1 13:27:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 10835333 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8747E1390 for ; Fri, 1 Mar 2019 13:28:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73E2D2EE31 for ; Fri, 1 Mar 2019 13:28:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67B3A2F72C; Fri, 1 Mar 2019 13:28:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1746D2EE31 for ; Fri, 1 Mar 2019 13:28:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=I0vTSgmrmIWp9Pr9Vd3QESZ60M8DRUx9h6wGm6ZZ6eM=; b=h0k Bk3ZwQI3y8vF9WbMVm8h4j0vubw7k7YSNUA/nfpJRVqshzHn6KnkpIcvOCeT0Z2mfn76ciegghQ0Q nQnXzUtnYKxZv3AjOzJm+E8telW7PBYeTzXvQ21HIAAAUlpBYVX3a7HkDniPtYTAVeWbDPyOfM8MZ OgYVSdzdCZTbsbPAwqyCqfFFbdLUZOYpxEy5pFYU6DseIjuj0LdSl8qDfwiMhCwU0XIIvw8PeJf2E SmGvlS9nRyFrRG4oQcJHPIDJqrcZNZa0RAXq0CsB0p6H5QkUwhPGFYgQthMu7qj3TVMDtU60Tx3fy EBnEoIWNaBY/UTIcB90XZz+t+dT/iIw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gziDD-0005YR-Nb; Fri, 01 Mar 2019 13:28:27 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gziD3-0005Nz-8e for linux-arm-kernel@lists.infradead.org; Fri, 01 Mar 2019 13:28:18 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0A4FCA78; Fri, 1 Mar 2019 05:28:15 -0800 (PST) Received: from fuggles.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1A8CD3F5C1; Fri, 1 Mar 2019 05:28:13 -0800 (PST) From: Will Deacon To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 00/10] Rework debug exception handling code Date: Fri, 1 Mar 2019 13:27:59 +0000 Message-Id: <20190301132809.24653-1-will.deacon@arm.com> X-Mailer: git-send-email 2.11.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190301_052817_308369_A6C35B4E X-CRM114-Status: UNSURE ( 9.48 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, Will Deacon MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi all, Our debug exception handling code is a bit of a horror show. Userspace can trigger kprobe logic to run (which ends up just returning back to the brk instruction instead of delivering a SIGTRAP) and can also enter KGDB if it is enabled (which causes a kernel panic due to a NULL dereference). These patch fix those problems and tidy up the code so that they're less likely to happen again in future. Will --->8 Will Deacon (10): arm64: debug: Don't propagate UNKNOWN FAR into si_code for debug signals arm64: debug: Ensure debug handlers check triggering exception level arm64: debug: Remove unused return value from do_debug_exception() arm64: debug: Rename addr parameter for non-watchpoint exception hooks arm64: debug: Remove meaningless comment arm64: debug: Separate debug hooks based on target exception level arm64: kprobes: Avoid calling kprobes debug handlers explicitly arm64: debug: Remove redundant user_mode(regs) checks from debug handlers arm64: probes: Move magic BRK values into brk-imm.h arm64: debug: Clean up brk_handler() arch/arm64/include/asm/brk-imm.h | 4 ++ arch/arm64/include/asm/debug-monitors.h | 24 +++---- arch/arm64/include/asm/esr.h | 4 +- arch/arm64/include/asm/kprobes.h | 2 - arch/arm64/kernel/debug-monitors.c | 111 ++++++++++++++++++-------------- arch/arm64/kernel/kgdb.c | 28 ++++---- arch/arm64/kernel/probes/kprobes.c | 16 ++++- arch/arm64/kernel/probes/uprobes.c | 19 ++---- arch/arm64/kernel/traps.c | 21 ++---- arch/arm64/mm/fault.c | 19 ++---- 10 files changed, 127 insertions(+), 121 deletions(-)