From: Michael Contreras Date: Wed, 16 Jan 2013 14:14:14 +0000 (+0000) Subject: e1000: Discard packets that are too long if !SBP and !LPE X-Git-Tag: qemu-xen-4.2.2-rc1~8 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=08f91b7dde7daeb3f62204678343f5b68be060d9;p=qemu-upstream-4.2-testing.git e1000: Discard packets that are too long if !SBP and !LPE 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. upstream-commmit-id: b0d9ffcd0251161c7c92f94804dcf599dfa3edeb security-tags: XSA-41, CVE-2012-6075 Signed-off-by: Michael Contreras Signed-off-by: Anthony Liguori --- diff --git a/hw/e1000.c b/hw/e1000.c index e164d79b8..37d207eac 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL); #define PNPMMIO_SIZE 0x20000 #define MIN_BUF_SIZE 60 /* Min. octets in an ethernet frame sans FCS */ +/* 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 @@ -693,6 +696,13 @@ e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size) size = sizeof(min_buf); } + /* 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 size;