]> xenbits.xensource.com Git - qemu-xen-4.6-testing.git/commitdiff
e1000: Discard packets that are too long if !SBP and !LPE
authorMichael Contreras <michael@inetric.com>
Mon, 3 Dec 2012 04:11:22 +0000 (20:11 -0800)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 16 Jan 2013 14:05:57 +0000 (14:05 +0000)
The e1000_receive function for the e1000 needs to discard packets longer than
1522 bytes if the SBP and LPE flags are disabled. The linux driver assumes
this behavior and allocates memory based on this assumption.

Signed-off-by: Michael Contreras <michael@inetric.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
[ This is a security vulnerability, CVE-2012-6075 / XSA-41. ]

hw/e1000.c

index 97104edaf571ec0ee54091f30a86c9896d132b0c..f0673f0048d27ca72850c61564941129778aa81f 100644 (file)
@@ -55,6 +55,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
 #define REG_IOADDR 0x0
 #define REG_IODATA 0x4
 
+/* this is the size past which hardware will drop packets when setting LPE=0 */
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
+
 /*
  * HW models:
  *  E1000_DEV_ID_82540EM works with Windows and Linux
@@ -628,6 +631,13 @@ e1000_receive(void *opaque, const uint8_t *buf, int size)
         return;
     }
 
+    /* Discard oversized packets if !LPE and !SBP. */
+    if (size > MAXIMUM_ETHERNET_VLAN_SIZE
+        && !(s->mac_reg[RCTL] & E1000_RCTL_LPE)
+        && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) {
+        return size;
+    }
+
     if (!receive_filter(s, buf, size))
         return;