Skip to contentSkip to conversation

VMCI: integer overflow in vmci_datagram_dispatch()

PATCH In review Dan Carpenter 2 participants 3 messages Aug 29, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 VMCI: integer overflow in vmci_datagram_dispatch()

This is untrusted user data from vmci_host_do_send_datagram() so the VMCI_DG_SIZE() macro can have an integer overflow.

drivers/misc/vmw_vmci/vmci_datagram.c +2 -1
index f3cdd90..8226652 100644
@@ -328,7 +328,8 @@ int vmci_datagram_dispatch(u32 context_id,
 
 	BUILD_BUG_ON(sizeof(struct vmci_datagram) != 24);
 
-	if (VMCI_DG_SIZE(dg) > VMCI_MAX_DG_SIZE) {
+	if (dg->payload_size > VMCI_MAX_DG_SIZE ||
+	    VMCI_DG_SIZE(dg) > VMCI_MAX_DG_SIZE) {
 		pr_devel("Payload (size=%llu bytes) too big to send\n",
 			 (unsigned long long)dg->payload_size);
 		return VMCI_ERROR_INVALID_ARGS;
#1 lore raw

Am 29.08.2014 10:42, schrieb Dan Carpenter:

Quoted 10 lines

This is untrusted user data from vmci_host_do_send_datagram() so the VMCI_DG_SIZE() macro can have an integer overflow.

drivers/misc/vmw_vmci/vmci_datagram.c +0 -0
index f3cdd90..8226652 100644

drivers/misc/vmw_vmci/vmci_datagram.c int vmci_datagram_dispatch(u32 context_id, · line 335

Quoted 9 lines
drivers/misc/vmw_vmci/vmci_datagram.c +2 -1
@@ -328,7 +328,8 @@ int vmci_datagram_dispatch(u32 context_id,
 
 	BUILD_BUG_ON(sizeof(struct vmci_datagram) != 24);
 
-	if (VMCI_DG_SIZE(dg) > VMCI_MAX_DG_SIZE) {
+	if (dg->payload_size > VMCI_MAX_DG_SIZE ||
+	    VMCI_DG_SIZE(dg) > VMCI_MAX_DG_SIZE) {
 		pr_devel("Payload (size=%llu bytes) too big to send\n",
 			 (unsigned long long)dg->payload_size);
 		return VMCI_ERROR_INVALID_ARGS;

Are your sure about that ">" ? maybe ">=" was intended ?

re,
wh

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 16 lines · walter harms

Am 29.08.2014 10:42, schrieb Dan Carpenter:

Quoted 13 lines

This is untrusted user data from vmci_host_do_send_datagram() so the VMCI_DG_SIZE() macro can have an integer overflow.

drivers/misc/vmw_vmci/vmci_datagram.c +0 -0
index f3cdd90..8226652 100644
@@ -328,7 +328,8 @@ int vmci_datagram_dispatch(u32 context_id,
 
 	BUILD_BUG_ON(sizeof(struct vmci_datagram) != 24);
 
Quoted 8 lines

drivers/misc/vmw_vmci/vmci_datagram.c int vmci_datagram_dispatch(u32 context_id, · line 335

Quoted 6 lines
drivers/misc/vmw_vmci/vmci_datagram.c +2 -1
-	if (VMCI_DG_SIZE(dg) > VMCI_MAX_DG_SIZE) {
+	if (dg->payload_size > VMCI_MAX_DG_SIZE ||
+	    VMCI_DG_SIZE(dg) > VMCI_MAX_DG_SIZE) {
 		pr_devel("Payload (size=%llu bytes) too big to send\n",
 			 (unsigned long long)dg->payload_size);
 		return VMCI_ERROR_INVALID_ARGS;

Are your sure about that ">" ? maybe ">=" was intended ?

Yes, I'm sure. As a rule of thumb, > is used for size comparisons and

Quoted 1 line

= is used for index comparisons.

regards,
dan carpenter