From patchwork Thu Jun 6 12:53:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 10979503 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 69E2014C0 for ; Thu, 6 Jun 2019 12:54:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55A8A2886C for ; Thu, 6 Jun 2019 12:54:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45D7E2886F; Thu, 6 Jun 2019 12:54:19 +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 E1BEF288AC for ; Thu, 6 Jun 2019 12:54:18 +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=jZ4rOamCus4fT03RJYaylKUcQXOaRUj6BbU84UE7CVY=; b=JS8 VnADHhJBv+ML7ROH8uYqTkAuFZfN3B+0XM2HZgOB2HaMvKKtU1+yY4oet0t720whxmfL1MkWshJeg Esdru8mOAetH06fNDA8ZlYUBazmMfb0tCGx9BHuSJXE+GPXCBvjv4VXMrb74RdCBxFLLGCher7N8C 3iM5ZRQh+619+fdixLWUXrNUwMDsqkiVhaOcjpFRhLMaaSSeXkVxP2LklJo9YhTz+TJk4m8fkgoRn BJ4qCBnD0XOehygRUEuVGMwWj8a7nRf9R7p4H4A1UvYgma4osrWoMFKoVrWtYDiutXkwf2TRCFCr1 ++mUoZgHystefv7DqkoCNBMUMI+fq/g==; 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 1hYruI-0002Ug-If; Thu, 06 Jun 2019 12:54:14 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hYruG-0002UC-2y for linux-arm-kernel@lists.infradead.org; Thu, 06 Jun 2019 12:54:13 +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 49C1B374; Thu, 6 Jun 2019 05:54:11 -0700 (PDT) Received: from lakrids.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 E604D3F5AF; Thu, 6 Jun 2019 05:54:09 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 0/3] arm64: stacktrace: improve robustness Date: Thu, 6 Jun 2019 13:53:59 +0100 Message-Id: <20190606125402.10229-1-mark.rutland@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-20190606_055412_131755_7373FC64 X-CRM114-Status: GOOD ( 12.12 ) 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, tengfeif@codeaurora.org, catalin.marinas@arm.com, will.deacon@arm.com, james.morse@arm.com, dave.martin@arm.com 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 The arm64 stacktrace code is careful to only access valid stack locations, but in the presence of a corrupted stack where frame records form a loop, it will never terminate. This series updates the stacktrace code to terminate in finite time even when a stack is corrupted. A stacktrace will be terminated if the next record is at a lower (or equal) address on the current stack, or when the next record is on a stack we've already completed unwinding. The first couple of patches come from Dave's prior attempt to fix this [1], with the final patch relying on infrastructure which has been introduced in the mean time. I've given this a quick spin with magic-sysrq L in a KVM guest, and things look fine, but further testing would be appreciated. This series (based on v5.2-rc1) can also be found in my arm64/robust-stracktrace branch on kernel.org [2]. Thanks, Mark. [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2018-April/572685.html [2] git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git arm64/robust-stacktrace Dave Martin (2): arm64: stacktrace: Constify stacktrace.h functions arm64: stacktrace: Factor out backtrace initialisation Mark Rutland (1): arm64: stacktrace: better handle corrupted stacks arch/arm64/include/asm/stacktrace.h | 55 ++++++++++++++++++++++++++++--------- arch/arm64/kernel/process.c | 6 +--- arch/arm64/kernel/stacktrace.c | 16 ++++++++++- arch/arm64/kernel/time.c | 6 +--- arch/arm64/kernel/traps.c | 13 ++++----- 5 files changed, 65 insertions(+), 31 deletions(-)