public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] tcp_vu: Change 'dlen' to ssize_t in tcp_vu_data_from_sock()
@ 2024-11-27 14:43 Stefano Brivio
  2024-11-27 14:59 ` Laurent Vivier
  0 siblings, 1 reply; 2+ messages in thread
From: Stefano Brivio @ 2024-11-27 14:43 UTC (permalink / raw)
  To: passt-dev; +Cc: Laurent Vivier

...to quickly suppress a false positive from Coverity, which assumes
that iov_size is 0 and 'dlen' might overflow as a result (with hdrlen
being 66). An ASSERT() in tcp_vu_sock_recv() already guarantees that
iov_size(iov, buf_cnt) here is anyway greater than 'hdrlen'.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
This applies on top of "[PATCH] Fix build on 32bit target"

 tcp_vu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tcp_vu.c b/tcp_vu.c
index 05e2d1d..a1510d9 100644
--- a/tcp_vu.c
+++ b/tcp_vu.c
@@ -462,7 +462,7 @@ int tcp_vu_data_from_sock(const struct ctx *c, struct tcp_tap_conn *conn)
 	for (i = 0, check = NULL; i < head_cnt; i++) {
 		struct iovec *iov = &elem[head[i]].in_sg[0];
 		int buf_cnt = head[i + 1] - head[i];
-		int dlen = iov_size(iov, buf_cnt) - hdrlen;
+		ssize_t dlen = iov_size(iov, buf_cnt) - hdrlen;
 
 		vu_set_vnethdr(vdev, iov->iov_base, buf_cnt);
 
-- 
@@ -462,7 +462,7 @@ int tcp_vu_data_from_sock(const struct ctx *c, struct tcp_tap_conn *conn)
 	for (i = 0, check = NULL; i < head_cnt; i++) {
 		struct iovec *iov = &elem[head[i]].in_sg[0];
 		int buf_cnt = head[i + 1] - head[i];
-		int dlen = iov_size(iov, buf_cnt) - hdrlen;
+		ssize_t dlen = iov_size(iov, buf_cnt) - hdrlen;
 
 		vu_set_vnethdr(vdev, iov->iov_base, buf_cnt);
 
-- 
2.43.0


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

* Re: [PATCH] tcp_vu: Change 'dlen' to ssize_t in tcp_vu_data_from_sock()
  2024-11-27 14:43 [PATCH] tcp_vu: Change 'dlen' to ssize_t in tcp_vu_data_from_sock() Stefano Brivio
@ 2024-11-27 14:59 ` Laurent Vivier
  0 siblings, 0 replies; 2+ messages in thread
From: Laurent Vivier @ 2024-11-27 14:59 UTC (permalink / raw)
  To: Stefano Brivio, passt-dev

On 27/11/2024 15:43, Stefano Brivio wrote:
> ...to quickly suppress a false positive from Coverity, which assumes
> that iov_size is 0 and 'dlen' might overflow as a result (with hdrlen
> being 66). An ASSERT() in tcp_vu_sock_recv() already guarantees that
> iov_size(iov, buf_cnt) here is anyway greater than 'hdrlen'.
> 
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> ---
> This applies on top of "[PATCH] Fix build on 32bit target"
> 
>   tcp_vu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tcp_vu.c b/tcp_vu.c
> index 05e2d1d..a1510d9 100644
> --- a/tcp_vu.c
> +++ b/tcp_vu.c
> @@ -462,7 +462,7 @@ int tcp_vu_data_from_sock(const struct ctx *c, struct tcp_tap_conn *conn)
>   	for (i = 0, check = NULL; i < head_cnt; i++) {
>   		struct iovec *iov = &elem[head[i]].in_sg[0];
>   		int buf_cnt = head[i + 1] - head[i];
> -		int dlen = iov_size(iov, buf_cnt) - hdrlen;
> +		ssize_t dlen = iov_size(iov, buf_cnt) - hdrlen;
>   
>   		vu_set_vnethdr(vdev, iov->iov_base, buf_cnt);
>   

Reviewed-by: Laurent Vivier <lvivier@redhat.com>


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

end of thread, other threads:[~2024-11-27 14:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-27 14:43 [PATCH] tcp_vu: Change 'dlen' to ssize_t in tcp_vu_data_from_sock() Stefano Brivio
2024-11-27 14:59 ` Laurent Vivier

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).