linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: Add memory length checks before it is xfered
@ 2024-09-06  9:27 Snehal Koukuntla
  2024-09-06 16:35 ` Marc Zyngier
  0 siblings, 1 reply; 4+ messages in thread
From: Snehal Koukuntla @ 2024-09-06  9:27 UTC (permalink / raw)
  To: Marc Zyngier, Oliver Upton
  Cc: James Morse, Suzuki K Poulose, Zenghui Yu, Catalin Marinas,
	Will Deacon, Sudeep Holla, Sebastian Ene, Vincent Donnefort,
	Snehal, Jean-Philippe Brucker, linux-arm-kernel, kvmarm,
	linux-kernel

From: Snehal <snehalreddy@google.com>

Check size during allocation to fix discrepancy in memory reclaim path.
Currently only happens during memory reclaim, inconsistent with mem_xfer

Signed-off-by: Snehal Koukuntla <snehalreddy@google.com>
---
 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,
 		goto out_unlock;
 	}
 
+	if (len > ffa_desc_buf.len) {
+		ret = FFA_RET_NO_MEMORY;
+		goto out_unlock;
+	}
+
 	buf = hyp_buffers.tx;
 	memcpy(buf, host_buffers.tx, fraglen);
 
-- 
2.46.0.469.g59c65b2a67-goog



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-09-09 13:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-06  9:27 [PATCH] KVM: arm64: Add memory length checks before it is xfered Snehal Koukuntla
2024-09-06 16:35 ` Marc Zyngier
2024-09-09  7:16   ` Sebastian Ene
2024-09-09 13:04     ` Snehal Koukuntla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).