From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=fail (p=quarantine dis=none) header.from=redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 1AF165A0271 for ; Tue, 10 Nov 2026 10:29:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794302973; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=abNs8mkhzV4Ujsc+/ftBVb7cS7cVj4JSHq9up08Oy5U=; b=Y3lrbocuKTiKHqSPVxPGISAmJlRbLwISfxdVof8DNtIIAH+a9j1VeOo1hL96w7Q0JSKL9Y 6ge4myeDVZ/jNTioyAX7YcbpLDz4SKZEVDLFfI268dL3XFlAzO/4k110mHZQJtL/l9wQEg 0+nJSCJA7Otd32LCExUk2xYW/rslsFg= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-76-Oa-3I_xBMs6p134VgX3e2w-1; Tue, 10 Nov 2026 04:29:29 -0500 X-MC-Unique: Oa-3I_xBMs6p134VgX3e2w-1 X-Mimecast-MFC-AGG-ID: Oa-3I_xBMs6p134VgX3e2w_1794302968 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-492e3189fc9so1384531f8f.1 for ; Tue, 10 Nov 2026 01:29:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794302968; x=1794907768; h=date:content-transfer-encoding:content-type:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=abNs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sqPMZij np3GwCg/b2axiaj1Ycq0588OKL5naS6XIANCmGCr6qxELs2L3SNi+blqnXgvmc/z4pEQ= X-Received: by 2002:a05:600c:3ba7:b0:4a2:1612:637a with SMTP id 5b1f17b1804b1-4ba0234621bmr38325515e9.16.1794302967999; Tue, 10 Nov 2026 01:29:27 -0800 (PST) X-Received: by 2002:a05:600c:3ba7:b0:4a2:1612:637a with SMTP id 5b1f17b1804b1-4ba0234621bmr38324665e9.16.1794302967397; Tue, 10 Nov 2026 01:29:27 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4ba01fe2cb2sm48767405e9.3.2026.11.10.01.29.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2026 01:29:26 -0800 (PST) From: Stefano Brivio To: Jon Maloy Subject: Re: [PATCH] tcp_vu: Fix assert/error-check order in tcp_vu_sock_recv() Message-ID: <20261110102925.1fbb87ff@elisabeth> In-Reply-To: <20261109221342.380271-1-jmaloy@redhat.com> References: <20261109221342.380271-1-jmaloy@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Tue, 10 Nov 2026 10:29:25 +0100 (CET) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 80a633J3jGMSuVLOxMgWPU4Fh6LCxypr04PA6Q4bA90_1794302968 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: DF2FFHEFRHKHZ7RMMPM27JCL4TBK6NTO X-Message-ID-Hash: DF2FFHEFRHKHZ7RMMPM27JCL4TBK6NTO X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: david@gibson.dropbear.id.au, passt-dev@passt.top, contact@jbartunek.de, Laurent Vivier X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: [Cc: Johannes, Laurent] Thanks for the patch and the explanation, but shouldn't this be: On Mon, 9 Nov 2026 17:13:42 -0500 Jon Maloy wrote: From: Johannes Bartunek and: > iov_tail_clone() returns a ssize_t. However, the assert comparing > it against (ARRAY_SIZE(iov_msg) - j), which yields size_t, comes > before the negative-value check. Hence, when iov_tail_clone() fails > and returns -1, the signed-to-unsigned promotion turns -1 into > SIZE_MAX, and causes the assert to fire. > > We fix this by moving the error check before the assert, while casting > the counter and the index inside the assert to size_t. Reported-by: Johannes Bartunek Suggested-by: Laurent Vivier ? > Signed-off-by: Jon Maloy > --- > tcp_vu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tcp_vu.c b/tcp_vu.c > index 868a35b9..c052d8e2 100644 > --- a/tcp_vu.c > +++ b/tcp_vu.c > @@ -291,9 +291,9 @@ static ssize_t tcp_vu_sock_recv(const struct ctx *c, struct vu_virtq *vq, > > cnt = iov_tail_clone(&iov_msg[j], ARRAY_SIZE(iov_msg) - j, > &data); > - assert(cnt < ARRAY_SIZE(iov_msg) - j); > if (cnt < 0) > die("Missing entries in iov_msg"); > + assert((size_t)cnt < ARRAY_SIZE(iov_msg) - (size_t)j); > > j += cnt; > } -- Stefano