All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] net: vmxnet3: memory leakage issue
@ 2015-12-02 12:17 P J P
  2015-12-03  7:17 ` Dmitry Fleytman
  2015-12-04  2:22 ` Jason Wang
  0 siblings, 2 replies; 21+ messages in thread
From: P J P @ 2015-12-02 12:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dmitry Fleytman, Qinghao Tang, Jason Wang

[-- Attachment #1: Type: text/plain, Size: 933 bytes --]

   Hello Dmitry, all

A memory leakage issue was reported by Mr Qinghao Tang, CC'd here.

In that, the Qemu VMXNET3 paravirtual device emulator does not check if the 
device is already active, before activating it. This leads to host memory 
leakage via calls to vmxnet_tx_pkt_init(), which calls g_malloc0().

===
static void vmxnet3_activate_device(VMXNET3State *s)
{
    ...
    /* Preallocate TX packet wrapper */
    VMW_CFPRN("Max TX fragments is %u", s->max_tx_frags);
    vmxnet_tx_pkt_init(&s->tx_pkt, s->max_tx_frags, s->peer_has_vhdr);
    ...
}
===

A malicious guest driver could use this flaw to leak excessive memory on the 
host, eventually killing the Qemu process.

Please see attached herein is a proposed (tested)patch which fixes this issue. 
Please let me know if it's okay or requires any changes.

Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F

[-- Attachment #2: Type: text/plain, Size: 1095 bytes --]

From 70f5e638d6f85a87b6bdeb90585f81b4616d31ef Mon Sep 17 00:00:00 2001
From: Prasad J Pandit <pjp@fedoraproject.org>
Date: Wed, 2 Dec 2015 17:28:06 +0530
Subject: net: vmxnet3: avoid multiple activations of device

Vmxnet3 device emulator does not check if the device is active
before activating it, resulting in memory leakage on the host.
Added a check to verify device state and avoid memory leakage.

Reported-by: Qinghao Tang <luodalongde@gmail.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
 hw/net/vmxnet3.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 071feeb..7b727b3 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -1425,6 +1425,12 @@ static void vmxnet3_activate_device(VMXNET3State *s)
         return;
     }
 
+    /* Verify if device is active */
+    if (s->device_active) {
+        VMW_CFPRN("Vmxnet3 device is active");
+        return;
+    }
+
     vmxnet3_adjust_by_guest_type(s);
     vmxnet3_update_features(s);
     vmxnet3_update_pm_state(s);
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2015-12-15 10:09 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-02 12:17 [Qemu-devel] net: vmxnet3: memory leakage issue P J P
2015-12-03  7:17 ` Dmitry Fleytman
2015-12-03 11:20   ` P J P
2015-12-04  3:16   ` Jason Wang
2015-12-08 10:17     ` P J P
2015-12-09 15:28       ` P J P
2015-12-11  9:10         ` Jason Wang
2015-12-11  9:34           ` Dmitry Fleytman
2015-12-11 10:04           ` P J P
2015-12-13  8:27             ` Dmitry Fleytman
2015-12-13  9:45         ` Dmitry Fleytman
2015-12-14 11:58           ` P J P
2015-12-14 17:27             ` Dmitry Fleytman
2015-12-15  6:57               ` P J P
2015-12-15  7:01                 ` Dmitry Fleytman
2015-12-15  8:00                   ` P J P
2015-12-15  8:24                     ` Jason Wang
2015-12-15  8:50                       ` P J P
2015-12-15  8:43             ` Miao Yan
2015-12-15 10:08               ` P J P
2015-12-04  2:22 ` Jason Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.