Skip to contentSkip to conversation

Fix calculation of minimum in colo_compare_tcp

PATCH In review Stefan Weil via 3 participants 5 messages Sep 9, 2024 – Oct 18, 2024 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix calculation of minimum in colo_compare_tcp

GitHub's CodeQL reports a critical error which is fixed by using the MIN macro:

Unsigned difference expression compared to zero

---
 net/colo-compare.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/colo-compare.c +1 -2
index c4ad0ab71f..39f90c4065 100644
@@ -412,8 +412,7 @@ static void colo_compare_tcp(CompareState *s, Connection *conn)
      * can ensure that the packet's payload is acknowledged by
      * primary and secondary.
     */
-    uint32_t min_ack = conn->pack - conn->sack > 0 ?
-                       conn->sack : conn->pack;
+    uint32_t min_ack = MIN(conn->pack, conn->sack);
 
 pri:
     if (g_queue_is_empty(&conn->primary_list)) {
Signature · 1 line
2.39.3 (Apple Git-146)
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines

-----Original Message-----
From: Stefan Weil <[email protected]>
Sent: Tuesday, September 10, 2024 4:43 AM
To: Zhang, Chen <[email protected]>; Li Zhijian <[email protected]>; Jason Wang <[email protected]>
Cc: [email protected]; Stefan Weil <[email protected]>
Subject: [PATCH] Fix calculation of minimum in colo_compare_tcp

Quoted 6 lines

GitHub's CodeQL reports a critical error which is fixed by using the MIN macro:

Unsigned difference expression compared to zero

Looks good to me.

Thanks
Chen

Quoted 21 lines
---
 net/colo-compare.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/colo-compare.c index renamed from net/colo-compare.c +0 -0

c4ad0ab71f..39f90c4065 100644

net/colo-compare.c +1 -2
@@ -412,8 +412,7 @@ static void colo_compare_tcp(CompareState *s,
 Connection *conn)
      * can ensure that the packet's payload is acknowledged by
      * primary and secondary.
     */
-    uint32_t min_ack = conn->pack - conn->sack > 0 ?
-                       conn->sack : conn->pack;
+    uint32_t min_ack = MIN(conn->pack, conn->sack);
 
 pri:
     if (g_queue_is_empty(&conn->primary_list)) {

--
2.39.3 (Apple Git-146)

#2 lore raw

It looks like nobody has sent a pull request for this fix up to now. Is it trivial enough for qemu-trivial? And maybe qemu-stable could also apply it to older versions.

Stefan W.

Am 10.09.24 um 04:38 schrieb Zhang, Chen:

Quoted 41 lines
Quoted 8 lines

-----Original Message-----
From: Stefan Weil<[email protected]>
Sent: Tuesday, September 10, 2024 4:43 AM
To: Zhang, Chen<[email protected]>; Li Zhijian<[email protected]>; Jason Wang<[email protected]>
Cc:[email protected]; Stefan Weil<[email protected]>
Subject: [PATCH] Fix calculation of minimum in colo_compare_tcp

Quoted 6 lines

GitHub's CodeQL reports a critical error which is fixed by using the MIN macro:

Unsigned difference expression compared to zero

Looks good to me.

Thanks
Chen

Quoted 21 lines
---
  net/colo-compare.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
net/colo-compare.c index renamed from net/colo-compare.c +0 -0

c4ad0ab71f..39f90c4065 100644

net/colo-compare.c +1 -2
@@ -412,8 +412,7 @@ static void colo_compare_tcp(CompareState *s,
 Connection *conn)
       * can ensure that the packet's payload is acknowledged by
       * primary and secondary.
      */
-    uint32_t min_ack = conn->pack - conn->sack > 0 ?
-                       conn->sack : conn->pack;
+    uint32_t min_ack = MIN(conn->pack, conn->sack);
 
  pri:
      if (g_queue_is_empty(&conn->primary_list)) {

--
2.39.3 (Apple Git-146)

Reviewed-by
#3 lore raw

Add Trivial patches Maintainers.

Hi Jason/Michael/Laurent,
Can you help to pick up this patch for upstream and stable?

Thanks
Chen

From: Stefan Weil <[email protected]>
Sent: Friday, October 18, 2024 3:44 AM
To: Zhang, Chen <[email protected]>; Li Zhijian <[email protected]>; Jason Wang <[email protected]>; qemu-stable <[email protected]>; QEMU Trivial <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] Fix calculation of minimum in colo_compare_tcp

It looks like nobody has sent a pull request for this fix up to now. Is it trivial enough for qemu-trivial? And maybe qemu-stable could also apply it to older versions.

Stefan W.
Am 10.09.24 um 04:38 schrieb Zhang, Chen:

-----Original Message-----

From: Stefan Weil <[email protected]><mailto:[email protected]>

Sent: Tuesday, September 10, 2024 4:43 AM

To: Zhang, Chen <[email protected]><mailto:[email protected]>; Li Zhijian <[email protected]><mailto:[email protected]>;

Jason Wang <[email protected]><mailto:[email protected]>

Subject: [PATCH] Fix calculation of minimum in colo_compare_tcp

GitHub's CodeQL reports a critical error which is fixed by using the MIN

macro:

Unsigned difference expression compared to zero

Looks good to me.

Thanks

Chen

---

 net/colo-compare.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/colo-compare.c index renamed from net/colo-compare.c +0 -0

c4ad0ab71f..39f90c4065 100644

--- a/net/colo-compare.c

+++ b/net/colo-compare.c

@@ -412,8 +412,7 @@ static void colo_compare_tcp(CompareState *s,

Connection *conn)

* can ensure that the packet's payload is acknowledged by

* primary and secondary.

*/

- uint32_t min_ack = conn->pack - conn->sack > 0 ?

- conn->sack : conn->pack;

+ uint32_t min_ack = MIN(conn->pack, conn->sack);

pri:

     if (g_queue_is_empty(&conn->primary_list)) {

--

2.39.3 (Apple Git-146)

#4 lore raw
Quoted 8 lines · Chen

Add Trivial patches Maintainers.

Hi Jason/Michael/Laurent,

Can you help to pick up this patch for upstream and stable?

Queued.

Btw, if you want -stable next time, please cc it.

Thanks

Quoted 106 lines

Thanks

Chen

From: Stefan Weil <[email protected]>
Sent: Friday, October 18, 2024 3:44 AM
To: Zhang, Chen <[email protected]>; Li Zhijian <[email protected]>; Jason Wang <[email protected]>; qemu-stable <[email protected]>; QEMU Trivial <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] Fix calculation of minimum in colo_compare_tcp

It looks like nobody has sent a pull request for this fix up to now. Is it trivial enough for qemu-trivial? And maybe qemu-stable could also apply it to older versions.

Stefan W.

Am 10.09.24 um 04:38 schrieb Zhang, Chen:

-----Original Message-----

From: Stefan Weil <[email protected]>

Sent: Tuesday, September 10, 2024 4:43 AM

To: Zhang, Chen <[email protected]>; Li Zhijian <[email protected]>;

Jason Wang <[email protected]>

Subject: [PATCH] Fix calculation of minimum in colo_compare_tcp

GitHub's CodeQL reports a critical error which is fixed by using the MIN

macro:

Unsigned difference expression compared to zero

Looks good to me.

Thanks

Chen

---

 net/colo-compare.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/colo-compare.c index renamed from net/colo-compare.c +0 -0

c4ad0ab71f..39f90c4065 100644

--- a/net/colo-compare.c

+++ b/net/colo-compare.c

net/colo-compare.c index renamed from net/colo-compare.c +1 -3
@@ -412,8 +412,7 @@ static void colo_compare_tcp(CompareState *s,
 
 Connection *conn)
 
      * can ensure that the packet's payload is acknowledged by
 
      * primary and secondary.
 
     */
 
-    uint32_t min_ack = conn->pack - conn->sack > 0 ?
 
-                       conn->sack : conn->pack;
 
+    uint32_t min_ack = MIN(conn->pack, conn->sack);
 
 
 
 pri:
 
     if (g_queue_is_empty(&conn->primary_list)) {
 
--

2.39.3 (Apple Git-146)