From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VPylLprO; dkim-atps=neutral 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 7F2105A026E for ; Thu, 09 Jul 2026 23:57:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783634227; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JWcc6Zq5kxepioyY8s6Te4ANL+32AL9R7Y4RBbgbk64=; b=VPylLprOVMAqNVh+JYAbatQpCDdvnegdE1NB0s82v7jfrwpkcEiAY0p/zk/N8ssXs34bUZ l0fFq7JWyAMSyefdFrG8Tj8ayXikykJej2dSKiXXoVc3MKadQLB8hTQJbTs1zyXJ1TSyaM I1r1IFZ1rUfTdAgOT2yA0LQY7hy4grc= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-588-kIVw1GQWPNqbxBW3848rdA-1; Thu, 09 Jul 2026 17:57:06 -0400 X-MC-Unique: kIVw1GQWPNqbxBW3848rdA-1 X-Mimecast-MFC-AGG-ID: kIVw1GQWPNqbxBW3848rdA_1783634225 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 476DF1955F44; Thu, 9 Jul 2026 21:57:05 +0000 (UTC) Received: from jmaloy-thinkpadp16vgen1.rmtcaqc.csb (unknown [10.22.88.44]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0B103195608A; Thu, 9 Jul 2026 21:57:03 +0000 (UTC) From: Jon Maloy To: sbrivio@redhat.com, david@gibson.dropbear.id.au, jmaloy@redhat.com, passt-dev@passt.top Subject: [PATCH v2 3/6] tap: Guard IPv6 tail size subtraction against underflow Date: Thu, 9 Jul 2026 17:56:53 -0400 Message-ID: <20260709215656.1351549-4-jmaloy@redhat.com> In-Reply-To: <20260709215656.1351549-1-jmaloy@redhat.com> References: <20260709215656.1351549-1-jmaloy@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: pC0cA-5a4TfzmoTadHZ533T8paspxO91iOX9yywZ4gk_1783634225 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: AZ2XT37YANVECZ7A3OOYMUX3M6WVSXFE X-Message-ID-Hash: AZ2XT37YANVECZ7A3OOYMUX3M6WVSXFE X-MailFrom: jmaloy@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 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: In tap6_handler(), iov_tail_size(&data) - sizeof(*ip6h) computes the expected payload length. IOV_PEEK_HEADER() guarantees at least sizeof(*ip6h) bytes, but add an explicit check to guard the unsigned subtraction. A too-small tail would indicate a malformed packet, so skip it. Signed-off-by: Jon Maloy --- v2: Use if-guard instead of assert(), to avoid runtime cost in per-packet path and to let the static checker follow the logic. --- tap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tap.c b/tap.c index 6d93c7ce..6fd5f595 100644 --- a/tap.c +++ b/tap.c @@ -986,7 +986,10 @@ resume: if (!ip6h) continue; - check = iov_tail_size(&data) - sizeof(*ip6h); + check = iov_tail_size(&data); + if (check < sizeof(*ip6h)) + continue; + check -= sizeof(*ip6h); saddr = &ip6h->saddr; daddr = &ip6h->daddr; -- 2.52.0