qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] cadence_gem: fix buffer overflow
@ 2016-01-14  9:43 Michael S. Tsirkin
  2016-01-14 10:03 ` [Qemu-devel] [Qemu-arm] " Peter Maydell
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Michael S. Tsirkin @ 2016-01-14  9:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Crosthwaite, Jason Wang, Prasad Pandit, qemu-arm,
	=?UTF-8?q?=E5=88=98=E4=BB=A4?=, Alistair Francis

gem_receive copies a packet received from network into an rxbuf[2048]
array on stack, with size limited by descriptor length set by guest.  If
guest is malicious and specifies a descriptor length that is too large,
and should packet size exceed array size, this results in a buffer
overflow.

Reported-by: 刘令 <liuling-it@360.cn>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/net/cadence_gem.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index 3639fc1..15a0786 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -862,6 +862,14 @@ static void gem_transmit(CadenceGEMState *s)
             break;
         }
 
+        if (tx_desc_get_length(desc) > sizeof(tx_packet) - (p - tx_packet)) {
+            DB_PRINT("TX descriptor @ 0x%x too large: size 0x%x space 0x%x\n",
+                     (unsigned)packet_desc_addr,
+                     (unsigned)tx_desc_get_length(desc),
+                     sizeof(tx_packet) - (p - tx_packet));
+            break;
+        }
+
         /* Gather this fragment of the packet from "dma memory" to our contig.
          * buffer.
          */
-- 
MST

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

end of thread, other threads:[~2016-01-19  2:49 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-14  9:43 [Qemu-devel] [PATCH] cadence_gem: fix buffer overflow Michael S. Tsirkin
2016-01-14 10:03 ` [Qemu-devel] [Qemu-arm] " Peter Maydell
2016-01-14 10:11   ` Michael S. Tsirkin
2016-01-15  6:19   ` Peter Crosthwaite
2016-01-15  8:06     ` P J P
2016-01-16  0:20       ` Alistair Francis
2016-01-16  5:23         ` P J P
2016-01-18  3:14     ` Jason Wang
2016-01-14 10:23 ` [Qemu-devel] " P J P
2016-01-15  3:16 ` Jason Wang
2016-01-15  5:39   ` P J P
2016-01-18  6:50 ` Jason Wang
2016-01-18  7:04   ` Peter Crosthwaite
2016-01-18  8:12     ` Jason Wang
2016-01-18  9:08       ` Peter Crosthwaite
2016-01-18  9:57         ` Jason Wang
2016-01-18 10:06           ` [Qemu-devel] [Qemu-arm] " Peter Maydell
2016-01-18 16:54             ` Alistair Francis
2016-01-19  2:48               ` Jason Wang
2016-01-19  2:48             ` Jason Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).