From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4C7A4C4332F for ; Wed, 4 Jan 2023 16:34:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc: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=PlIdz/coSpj9A8Tp7970wxyClmeOEDOmoGi31me5EpU=; b=pzf7U8MRT+eEoJ /K8vo02e3JcbQR4/wELYpPN/glNtYiSR6bWr/YEqVuwr54m4ouR1o3qiQF7Sn93LjHMuF5KA2HYsF v16i3bGH6lUAYzwu6kOUajgNta9N+qgoapbpCZFPZXpoLqJpsg6m6hDXrIQInxoNrA3dx+rb1dSLL /qQY2cKEXc5PIYDwjf2t9X6qCl/8BuYNiIYHgL8lzi3WyNmpiiYMeI6b5INbs+Zqpc2zubCHHEgTR yDIVz35w/UiBIV/qxDJ3sQK+7NeJ33zQNqtDb2Wvo2ATIIaLztiLGXOANLAeJNgeMZ9Y/M3sreKBw O2yQJrNf/6oljxeF0/Lw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pD6hq-00AOD8-9Z; Wed, 04 Jan 2023 16:33:34 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pD6fC-00ANq3-TE for linux-arm-kernel@lists.infradead.org; Wed, 04 Jan 2023 16:30:53 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8D3A5165C; Wed, 4 Jan 2023 08:31:26 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.37.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6099A3F71A; Wed, 4 Jan 2023 08:30:43 -0800 (PST) Date: Wed, 4 Jan 2023 16:30:40 +0000 From: Mark Rutland To: Ard Biesheuvel Cc: Lee Jones , stable@vger.kernel.org, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, will@kernel.org, catalin.marinas@arm.com, Sami Tolvanen , Kees Cook Subject: Re: [PATCH 1/2] arm64: efi: Execute runtime services from a dedicated stack Message-ID: References: <20221205201210.463781-1-ardb@kernel.org> <20221205201210.463781-2-ardb@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230104_083051_083177_BC822D54 X-CRM114-Status: GOOD ( 35.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jan 04, 2023 at 05:15:34PM +0100, Ard Biesheuvel wrote: > On Wed, 4 Jan 2023 at 17:13, Mark Rutland wrote: > > > > On Wed, Jan 04, 2023 at 02:56:19PM +0100, Ard Biesheuvel wrote: > > > On Wed, 4 Jan 2023 at 11:40, Lee Jones wrote: > > > > > > > > On Mon, 05 Dec 2022, Ard Biesheuvel wrote: > > > > > > > > > With the introduction of PRMT in the ACPI subsystem, the EFI rts > > > > > workqueue is no longer the only caller of efi_call_virt_pointer() in the > > > > > kernel. This means the EFI runtime services lock is no longer sufficient > > > > > to manage concurrent calls into firmware, but also that firmware calls > > > > > may occur that are not marshalled via the workqueue mechanism, but > > > > > originate directly from the caller context. > > > > > > > > > > For added robustness, and to ensure that the runtime services have 8 KiB > > > > > of stack space available as per the EFI spec, introduce a spinlock > > > > > protected EFI runtime stack of 8 KiB, where the spinlock also ensures > > > > > serialization between the EFI rts workqueue (which itself serializes EFI > > > > > runtime calls) and other callers of efi_call_virt_pointer(). > > > > > > > > > > While at it, use the stack pivot to avoid reloading the shadow call > > > > > stack pointer from the ordinary stack, as doing so could produce a > > > > > gadget to defeat it. > > > > > > > > > > Signed-off-by: Ard Biesheuvel > > > > > --- > > > > > arch/arm64/include/asm/efi.h | 3 +++ > > > > > arch/arm64/kernel/efi-rt-wrapper.S | 13 +++++++++- > > > > > arch/arm64/kernel/efi.c | 25 ++++++++++++++++++++ > > > > > 3 files changed, 40 insertions(+), 1 deletion(-) > > > > > > > > Could we have this in Stable please? > > > > > > > > Upstream commit: ff7a167961d1b ("arm64: efi: Execute runtime services from a dedicated stack") > > > > > > > > Ard, do we need Patch 2 as well, or can this be applied on its own? > > > > > > > > > > Thanks for the reminder. > > > > > > Only patch #1 is needed. It should be applied to v5.10 and later. > > > > Hold on, why did this go into mainline when I had an outstanding comment w.r.t. > > the stack unwinder? > > > > From your last reply to me there I was expecting a respin with that fixed. > > > > Apologies for the confusion. > > I have a patch for this queued up, but AIUI, that cannot be merged all > the way back to v5.10, so these need to remain separate changes in any > case. > > https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=c2530a04a73e6b75ed71ed14d09d7b42d6300013 Ah, ok, thanks for the pointer! I'm a little uneasy here, still. By backporting this we're also backporting the new breakage of the stack unwinder, and the minimal change for backports would be to add the lock and not the new stack (which was added for additinoal robustness, not to fix the bug the lock fixes). I do appreciate that the additional stack is likely more useful than the occasional diagnostic output from the kernel, but it does seem like this has traded off one bug for another, and I'm just a little annoyed because I pointed that out before the first pull request was made. I do know that this isn't malicious, and I'm not trying to start a fight, but now we have to consider whether we want/need to backport a stack unwinder fix to account for this, and we hadn't had that discussion before. Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel