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: 247289 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp2744259ilg; Thu, 30 Jul 2020 13:51:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEHk/um6BH5GjUr19CaQF5T3ycplKD5uE/APL62W7ySKkqYFWdGZO50T9MctQPuKGzcjbn X-Received: by 2002:a05:6402:1c10:: with SMTP id ck16mr817863edb.151.1596142288882; Thu, 30 Jul 2020 13:51:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596142288; cv=none; d=google.com; s=arc-20160816; b=HWC97MVMnupiQqeWwEfZX7SiXJ3VrGfmkdWYeY+f+lPRToNsUXwPsPDGlUJwFP9q91 2cAttwmo/cbjZMusO/r4VNcwAeFkziL3lZboh2xiggQ5UfKtFF+Ea7p6Q5bGVP0Lr4/A UJ5/RpbVXW1ZSonEc8d8RgiFNf4Bq9reVwsfL8HG/9aVcyh0CHqHr352Ur9qn95n8WnB 8oJcLlolAtD5XGyTv998xhxll8CsZy1RpFbxejlkwcGL+lDkegu8fS3hon8A4fRToQag RPr+3L6ySiHrbO0xEZ1lU8Bm2R+lzyefJFuHHshvaqh81B/Hz1I1reDNHbIRfYkNPou4 L7lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=G95KKuekTz1iA7Zr8ZdyT9EdDFTvRs8dYtvTVOv4Dfc=; b=KRN9hETN84oOEFLpScd2a1u1R8Ogfo4nLP4et7RxLGpWZz1q5RGWtRafpx5bloWbgS ka80oPo9iLhi2tjh76dBJn1xp4SiMrnZjenKby0wdqeIj0MisGh7X3K4VaRP7lfGK9FW rIHVjb5nb1XVnH2Wos6ItmSovU4r2/ObuTJ6PVC/2i7xtBlngUMXdyJAKkB9rbGyAbH7 szEB9LsP9IfJuvgYXdSGnaqdREopOdUY6p6Eq7FR95Dhiml7i0ckL/SkyGOGMhn0yvXE DEtrVrH5vfByU67UvpCMS9XDIoROJB5HMjtSDhPmNAoDKD6r6McGkj11Wf/LOkynLWNX yIyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ViS1JlQV; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cf17si3983460edb.488.2020.07.30.13.51.28; Thu, 30 Jul 2020 13:51:28 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ViS1JlQV; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728806AbgG3Uv2 (ORCPT + 15 others); Thu, 30 Jul 2020 16:51:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728778AbgG3Uv1 (ORCPT ); Thu, 30 Jul 2020 16:51:27 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AAFCC061575 for ; Thu, 30 Jul 2020 13:51:27 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id u12so35457887ybj.0 for ; Thu, 30 Jul 2020 13:51:27 -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=qEHUoJfPTmywOWb1nVbMxFjnOzMbN+CEgPi+J6oTXR6rUhMCwfncqrC9Utadn/lyZe Nh/F3lZDIOWhhhxUaeERTBuhqACOKFhA5K9C7UVfg9m5YyGwWLOcbL1a+F34XoKKgrGP oeu5TFHQhyFvz7tLje2J1ax3hjAy6Ewczisp7+YeYhbJe+IVLA0Ij4DFAZoRzVK2nWAc ZklpGqYt5J+zcTqPJQcUyNHGRjfzFUFKuwf8XT00tLBHyuya2fsR0+/CHyipOT2jOlJh uMgixcW6wDphzXimA2VOSBiJi1H/yu7VHM55PGZfuDyNyW+2f83v3Ds6RpzTcD1PQTJL v83A== X-Gm-Message-State: AOAM530jLUTS/wXeECPySBQZqCyoa/CiQIo8UOZMLGk1EpaKht5geLqc kzRyVEyFfJwljE8r9GvGwonCJpkAkFmYOnpI/6w= 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 Cc: Andrew Morton , Chunyan Zhang , clang-built-linux@googlegroups.com, Dmitry Safonov <0x7f454c46@gmail.com>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Lvqiang Huang , Matthias Brugger , Nick Desaulniers , Miles Chen , stable@vger.kernel.org Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.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 --- arch/arm/lib/backtrace-clang.S | 2 ++ 1 file changed, 2 insertions(+) -- 2.28.0.163.g6104cc2f0b6-goog Reviewed-by: Nathan Huckleberry 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