public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] misc: ibmvmc: fix buffer overflow in ibmvmc_recv_msg()
@ 2025-12-18 14:43 Junrui Luo
  2025-12-18 14:57 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Junrui Luo @ 2025-12-18 14:43 UTC (permalink / raw)
  To: Brad Warrum, Ritu Agarwal, Arnd Bergmann, Greg Kroah-Hartman,
	Adam Reznechek, Steven Royer, Bryant G. Ly, Randy Dunlap
  Cc: linux-kernel, Yuhao Jiang, Junrui Luo

The ibmvmc_recv_msg() function receives a msg_len value from the
hypervisor and uses it directly in h_copy_rdma() without validating.
This can result a buffer overflow.

Add a check to ensure msg_len does not exceed buffer->size before
calling h_copy_rdma().

Reported-by: Yuhao Jiang <danisjiang@gmail.com>
Reported-by: Junrui Luo <moonafterrain@outlook.com>
Fixes: 0eca353e7ae7 ("misc: IBM Virtual Management Channel Driver (VMC)")
Signed-off-by: Junrui Luo <moonafterrain@outlook.com>
---
 drivers/misc/ibmvmc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/misc/ibmvmc.c b/drivers/misc/ibmvmc.c
index e5f935b5249d..e583a73a3592 100644
--- a/drivers/misc/ibmvmc.c
+++ b/drivers/misc/ibmvmc.c
@@ -1654,6 +1654,12 @@ static int ibmvmc_recv_msg(struct crq_server_adapter *adapter,
 	}
 
 	/* RDMA the data into the partition. */
+	if (msg_len > buffer->size) {
+		dev_err(adapter->dev, "Recv_msg: msg_len 0x%x exceeds buffer size 0x%x\n",
+			(unsigned int)msg_len, (unsigned int)buffer->size);
+		spin_unlock_irqrestore(&hmc->lock, flags);
+		return -EINVAL;
+	}
 	rc = h_copy_rdma(msg_len,
 			 adapter->riobn,
 			 buffer->dma_addr_remote,

---
base-commit: ea1013c1539270e372fc99854bc6e4d94eaeff66
change-id: 20251218-fixes-1fa33e72a87f

Best regards,
-- 
Junrui Luo <moonafterrain@outlook.com>


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

end of thread, other threads:[~2025-12-18 14:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-18 14:43 [PATCH] misc: ibmvmc: fix buffer overflow in ibmvmc_recv_msg() Junrui Luo
2025-12-18 14:57 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox