On Tue, Aug 05, 2025 at 03:07:38PM +0800, Wang Liang wrote:
在 2025/8/5 12:17, bsdhenrymartin@xxxxxxxxx 写道:
From: Henry Martin <bsdhenryma@xxxxxxxxxxx>
The vulnerability is triggered when processing a malicious VMCI datagram
with an extremely large `payload_size` value. The attack path is:
1. Attacker crafts a malicious `vmci_datagram` with `payload_size` set
to a value near `SIZE_MAX` (e.g., `SIZE_MAX - offsetof(struct
vmci_datagram, payload) + 1`)
2. The function calculates: `size = VMCI_DG_SIZE(dg)` Where
`VMCI_DG_SIZE(dg)` expands to `offsetof(struct vmci_datagram,
payload) + dg->payload_size`
3. Integer overflow occurs during this addition, making `size` smaller
than the actual datagram size
Fixes: d021c344051a ("VSOCK: Introduce VM Sockets")
Reported-by: TCS Robot <tcs_robot@xxxxxxxxxxx>
Signed-off-by: Henry Martin <bsdhenryma@xxxxxxxxxxx>
---
net/vmw_vsock/vmci_transport.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c
index 7eccd6708d66..07079669dd09 100644
--- a/net/vmw_vsock/vmci_transport.c
+++ b/net/vmw_vsock/vmci_transport.c
@@ -630,6 +630,10 @@ static int vmci_transport_recv_dgram_cb(void *data, struct vmci_datagram *dg)
if (!vmci_transport_allow_dgram(vsk, dg->src.context))
return VMCI_ERROR_NO_ACCESS;
+ /* Validate payload size to prevent integer overflow */
+ if (dg->payload_size > SIZE_MAX - offsetof(struct vmci_datagram, payload))
+ return VMCI_ERROR_INVALID_ARGS;
+
The struct vmci_datagram has no member 'payload'. Your patch may
trigger compile error.
@Wang thanks for the highlight!
mmm, so this is the 3rd no-sense patch from the same author!
Last advice for the author, please fix your bot and try your patches
before submitting it!
Stefano
size = VMCI_DG_SIZE(dg);
/* Attach the packet to the socket's receive queue as an sk_buff. */