e1000: Avoid infinite loop in processing transmit descriptor
PATCH 1/1 e1000: Avoid infinite loop in processing transmit descriptor
From: P J P <[email protected]>
While processing transmit descriptors, it could lead to an infinite loop if 'bytes' was to become zero; Add a check to avoid it.
[The guest can force 'bytes' to 0 by setting the hdr_len and mss descriptor fields to 0.
--Stefan]
--- hw/net/e1000.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/net/e1000.c +2 -1
@@ -740,7 +740,8 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)memmove (tp->data, tp->header, tp->hdr_len); tp->size = tp->hdr_len; } - }while (split_size -= bytes); + split_size -= bytes; + }while (bytes && split_size); }else if (!tp->tse && tp->cptse) {// context descriptor TSE is not set, while data descriptor TSE is set DBGOUT (TXERR ,"TCP segmentation error\n" );
Signature · 1 line
2.4.3
Quoted 8 lines · Stefan Hajnoczi
From: P J P <[email protected]>
While processing transmit descriptors, it could lead to an infinite loop if 'bytes' was to become zero; Add a check to avoid it.
[The guest can force 'bytes' to 0 by setting the
hdr_lenand mss descriptor fields to 0.
--Stefan]
I wonder whether we should log an LOG_GUEST_ERROR in that case since this sounds like a problem in the guest ... ?
Quoted 5 lines
hw/net/e1000.c +0
-0
hw/net/e1000.c process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) · line 747
Quoted 9 lines
hw/net/e1000.c +2
-1@@ -740,7 +740,8 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)memmove (tp->data, tp->header, tp->hdr_len); tp->size = tp->hdr_len; } - }while (split_size -= bytes); + split_size -= bytes; + }while (bytes && split_size); }else if (!tp->tse && tp->cptse) {// context descriptor TSE is not set, while data descriptor TSE is set DBGOUT (TXERR ,"TCP segmentation error\n" );
Looks sane ... (but IMHO code would be more readable though if it would break out of the loop already earlier, as soon as it is clear that bytes == 0, so that e.g. the pci_dma_read(..., 0) is not called at all).
Quoted 6 lines · Thomas Huth
Quoted 5 lines · Stefan Hajnoczi
From: P J P <[email protected]>
While processing transmit descriptors, it could lead to an infinite loop if 'bytes' was to become zero; Add a check to avoid it.
Quoted 6 lines
Quoted 3 lines
[The guest can force 'bytes' to 0 by setting the
hdr_lenand mss descriptor fields to 0.
--Stefan]I wonder whether we should log an
LOG_GUEST_ERRORin that case since this sounds like a problem in the guest ... ?
e1000.c seems to use DBGOUT(TXERR, ...) but doesn't do any rate-limiting, which can pose a problem if a malicious guest keeps triggering a warning message to fill up the disk on the host :(.
Quoted 10 lines
Quoted 10 lines
hw/net/e1000.c +1
-1@@ -740,7 +740,8 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)memmove (tp->data, tp->header, tp->hdr_len); tp->size = tp->hdr_len; } - }while (split_size -= bytes); + split_size -= bytes;
Quoted 8 lines
hw/net/e1000.c process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) · line 747
Quoted 4 lines
hw/net/e1000.c +1
-0+ }while (bytes && split_size); }else if (!tp->tse && tp->cptse) {// context descriptor TSE is not set, while data descriptor TSE is set DBGOUT (TXERR ,"TCP segmentation error\n" );Looks sane ... (but IMHO code would be more readable though if it would break out of the loop already earlier, as soon as it is clear that bytes == 0, so that e.g. the
pci_dma_read(..., 0)is not called at all).
I agree. P J P probably chose this approach because it is the smallest change. I'm happy enough as-is and you've posted your Reviewed-by too so let's leave it.
Stefan Hajnoczi
AppliedQuoted 9 lines · Stefan Hajnoczi
From: P J P <[email protected]>
While processing transmit descriptors, it could lead to an infinite loop if 'bytes' was to become zero; Add a check to avoid it.
[The guest can force 'bytes' to 0 by setting the
hdr_lenand mss descriptor fields to 0.
--Stefan]
Quoted 5 lines
Signed-off-by P J P <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>--- hw/net/e1000.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net
Stefan
Hello Stefan,
Quoted 3 lines · Stefan Hajnoczi
P J P probably chose this approach because it is the smallest change.
True.
Quoted 6 lines · Stefan Hajnoczi
Quoted 2 lines
hw/net/e1000.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net
Thank you so much, I appreciate it.
Thank you.
---Regards
-P J P
http://feedmug.com