qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw/net/dp8393x: fix integer underflow in dp8393x_do_transmit_packets()
@ 2020-11-24  9:24 Mauro Matteo Cascella
  2020-11-30 10:44 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 5+ messages in thread
From: Mauro Matteo Cascella @ 2020-11-24  9:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: jasowang, pgn, mcascell

An integer underflow could occur during packet transmission due to 'tx_len' not
being updated if SONIC_TFC register is set to zero. Check for negative 'tx_len'
when removing existing FCS.

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1899722
Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
Reported-by: Gaoning Pan <pgn@zju.edu.cn>
---
 hw/net/dp8393x.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
index 674b04b354..205c0decc5 100644
--- a/hw/net/dp8393x.c
+++ b/hw/net/dp8393x.c
@@ -495,6 +495,10 @@ static void dp8393x_do_transmit_packets(dp8393xState *s)
         } else {
             /* Remove existing FCS */
             tx_len -= 4;
+            if (tx_len < 0) {
+                SONIC_ERROR("tx_len is %d\n", tx_len);
+                break;
+            }
         }
 
         if (s->regs[SONIC_RCR] & (SONIC_RCR_LB1 | SONIC_RCR_LB0)) {
-- 
2.28.0



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

end of thread, other threads:[~2020-12-01 12:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-24  9:24 [PATCH] hw/net/dp8393x: fix integer underflow in dp8393x_do_transmit_packets() Mauro Matteo Cascella
2020-11-30 10:44 ` Philippe Mathieu-Daudé
2020-11-30 12:11   ` Mauro Matteo Cascella
2020-12-01  5:46     ` Jason Wang
2020-12-01 12:09       ` Peter Maydell

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).