Skip to contentSkip to conversation

KVM: Enhance the coalesced_mmio_write() parameter to avoid stack buffer overflow

PATCH In review [email protected] 3 participants 3 messages Apr 12, 2010 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: Enhance the coalesced_mmio_write() parameter to avoid stack buffer overflow

coalesced_mmio_write() is not check the len value, if len is negative, memcpy(ring->coalesced_mmio[ring->last].data, val, len); will cause stack buffer overflow.

---
 virt/kvm/coalesced_mmio.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
virt/kvm/coalesced_mmio.c +4 -0
index c0dcfb7..eb4601c 100644
@@ -61,6 +61,10 @@ static int coalesced_mmio_write(struct kvm_io_device *this,
 {
 	struct kvm_coalesced_mmio_dev *dev = to_mmio(this);
 	struct kvm_coalesced_mmio_ring *ring = dev->kvm->coalesced_mmio_ring;
+
+	if (len < 0)
+		return -EOPNOTSUPP;
+
 	if (!coalesced_mmio_in_range(dev, addr, len))
 		return -EOPNOTSUPP;
 
Signature · 1 line
1.6.5.3
#2 lore raw
In reply to [email protected]
Quoted 5 lines · On 04/12/2010 04:57 AM, [email protected] wrote:

coalesced_mmio_write() is not check the len value, if len is negative, memcpy(ring->coalesced_mmio[ring->last].data, val, len); will cause stack buffer overflow.

How can len be negative? It can only be between 1 and 8.

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.