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 28F55E6FE2F for ; Fri, 6 Sep 2024 16:37:14 +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-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0aLy431c+zotpBIky4NVOxya6P/Shby1QLzZ40FGOuE=; b=I7z0qYsLzcxLO0ku8lksaOsRQT ma/w0zgc+oIE9SggX9hjE/NNy/sMBcgRH9c0pFwMLr9VvglZQDSqtUKzr4gkbCGIqr8t5+MFOE4a3 zHqNVQsGqTNMkTqcBIzN9MaDVP8OEHwXHQRypxooyui4NsH9qdgVvDG/2HxaRCSjUlfjdav3Vx0cX Dgo5QLD8un51h+xtJ4QXPPBb+12oKus8fV4WELH4IG2hJ/FeKOLt+saEo44eKn3F3pLW4bmSGUXL0 SEJOE8BvQjexI2WQxbS069FfPUqbDZUWfNJCfF+qzt2S8yVJLsFfvkSlP98V/WkALutdkQul8UV0+ rYpfoPxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smbxF-0000000D04C-3M9o; Fri, 06 Sep 2024 16:37:01 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smbw0-0000000Czna-13ZW for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 16:35:45 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id B02A9A45144; Fri, 6 Sep 2024 16:35:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A616BC4CEC4; Fri, 6 Sep 2024 16:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725640542; bh=6fgAXad1syfSTJKtcJj8sAwYW4bPeTU9Trm2C5UltDI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=JS3ULYHAwmxeeeuP2MnCRTbcNb3OCtYWMoxxJS4D1pW6ck4O3gu+KVS3MdIO/8qmx NL3FyMDaQqKObH4DxptJNG2J2+JUhsCUthCLmlHL2AMsFj2OnBwKz5nDesOz2zRg3q uUbFAn/YbLKASKiDxcQx/b6o7UkTgOBakt1z7yhDuh+lqsoBAVffKttn3qhvaAik4a qhkj/hYbF2iini3Lmt4sTr3VgLKek9f4EkRKHrV53S7ispe6VJvnsqga9O3i1SHtw9 8jVQHpwIIV8g6XWPZOckiF1KVa0JIJmRSHS5Vg39mIQnaX1SwSdaLlUP/UtO0yhGHs 3ZDqe7az1aoeg== 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.95) (envelope-from ) id 1smbvv-00AMkA-TG; Fri, 06 Sep 2024 17:35:40 +0100 Date: Fri, 06 Sep 2024 17:35:39 +0100 Message-ID: <86ed5wvixw.wl-maz@kernel.org> From: Marc Zyngier To: Snehal Koukuntla Cc: Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Sudeep Holla , Sebastian Ene , Vincent Donnefort , Jean-Philippe Brucker , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: arm64: Add memory length checks before it is xfered In-Reply-To: <20240906092732.113152-1-snehalreddy@google.com> References: <20240906092732.113152-1-snehalreddy@google.com> 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/29.4 (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=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: snehalreddy@google.com, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, sudeep.holla@arm.com, sebastianene@google.com, vdonnefort@google.com, jean-philippe@linaro.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_093544_440520_869022FF X-CRM114-Status: GOOD ( 22.31 ) 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 Hi Snehal, On Fri, 06 Sep 2024 10:27:32 +0100, Snehal Koukuntla wrote: > > From: Snehal > > Check size during allocation to fix discrepancy in memory reclaim path. > Currently only happens during memory reclaim, inconsistent with mem_xfer Can you please elaborate? It doesn't seem to fail at allocation time here, as everything is pre-allocated. Some context would greatly help, as my FFA-foo is as basic as it gets (I did read the spec once and ran away screaming). > > Signed-off-by: Snehal Koukuntla The From: and Signed-off-by: tags do not match. You may want to add a [user] section to your .gitconfig with your full name so that this issue is sorted once and for all. > --- > arch/arm64/kvm/hyp/nvhe/ffa.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c > index e715c157c2c4..e9223cc4f913 100644 > --- a/arch/arm64/kvm/hyp/nvhe/ffa.c > +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c > @@ -461,6 +461,11 @@ static __always_inline void do_ffa_mem_xfer(const u64 func_id, /facepalm: why do we have this __always_inline here? Nothing to do with your patch, but definitely worth understanding why it is required. > goto out_unlock; > } > > + if (len > ffa_desc_buf.len) { > + ret = FFA_RET_NO_MEMORY; > + goto out_unlock; > + } > + It took some digging to understand how the various queues are sized, and a comment explaining the relation between ffa_desc_buf and the other queues would be very welcome. I also notice that we have other places (apparently dealing with fragments) that do not have such checks. Do they need anything else? > buf = hyp_buffers.tx; > memcpy(buf, host_buffers.tx, fraglen); > Finally, this probably deserves a Fixes: tag and a Cc: stable so that it can be backported. Thanks, M. -- Without deviation from the norm, progress is not possible.