From patchwork Tue Jul 10 03:04:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 10516071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D42A1601D4 for ; Tue, 10 Jul 2018 03:05:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A671528BD3 for ; Tue, 10 Jul 2018 03:05:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81F2328BDF; Tue, 10 Jul 2018 03:05:10 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI 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 05F0528BD3 for ; Tue, 10 Jul 2018 03:05:09 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:Message-ID: In-Reply-To:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UqIdjS9crhbtZ48sP6ztveIT649BzzWElbFPQdMwR/E=; b=VEfwDgWXvzx7ug UXAJHxxAGU0Q9FXSzxIqkeQ//sKMjuKSjcz042eP0g5jisnRC4rAVf3ojvkvutWiezHxgQ6vkTsMA FYuFzrzJy99ZZy/4oU2NBKxS3DJ0TYTcwzrnphDNQtVlTJiscpQUnDFhqS+KjmMouD9ddVlXhUpdk /kbYgmjxnSJqKPaoG0JviV5qHt8ObnqPiejRqFTiJfDDBqfBA4b/qKvnHay39W/HoQLDB2PBU6NXj N5/N++DI+F8RDcKZ13fNQblfUbwBNYK7WLfwhzSwN8Gz6yfgl+Y6yLbItGWZxIXgBwJ2JK0AmIeeT mLTwnUHAQ7ZgR6CuX3ag==; 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 1fcixe-00087W-UM; Tue, 10 Jul 2018 03:05:06 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fcixe-0007lo-2I for linux-arm-kernel@bombadil.infradead.org; Tue, 10 Jul 2018 03:05:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: Message-ID:In-Reply-To:Subject:cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=hY+VhjeZeB7qAINbaizF/lU4Fh49R//mUpfebokCl6Q=; b=aBzo3G7jJp1cfB+LH9NCpIWHX qXhPs7UoR36YV8pRNj6mqI6WXll1B1cdevzbtCYq9JebMYfvjTHhmnynKPI5lnHQH1WnIgIeZY7zU QspUjKD+jWfXwmKRJyCiukCSnYvvLnATnS3DMCzA9dRuYl/XufD0apqz1ZQJijEaergqmTKrjvC8S rn8mtOQn6vXIYxdS7TaPwL26Cgf3bgwFMk1HjKFK4pmtX338E4CD3tO1ABxCFFs2Yj/1Cwxch07rA CwJEKsmWFvvrPfPPUNvB7pcRl4D4tBhoGAobUCjMoneAgjWXbP3BeSmBvNDjEqry0bp4cZv66LzA0 HjwI8iBfQ==; Received: from mx3-rdu2.redhat.com ([66.187.233.73] helo=mx1.redhat.com) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fcixb-0005bN-6O for linux-arm-kernel@lists.infradead.org; Tue, 10 Jul 2018 03:05:04 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1AECE808255B; Tue, 10 Jul 2018 03:04:34 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 09F5D2026D65; Tue, 10 Jul 2018 03:04:33 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id w6A34X4I025089; Mon, 9 Jul 2018 23:04:33 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id w6A34Xmg025084; Mon, 9 Jul 2018 23:04:33 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Mon, 9 Jul 2018 23:04:33 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Dave Martin Subject: Re: [PATCH] arm64: fix infinite stacktrace In-Reply-To: <20180628164900.GB26019@e103592.cambridge.arm.com> Message-ID: References: <20180615115823.2oq5d7amzwlliczg@lakrids.cambridge.arm.com> <20180627164150.GB8729@arm.com> <20180628164900.GB26019@e103592.cambridge.arm.com> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 10 Jul 2018 03:04:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 10 Jul 2018 03:04:34 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mpatocka@redhat.com' RCPT:'' X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180709_230503_310726_D4F4F787 X-CRM114-Status: GOOD ( 36.32 ) 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 , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org 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 On Thu, 28 Jun 2018, Dave Martin wrote: > On Wed, Jun 27, 2018 at 05:41:51PM +0100, Will Deacon wrote: > > Hi all, > > > > On Fri, Jun 15, 2018 at 12:58:23PM +0100, Mark Rutland wrote: > > > On Thu, Jun 14, 2018 at 02:58:21PM -0400, Mikulas Patocka wrote: > > > > I've got this infinite stacktrace when debugging another problem: > > > > [ 908.795225] INFO: rcu_preempt detected stalls on CPUs/tasks: > > > > [ 908.796176] 1-...!: (1 GPs behind) idle=952/1/4611686018427387904 softirq=1462/1462 fqs=355 > > > > [ 908.797692] 2-...!: (1 GPs behind) idle=f42/1/4611686018427387904 softirq=1550/1551 fqs=355 > > > > [ 908.799189] (detected by 0, t=2109 jiffies, g=130, c=129, q=235) > > > > [ 908.800284] Task dump for CPU 1: > > > > [ 908.800871] kworker/1:1 R running task 0 32 2 0x00000022 > > > > [ 908.802127] Workqueue: writecache-writeabck writecache_writeback [dm_writecache] > > > > [ 908.820285] Call trace: > > > > [ 908.824785] __switch_to+0x68/0x90 > > > > [ 908.837661] 0xfffffe00603afd90 > > > > [ 908.844119] 0xfffffe00603afd90 > > > > [ 908.850091] 0xfffffe00603afd90 > > > > [ 908.854285] 0xfffffe00603afd90 > > > > [ 908.863538] 0xfffffe00603afd90 > > > > [ 908.865523] 0xfffffe00603afd90 > > > > > > > > The machine just locked up and kept on printing the same line over and > > > > over again. This patch fixes it. > > > > > > > > Signed-off-by: Mikulas Patocka > > > > Cc: stable@vger.kernel.org > > > > > > Given this can only occur when there's a corrupted stack (where a frame > > > record points to itself), I'm not sure this requires a cc stable. > > > > > > > Index: linux-2.6/arch/arm64/kernel/stacktrace.c > > > > =================================================================== > > > > --- linux-2.6.orig/arch/arm64/kernel/stacktrace.c > > > > +++ linux-2.6/arch/arm64/kernel/stacktrace.c > > > > @@ -56,6 +56,9 @@ int notrace unwind_frame(struct task_str > > > > frame->fp = READ_ONCE_NOCHECK(*(unsigned long *)(fp)); > > > > frame->pc = READ_ONCE_NOCHECK(*(unsigned long *)(fp + 8)); > > > > > > > > + if (frame->fp <= fp) > > > > + return -EINVAL; > > > > + > > > > > > Dave Martin had a series [1] which addressed this along with a number of > > > other cases where stack traces might not terminate. > > > > > > Dave, do you plan to respin that? > > > > I'd be interested in an update on that; we clearly should be fixing this in > > one way or another. > > > > Mikulus -- would you be able to test and/or review it, please? > > My patch was arguably over-engineered, and broken in some way connected > with SDEI. Unfortunately I've had too much other stuff to do... > > I could take another look, but it may take time to get to it. > > Alternatively, if someone wants to pick up my patch and take it forward, > I'm happy to comment. > > Cheers > ---Dave Or - what about this patch? It doesn't guarantee that infinite loop won't happen, but it at least catches the most obvious loop on the same address. From: Mikulas Patocka Subject: [PATCH] arm64: fix infinite stacktrace I've got this infinite stacktrace when debugging another problem: [ 908.795225] INFO: rcu_preempt detected stalls on CPUs/tasks: [ 908.796176] 1-...!: (1 GPs behind) idle=952/1/4611686018427387904 softirq=1462/1462 fqs=355 [ 908.797692] 2-...!: (1 GPs behind) idle=f42/1/4611686018427387904 softirq=1550/1551 fqs=355 [ 908.799189] (detected by 0, t=2109 jiffies, g=130, c=129, q=235) [ 908.800284] Task dump for CPU 1: [ 908.800871] kworker/1:1 R running task 0 32 2 0x00000022 [ 908.802127] Workqueue: writecache-writeabck writecache_writeback [dm_writecache] [ 908.820285] Call trace: [ 908.824785] __switch_to+0x68/0x90 [ 908.837661] 0xfffffe00603afd90 [ 908.844119] 0xfffffe00603afd90 [ 908.850091] 0xfffffe00603afd90 [ 908.854285] 0xfffffe00603afd90 [ 908.863538] 0xfffffe00603afd90 [ 908.865523] 0xfffffe00603afd90 The machine just locked up and kept on printing the same line over and over again. This patch fixes it. Signed-off-by: Mikulas Patocka Cc: stable@vger.kernel.org --- arch/arm64/kernel/stacktrace.c | 3 +++ 1 file changed, 3 insertions(+) Index: linux-2.6/arch/arm64/kernel/stacktrace.c =================================================================== --- linux-2.6.orig/arch/arm64/kernel/stacktrace.c 2018-07-10 05:01:56.990000000 +0200 +++ linux-2.6/arch/arm64/kernel/stacktrace.c 2018-07-10 05:02:51.650000000 +0200 @@ -56,6 +56,9 @@ int notrace unwind_frame(struct task_str frame->fp = READ_ONCE_NOCHECK(*(unsigned long *)(fp)); frame->pc = READ_ONCE_NOCHECK(*(unsigned long *)(fp + 8)); + if (frame->fp == fp) + return -EINVAL; + #ifdef CONFIG_FUNCTION_GRAPH_TRACER if (tsk->ret_stack && (frame->pc == (unsigned long)return_to_handler)) {