From patchwork Thu Jul 30 20:51:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 11693675 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D96131392 for ; Thu, 30 Jul 2020 20:53:11 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AF07B20829 for ; Thu, 30 Jul 2020 20:53:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QdKFNMHI"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="ViS1JlQV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF07B20829 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7GL3SsTtpUepldMSwSKf9aPPqqkKAXG5etthZtGSQ2w=; b=QdKFNMHIZxGt51Uj4JoVQgGSf PUG3tJibR0yjXkT9DWVTTpYItqo0qgFJxiZTA0ospQvbw77UBgy21MpjXOTnFNSyUYt+5Mhi8atF0 gOazumTSCGfvVNtB9Muw+hSnI2JkYna7JUcoA4jlb7WbX5pC0YukH6Qde1fuJGXUjzJUVVC5HdPRv 6htckZ3gEZ4NIei2r6P+q/j5ZCUGnZqmiNE9+/yhmGKmdVK1bE3yaEOuA8N3THXBrKS6znMM4YRq2 BR6BFefxWYg/N8YZ3I0lICj0X+qNmw0YBh8PwQWZDM1k7+fJ5tLQ69g1MRKmVx2ioVUX88OseoxOW ejOOvld0A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1FWZ-0004gg-6R; Thu, 30 Jul 2020 20:51:35 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1FWU-0004dy-4s for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 20:51:30 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id t203so2766868yba.11 for ; Thu, 30 Jul 2020 13:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=G95KKuekTz1iA7Zr8ZdyT9EdDFTvRs8dYtvTVOv4Dfc=; b=ViS1JlQVeIZx1+sasiczEhUQiJqT9BJ3+cGlNfVvdmsU9R2mLheJZdbOTUgKPav/+p 5pdrAapxvRSoKlz+chL0Gy18OCbJssl+aqaycS4dtpZekMdniwmfHSE28+u/htN+H2l+ lzAV54E++V9VAVcItllAAJIR59b/yWJz3F+UzYTyFBu/N5BqHonoSRohu96fk/lK3LEL 0FlD+6rYx6p5mrUR2jhCMNL3Mk/QYxpV5o//SYtwl8PLWXae6OWyWZcWxICKQUEdXgj8 g1z85D6nN1NBUXBVWo8pSEl6use+HV+VDaOcghe11TQpqrFnYk0mdJa+xoPyhRvpSBPa 46FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=G95KKuekTz1iA7Zr8ZdyT9EdDFTvRs8dYtvTVOv4Dfc=; b=BrqQ49CALi2sqNMfy/wdfjUjsa9UywROg5WZVXGtRrDxYXNtiZOvdupYU0/7RzUcQr D4ecjxyFgj8NiiKQ3e2CdZvyQ5DgAzRIumIMYV3mJCx8hOAgVja+K7440T3jGSaN4AsZ a+m8Jvg9uTT7TTsNtnkDNr9gRqfiDbMuA8Wu/hn2+s9kEdiWy5I3MRYCZGBB7WFwqfub qRzalLkNOSDSDsPZ72YIhsKfouj3ydbds+JBsVovdQzcDyc6O12fpmzxwZLhfkEl7gnW SENde8H4lmsknmk+rP3ZGrr3m92HZ4EaKHbMmm4jWgOOTC6+p8P9Eud3U0W+2o60LG2j dhTQ== X-Gm-Message-State: AOAM530ITpbBviUHCIsvTDGT6S3/M3zIFoDxdaKgyOUQCabyFmq7E4E5 bnLocSNdnVILaLiXWVOtxfMauyq4QPqV9qMkhig= X-Google-Smtp-Source: ABdhPJx9IM+NZ+Dy+UO1H89OWuA1mQwu+ABN06cb8h6aN7Xpr4/KTHo0SHpRsO8t4uShHvxZa2ijHx26yaXliUNcOww= X-Received: by 2002:a25:40cb:: with SMTP id n194mr1171359yba.380.1596142286622; Thu, 30 Jul 2020 13:51:26 -0700 (PDT) Date: Thu, 30 Jul 2020 13:51:09 -0700 In-Reply-To: <20200730205112.2099429-1-ndesaulniers@google.com> Message-Id: <20200730205112.2099429-2-ndesaulniers@google.com> Mime-Version: 1.0 References: <20200730205112.2099429-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog Subject: [PATCH 1/4] ARM: backtrace-clang: check for NULL lr From: Nick Desaulniers To: Nathan Huckleberry , Russell King X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200730_165130_256411_311B2974 X-CRM114-Status: GOOD ( 14.01 ) X-Spam-Score: -7.7 (-------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-7.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:b4a listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 DKIMWL_WL_MED DKIMwl.org - Medium sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nick Desaulniers , Chunyan Zhang , Dmitry Safonov <0x7f454c46@gmail.com>, linux-kernel@vger.kernel.org, stable@vger.kernel.org, clang-built-linux@googlegroups.com, Miles Chen , linux-mediatek@lists.infradead.org, Matthias Brugger , Andrew Morton , Lvqiang Huang , 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 If the link register was zeroed out, do not attempt to use it for address calculations for which there are currently no fixup handlers, which can lead to a panic during unwind. Since panicking triggers another unwind, this can lead to an infinite loop. If this occurs during start_kernel(), this can prevent a kernel from booting. commit 59b6359dd92d ("ARM: 8702/1: head-common.S: Clear lr before jumping to start_kernel()") intentionally zeros out the link register in __mmap_switched which tail calls into start kernel. Test for this condition so that we can stop unwinding when initiated within start_kernel() correctly. Cc: stable@vger.kernel.org Fixes: commit 6dc5fd93b2f1 ("ARM: 8900/1: UNWINDER_FRAME_POINTER implementation for Clang") Reported-by: Miles Chen Signed-off-by: Nick Desaulniers Reviewed-by: Nathan Huckleberry --- arch/arm/lib/backtrace-clang.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/lib/backtrace-clang.S b/arch/arm/lib/backtrace-clang.S index 6174c45f53a5..5388ac664c12 100644 --- a/arch/arm/lib/backtrace-clang.S +++ b/arch/arm/lib/backtrace-clang.S @@ -144,6 +144,8 @@ for_each_frame: tst frame, mask @ Check for address exceptions */ 1003: ldr sv_lr, [sv_fp, #4] @ get saved lr from next frame + tst sv_lr, #0 @ If there's no previous lr, + beq finished_setup @ we're done. ldr r0, [sv_lr, #-4] @ get call instruction ldr r3, .Lopcode+4 and r2, r3, r0 @ is this a bl call