From: bsdhenrymartin@gmail.com
To: huntazhang@tencent.com, jitxie@tencent.com,
landonsun@tencent.com, bryan-bt.tan@broadcom.com,
vishnu.dasa@broadcom.com, bcm-kernel-feedback-list@broadcom.com,
sgarzare@redhat.com, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org
Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux.dev,
netdev@vger.kernel.org, Henry Martin <bsdhenryma@tencent.com>,
TCS Robot <tcs_robot@tencent.com>
Subject: [PATCH] VSOCK: fix Integer Overflow in vmci_transport_recv_dgram_cb()
Date: Tue, 5 Aug 2025 12:17:48 +0800 [thread overview]
Message-ID: <20250805041748.1728098-1-tcs_kernel@tencent.com> (raw)
From: Henry Martin <bsdhenryma@tencent.com>
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@tencent.com>
Signed-off-by: Henry Martin <bsdhenryma@tencent.com>
---
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;
+
size = VMCI_DG_SIZE(dg);
/* Attach the packet to the socket's receive queue as an sk_buff. */
--
2.41.3
next reply other threads:[~2025-08-05 4:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-05 4:17 bsdhenrymartin [this message]
2025-08-05 7:07 ` Wang Liang
2025-08-05 7:22 ` Stefano Garzarella
2025-08-06 21:03 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250805041748.1728098-1-tcs_kernel@tencent.com \
--to=bsdhenrymartin@gmail.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bryan-bt.tan@broadcom.com \
--cc=bsdhenryma@tencent.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=huntazhang@tencent.com \
--cc=jitxie@tencent.com \
--cc=kuba@kernel.org \
--cc=landonsun@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sgarzare@redhat.com \
--cc=tcs_robot@tencent.com \
--cc=virtualization@lists.linux.dev \
--cc=vishnu.dasa@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®