Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp163056pxm; Wed, 2 Mar 2022 12:33:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxp3vE5iwXnF2cjlsFC4HsMRPWtjp48YZWCdarw6O6edse52qOxT7ZSf68XdIrLLgwZoU3Y X-Received: by 2002:a17:906:5006:b0:6ce:3762:c72e with SMTP id s6-20020a170906500600b006ce3762c72emr24687066ejj.30.1646253189856; Wed, 02 Mar 2022 12:33:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646253189; cv=none; d=google.com; s=arc-20160816; b=HQCmCPm9bbOzOXwoPKzBddZIvsB1GJ9uIkap7z744xxyjgahWRNkwli8tDzA/S+Rza MLmoPQG0cfzIOMfFydL/4A4XBt4OjphZIJ51vPdbucP70L5WJCO1QyHnTwchzF8c6hAP qe6nlxqKr3YEIXD/UNpsDfl/2TT0C7Llyd79L1I/uwtCNap2Qv65q3nfET9ZmplDPbNQ sD9z/Ni+QF9nrDRB3kSZ1p6GLKBH9ABI0WfzTuChGBl67a7geNCh8tKenblrUn44Ebp5 4MV6Etv7cs2mUWW3DlOYy1FfvHvMOCDfOKik4FnYthLRwlUXCnMvEMZ6Fgori5XAHgZR SMOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=khBsrTjvSXI7IJjJJ+YNtvYXy57+H5QYGdiVzzjkpCU=; b=TtdzFaBLVeiBMuiq5aZkjVxlXQ9Wha5LI6D8MgBKgF3KoVFvTvr7K2jr+mcxvxims1 WzbKnLR9gVbhywDr9WX4Dc5dfJ7wFFIp6TdeE5UBQuJgcBnG0bxAUmY6S3OZVxlOHDUX p0sNhyC+pCrgbZljjeaosC2wdnCH/377PRHwdz2Y8fTq3tETubPr3mmr/4bnWJPyKjUl TLXF8U9CByyYWBskQrsz2XaNU8wqO+E16Zfq7BiiKw7HyyjNwc4APmNjSAdyX04vejiW yNuchIo0jSAWXo6CjxAYe4VS+Wt64AYbw8Jo/BFf2K5l+Dr6+4w0QxMDJfjMu0Qz0oxL kf1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qfMtk41D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf22-20020a1709077f1600b006d0beded887si33221ejc.975.2022.03.02.12.32.44; Wed, 02 Mar 2022 12:33:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qfMtk41D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240612AbiCBJqn (ORCPT + 99 others); Wed, 2 Mar 2022 04:46:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233118AbiCBJqm (ORCPT ); Wed, 2 Mar 2022 04:46:42 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90D623EF0F for ; Wed, 2 Mar 2022 01:45:59 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2D94261589 for ; Wed, 2 Mar 2022 09:45:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 856C9C340EF for ; Wed, 2 Mar 2022 09:45:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646214358; bh=2JnRdqk9IpbS2csdbNfGa/teFvYHGo28QkZ62lr+Dws=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=qfMtk41Dv85APtPi8l9R6uufvD2N9rrV/Lk5bQgs9VzeDpGrWN4DJn5d9hgyz0Cb+ ZGBbGCY+EqIcUJ8NZJkeE5K+gh/wGJVkQ3qwUm7pcrGM1GXL1G1yhW3emdYYZB9+59 OpZUukkg8JdYu3aeONCpZXdLcgHzAOOSpTHoLyuVHZyV0KCBYT1NvGWTWMtrn/z7k5 h1LhsZF6kp1Cvy0W0xf5LRINDpE28jxM3YmOg2Li4HL6VCwNXfW/5NrhOdSGRlxKa9 fkULnNS/z09J2cSwcj+ivkjgnStoHymEJXFFBCC9AgABnZp7NTQhaLv7NSiicCY36B QFJHqDroqCrKw== Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-2dbd97f9bfcso10408847b3.9 for ; Wed, 02 Mar 2022 01:45:58 -0800 (PST) X-Gm-Message-State: AOAM532orE3Rp5lRIu/pCWQuXEzIc4tBzEQGyQizS6k9gzKs9cqYneBw XNqp1XiTORW3j3xSe7vZIlzYgJa1zP9wYs4SciE= X-Received: by 2002:a81:84d5:0:b0:2d1:e85:bf04 with SMTP id u204-20020a8184d5000000b002d10e85bf04mr29646515ywf.465.1646214357573; Wed, 02 Mar 2022 01:45:57 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Ard Biesheuvel Date: Wed, 2 Mar 2022 10:45:46 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: boot flooded with unwind: Index not found To: Corentin Labbe , Linus Walleij , Arnd Bergmann Cc: "Russell King (Oracle)" , Linux ARM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2 Mar 2022 at 09:55, Corentin Labbe wro= te: > > Le Wed, Mar 02, 2022 at 09:44:52AM +0100, Ard Biesheuvel a =C3=A9crit : > > On Wed, 2 Mar 2022 at 09:40, Corentin Labbe = wrote: > > > > > > Le Tue, Mar 01, 2022 at 05:52:30PM +0100, Ard Biesheuvel a =C3=A9crit= : > > > > On Tue, 1 Mar 2022 at 17:37, Ard Biesheuvel wrote= : > > > > > > > > > > On Tue, 1 Mar 2022 at 16:52, Russell King (Oracle) > > > > > wrote: > > > > > > > > > > > > On Tue, Mar 01, 2022 at 04:48:25PM +0100, Corentin Labbe wrote: > > > > > > > Hello > > > > > > > > > > > > > > I booted today linux-next (20220301) and my boot is flooded w= ith: > > > > > > > [ 0.000000] unwind: Index not found c0f0c440 > > > > > > > [ 0.000000] unwind: Index not found 00000000 > > > > > > > [ 0.000000] unwind: Index not found c0f0c440 > > > > > > > [ 0.000000] unwind: Index not found 00000000 > > > > > > > > > > > > > > This happen on a sun8i-a83t-bananapi-m3 > > > > > > > > > > > > Have you enabled vmapped stacks? > > > > > > > > > > > > > > > > This is probably related to > > > > > > > > > > 538b9265c063 ARM: unwind: track location of LR value in stack fra= me > > > > > > > > > > which removes a kernel_text_address() check on frame->pc as it is > > > > > essentially redundant, given that we won't find unwind data other= wise. > > > > > Unfortunately, I failed to realise that the other check carries a > > > > > pr_warn(), which may apparently fire spuriously in some cases. > > > > > > > > > > The 0x0 value can easily be filtered out, but i would be interest= ing > > > > > where the other value originates from. We might be able to solve = this > > > > > with a simple .nounwind directive in a asm routine somewhere. > > > > > > > > > > I'll prepare a patch that disregards the 0x0 value - could you ch= eck > > > > > in the mean time what the address 0xcf0c440 coincides with in you= r > > > > > build? > > > > > > > > Something like the below should restore the previous behavior, whil= e > > > > taking the kernel_text_address() check out of the hot path. > > > > > > > > --- a/arch/arm/kernel/unwind.c > > > > +++ b/arch/arm/kernel/unwind.c > > > > @@ -400,7 +400,8 @@ int unwind_frame(struct stackframe *frame) > > > > > > > > idx =3D unwind_find_idx(frame->pc); > > > > if (!idx) { > > > > - pr_warn("unwind: Index not found %08lx\n", frame->p= c); > > > > + if (frame->pc && kernel_text_address(frame->pc)) > > > > + pr_warn("unwind: Index not found %08lx\n", = frame->pc); > > > > return -URC_FAILURE; > > > > } > > > > > > Hello > > > > > > This is a more detailed trace from my follow up after your patch: > > > > So the log below is from a kernel that has the above patch applied? > > Could you please share the .config? > > > > Yes this is a kernel with above patch applied (this board do not boot wit= hout it). It's not entirely clear to me how (or whether) the recent changes to unwind.c cause this issue, but one thing that stands out in the current code is the unguarded dereference of a value pulled of the stack as a memory address. It is worth noting that the only unwind entries in vmlinux that load SP from the stack directly (as opposed to unwinding it by moving from the frame pointer or by addition/subtraction) are the __irq_svc/__pabt_svc/__dabt_svc entry routines, and given that the bogus address 60000013 looks suspiciously like a PSR value (which is stored in the vicinity of SP on the exception stack), my suspicion is that some unwinder annotations are out of sync with the actual code. So while the below does not fix the root cause, i.e., that the unwinder unwinds SP incorrectly causing us to dereference a bogus pointer, it should avoid the subsequent crash. Please give it a go. --- a/arch/arm/kernel/unwind.c +++ b/arch/arm/kernel/unwind.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -236,10 +237,11 @@ static int unwind_pop_register(struct unwind_ctrl_block *ctrl, if (*vsp >=3D (unsigned long *)ctrl->sp_high) return -URC_FAILURE; - /* Use READ_ONCE_NOCHECK here to avoid this memory access - * from being tracked by KASAN. + /* Use get_kernel_nofault() here to avoid this memory access + * from causing a fatal fault, and from being tracked by KASAN. */ - ctrl->vrs[reg] =3D READ_ONCE_NOCHECK(*(*vsp)); + if (get_kernel_nofault(ctrl->vrs[reg], *vsp)) + return -URC_FAILURE; if (reg =3D=3D 14) ctrl->lr_addr =3D *vsp; (*vsp)++;