From 22dc8609c565456fda3de6ddc34e07af98f11203 Mon Sep 17 00:00:00 2001 From: Richard Scheffenegger Date: Tue, 17 Oct 2023 16:07:23 +0200 Subject: [PATCH] tcp: use signed IsLost() related accounting variables Coverity found that one safety check (kassert) was not functional, as possible incorrect subtractions during the accounting wouldn't show up as (invalid) negative values. Reported by: gallatin Reviewed By: cc, #transport Sponsored By: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D42180 --- sys/netinet/tcp_sack.c | 4 ++-- sys/netinet/tcp_var.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/netinet/tcp_sack.c b/sys/netinet/tcp_sack.c index 8647630bb6b..589b0c424ac 100644 --- a/sys/netinet/tcp_sack.c +++ b/sys/netinet/tcp_sack.c @@ -888,10 +888,10 @@ tcp_free_sackholes(struct tcpcb *tp) while ((q = TAILQ_FIRST(&tp->snd_holes)) != NULL) tcp_sackhole_remove(tp, q); tp->sackhint.sack_bytes_rexmit = 0; - tp->sackhint.sacked_bytes = 0; tp->sackhint.delivered_data = 0; - tp->sackhint.lost_bytes = 0; + tp->sackhint.sacked_bytes = 0; tp->sackhint.hole_bytes = 0; + tp->sackhint.lost_bytes = 0; KASSERT(tp->snd_numholes == 0, ("tp->snd_numholes == 0")); KASSERT(tp->sackhint.nexthole == NULL, diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 11509a87c6e..c6e24b187e0 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -128,8 +128,8 @@ struct sackhint { uint32_t recover_fs; /* Flight Size at the start of Loss recovery */ uint32_t prr_delivered; /* Total bytes delivered using PRR */ uint32_t prr_out; /* Bytes sent during IN_RECOVERY */ - uint32_t hole_bytes; /* current number of bytes in scoreboard holes */ - uint32_t lost_bytes; /* number of rfc6675 IsLost() bytes */ + int32_t hole_bytes; /* current number of bytes in scoreboard holes */ + int32_t lost_bytes; /* number of rfc6675 IsLost() bytes */ }; #define SEGQ_EMPTY(tp) TAILQ_EMPTY(&(tp)->t_segq)