net: e1000: check transmit descriptor field values
PATCH 1/1 net: e1000: check transmit descriptor field values
From: Prasad J Pandit <[email protected]>
While processing transmit (tx) descriptors in process_tx_desc() various descriptor fields are not checked properly. This may lead to infinite loop like issue. Add checks to avoid them.
--- hw/net/e1000.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/net/e1000.c +6 -0
@@ -667,9 +667,11 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) addr =le64_to_cpu (dp->buffer_addr);if (tp->cptse) { +assert (tp->tso_props.hdr_len); msh = tp->tso_props.hdr_len + tp->tso_props.mss; do { bytes = split_size; + assert(msh > tp->size); if (tp->size + bytes > msh) bytes = msh - tp->size;
@@ -681,22 +683,26 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)memmove (tp->header, tp->data, tp->tso_props.hdr_len); } tp->size = sz; +assert (tp->size);/* sz may get truncated */ addr += bytes;if (sz == msh) {xmit_seg (s);memmove (tp->data, tp->header, tp->tso_props.hdr_len); tp->size = tp->tso_props.hdr_len; } +assert (split_size >= bytes); split_size -= bytes; }while (bytes && split_size); }else { split_size =MIN (sizeof (tp->data) - tp->size, split_size); +assert (tp->size && split_size);pci_dma_read (d, addr, tp->data + tp->size, split_size); tp->size += split_size; }if (!(txd_lower &E1000_TXD_CMD_EOP ))return ; +assert (tp->size && tp->tso_props.hdr_len);if (!(tp->cptse && tp->size < tp->tso_props.hdr_len)) {xmit_seg (s); }
Signature · 1 line
2.29.2
Quoted 6 lines · P J P
From: Prasad J Pandit <[email protected]>
While processing transmit (tx) descriptors in
process_tx_desc()various descriptor fields are not checked properly. This may lead to infinite loop like issue. Add checks to avoid them.
Quoted 7 lines
Reported-by Alexander Bulekov <[email protected]>Reported-by Cheolwoo Myung <[email protected]>Reported-by Ruhr-University Bochum <[email protected]>Signed-off-by Prasad J Pandit <[email protected]>--- hw/net/e1000.c | 6 ++++++ 1 file changed, 6 insertions(+)
I guess you post the wrong patch :) ?
Thanks
Quoted 44 lines
hw/net/e1000.c +6
-0@@ -667,9 +667,11 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) addr =le64_to_cpu (dp->buffer_addr);if (tp->cptse) { +assert (tp->tso_props.hdr_len); msh = tp->tso_props.hdr_len + tp->tso_props.mss; do { bytes = split_size; + assert(msh > tp->size); if (tp->size + bytes > msh) bytes = msh - tp->size;@@ -681,22 +683,26 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)memmove (tp->header, tp->data, tp->tso_props.hdr_len); } tp->size = sz; +assert (tp->size);/* sz may get truncated */ addr += bytes;if (sz == msh) {xmit_seg (s);memmove (tp->data, tp->header, tp->tso_props.hdr_len); tp->size = tp->tso_props.hdr_len; } +assert (split_size >= bytes); split_size -= bytes; }while (bytes && split_size); }else { split_size =MIN (sizeof (tp->data) - tp->size, split_size); +assert (tp->size && split_size);pci_dma_read (d, addr, tp->data + tp->size, split_size); tp->size += split_size; }if (!(txd_lower &E1000_TXD_CMD_EOP ))return ; +assert (tp->size && tp->tso_props.hdr_len);if (!(tp->cptse && tp->size < tp->tso_props.hdr_len)) {xmit_seg (s); }
Hello Jason,
+-- On Thu, 18 Feb 2021, Jason Wang wrote --+ | On 2021/2/10 下午10:52, P J P wrote: | > From: Prasad J Pandit <[email protected]> | > | > While processing transmit (tx) descriptors in process_tx_desc() | > various descriptor fields are not checked properly. This may lead | > to infinite loop like issue. Add checks to avoid them. | > | > Reported-by: Alexander Bulekov <[email protected]> | > Reported-by: Cheolwoo Myung <[email protected]> | > Reported-by: Ruhr-University Bochum <[email protected]> | > Signed-off-by: Prasad J Pandit <[email protected]> | > --- | > hw/net/e1000.c | 6 ++++++ | > 1 file changed, 6 insertions(+) | | I guess you post the wrong patch :) ?
Wrong patch...?
Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D
Quoted 20 lines · P J P
Hello Jason,
+-- On Thu, 18 Feb 2021, Jason Wang wrote --+ | On 2021/2/10 下午10:52, P J P wrote: | > From: Prasad J Pandit <[email protected]> | > | > While processing transmit (tx) descriptors in process_tx_desc() | > various descriptor fields are not checked properly. This may lead | > to infinite loop like issue. Add checks to avoid them. | > | > Reported-by: Alexander Bulekov <[email protected]> | > Reported-by: Cheolwoo Myung <[email protected]> | > Reported-by: Ruhr-University Bochum <[email protected]> | > Signed-off-by: Prasad J Pandit <[email protected]> | > --- | > hw/net/e1000.c | 6 ++++++ | > 1 file changed, 6 insertions(+) | | I guess you post the wrong patch :) ?
Quoted 3 lines
Wrong patch...?
Thank you.
Yes, I think I sent you a patch a week ago. I think we should use that one instead of using assert() here?
Thanks
Quoted 3 lines
--
Prasad J Pandit / Red Hat Product Security Team
8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D
Quoted 6 lines · P J P
From: Prasad J Pandit <[email protected]>
While processing transmit (tx) descriptors in
process_tx_desc()various descriptor fields are not checked properly. This may lead to infinite loop like issue. Add checks to avoid them.
+CC Peter Maydell
Is this a DMA re-entracy/stack-overflow issue? IIRC the plan was to have some sort of wider fix for these issues. There are bunch of these reports floating around at this point, I believe.
Quoted 54 lines
Reported-by Alexander Bulekov <[email protected]>Reported-by Cheolwoo Myung <[email protected]>Reported-by Ruhr-University Bochum <[email protected]>Signed-off-by Prasad J Pandit <[email protected]>--- hw/net/e1000.c | 6 ++++++ 1 file changed, 6 insertions(+)hw/net/e1000.c +6
-0@@ -667,9 +667,11 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) addr =le64_to_cpu (dp->buffer_addr);if (tp->cptse) { +assert (tp->tso_props.hdr_len); msh = tp->tso_props.hdr_len + tp->tso_props.mss; do { bytes = split_size; + assert(msh > tp->size); if (tp->size + bytes > msh) bytes = msh - tp->size;@@ -681,22 +683,26 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)memmove (tp->header, tp->data, tp->tso_props.hdr_len); } tp->size = sz; +assert (tp->size);/* sz may get truncated */ addr += bytes;if (sz == msh) {xmit_seg (s);memmove (tp->data, tp->header, tp->tso_props.hdr_len); tp->size = tp->tso_props.hdr_len; } +assert (split_size >= bytes); split_size -= bytes; }while (bytes && split_size); }else { split_size =MIN (sizeof (tp->data) - tp->size, split_size); +assert (tp->size && split_size);pci_dma_read (d, addr, tp->data + tp->size, split_size); tp->size += split_size; }if (!(txd_lower &E1000_TXD_CMD_EOP ))return ; +assert (tp->size && tp->tso_props.hdr_len);if (!(tp->cptse && tp->size < tp->tso_props.hdr_len)) {xmit_seg (s); }Signature · 1 line
2.29.2
+-- On Thu, 18 Feb 2021, Alexander Bulekov wrote --+ | Is this a DMA re-entracy/stack-overflow issue? IIRC the plan was to have | some sort of wider fix for these issues. There are bunch of these reports | floating around at this point, I believe.
* It is similar to the eepro100 one.
Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D
Quoted 9 lines · Alexander Bulekov
Quoted 6 lines · P J P
From: Prasad J Pandit <[email protected]>
While processing transmit (tx) descriptors in
process_tx_desc()various descriptor fields are not checked properly. This may lead to infinite loop like issue. Add checks to avoid them.
Quoted 5 lines
+CC Peter Maydell
Is this a DMA re-entracy/stack-overflow issue? IIRC the plan was to have some sort of wider fix for these issues. There are bunch of these reports floating around at this point, I believe.
I have no idea, because the commit message for this patch does not describe the failure in any detail at all and has no links to any bug report or test case for the failures it claims to be fixing...
-- PMM