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 623B7CD5BA4 for ; Thu, 21 May 2026 12:13:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Subject:Cc:To:From: Message-ID:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=QXychn9L0mxdWwBTB7z2HXwk+PRqle39TGYH6NUQk0Y=; b=rZSBAFX4eOI0M52ibgGLTZ+9+J qhQzodbM14v28FJMQ9y6SzKYWSfz4MJfyd3Yy+JS5pz7vvojjIdNhXyVEqDHW0oz5OyNl0M/B9X2L 76kfOFWaCXPMiQy0YieNsPfdXYdj4l3nDAED21U66rHmVzHeHH+zyFVhElMEqvjFRMao2RxEJdeyL ySS1+zpAOalixoSgiu8hPi9HjU5ZgJfgdBIVD1DUyc2Kyq59R8I6zzUZ64BnFBMUuZjTkw/Tsv2/O Fq3xQs2CuuJHKHKFHd/XNEk8YCgZEC6XHoToSA39L4z9A6F34iQYLbSrU3ehXV8Xk3ZzQq/aHKMQ+ 8H6344ag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wQ2Go-00000007hBT-1AnW; Thu, 21 May 2026 12:12:58 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wQ2Gl-00000007hB0-2W3N for linux-arm-kernel@lists.infradead.org; Thu, 21 May 2026 12:12:55 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id B755F60210; Thu, 21 May 2026 12:12:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D63C1F00A3B; Thu, 21 May 2026 12:12:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779365574; bh=QXychn9L0mxdWwBTB7z2HXwk+PRqle39TGYH6NUQk0Y=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=cdqQBgdX4gUwX9OmhPoMjIGM/CW9yfN8zKNNFcfBWKNEQtv1iwpnD8xXmH+Ovdt6g Nb9QE/CeAVzuJ03zyLL92uN51RT04aSQl/xFznE6tRiHlf58QJaBsJWwrU0lje0k8w YnTKt8FQfFlOiPplGA9LmCV9emUvVMZQmScmiqmCFRwId/JxVtQOpE/FyU9Fe6QPIu dfj0QgZh8bgn0f2dB9uTTmSkp6hXfRzHMgh9Vo6s6BFgzw16Vf4QyyHsIXOQG7aQ4N 65bYEZEcX95fQ4AkCJwsGS9EtUycxiIMj3VzkGIlvAs7zKOawjeHqzeCDfurqg0I+Z LKZiUfpBAQygQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wQ2Gi-00000004o66-1DzI; Thu, 21 May 2026 12:12:52 +0000 Date: Thu, 21 May 2026 13:12:51 +0100 Message-ID: <86h5o1vu4c.wl-maz@kernel.org> From: Marc Zyngier To: Mostafa Saleh Cc: op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, oupton@kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, jens.wiklander@linaro.org, sumit.garg@kernel.org, sebastianene@google.com, vdonnefort@google.com, sudeep.holla@kernel.org Subject: Re: [PATCH v4 4/5] KVM: arm64: Fix bounds checking in do_ffa_mem_reclaim() In-Reply-To: References: <20260520204948.2440882-1-smostafa@google.com> <20260520204948.2440882-5-smostafa@google.com> <86ldddw4ht.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: smostafa@google.com, op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, oupton@kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, jens.wiklander@linaro.org, sumit.garg@kernel.org, sebastianene@google.com, vdonnefort@google.com, sudeep.holla@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 21 May 2026 11:43:58 +0100, Mostafa Saleh wrote: >=20 > On Thu, May 21, 2026 at 11:30=E2=80=AFAM Mostafa Saleh wrote: > > > > Hi Marc, > > > > On Thu, May 21, 2026 at 09:28:46AM +0100, Marc Zyngier wrote: > > > On Wed, 20 May 2026 21:49:47 +0100, > > > Mostafa Saleh wrote: > > > > > > > > Sashiko (locally) reports out of bound write possiblity if SPMD > > > > returns an invalid data. > > > > > > > > While SPMD is considered trusted, pKVM does some basic checks, > > > > for offset to be less than or equal len. > > > > > > > > However, that is incorrect as even if the offset is smaller than > > > > len pKVM can still access out of bound memory in the next > > > > ffa_host_unshare_ranges(). > > > > > > > > Split this check into 2: > > > > 1- Check that the fixed portion of the descriptor fits. > > > > 2- After getting reg, check the variable array size addr_range_cnt > > > > fits. > > > > > > > > Signed-off-by: Mostafa Saleh > > > > --- > > > > arch/arm64/kvm/hyp/nvhe/ffa.c | 7 ++++++- > > > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvh= e/ffa.c > > > > index 1af722771178..e6aa2bfa63b1 100644 > > > > --- a/arch/arm64/kvm/hyp/nvhe/ffa.c > > > > +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c > > > > @@ -607,7 +607,7 @@ static void do_ffa_mem_reclaim(struct arm_smccc= _1_2_regs *res, > > > > * check that we end up with something that doesn't look _compl= etely_ > > > > * bogus. > > > > */ > > > > - if (WARN_ON(offset > len || > > > > + if (WARN_ON(offset + CONSTITUENTS_OFFSET(0) > len || > > > > fraglen > KVM_FFA_MBOX_NR_PAGES * PAGE_SIZE)) { > > > > > > Do you really want to keep this a WARN_ON(), given that this results > > > in a panic in most pKVM configurations? > > > > Which kind of configuration will that check fail on? > > Does that mean at the moment pKVM does out-of-bound access for > > the header? > > > I might have misunderstood the point. I thought you meant the new > change would cause a panic on most configurations, or were you > suggesting just removing the WARN_ON? Just dropping the WARN_ON(), because for most users, that means just killing the machine (only configurations with debug will give you a stack trace). > I can do that, I just updated the current faulty check and left the > WARN_ON as is. I'd be all for that. Thanks, M. --=20 Without deviation from the norm, progress is not possible.