在 2025/8/5 12:17, [email protected] 写道:
From: Henry Martin <[email protected]>

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 <[email protected]>
Signed-off-by: Henry Martin <[email protected]>
---
  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.

        size = VMCI_DG_SIZE(dg);
/* Attach the packet to the socket's receive queue as an sk_buff. */

Reply via email to