From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202602 header.b=dE2pkhvr; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 9B26E5A0275 for ; Mon, 11 May 2026 12:03:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1778493804; bh=128QdFxTTALWLrqwGGl+HojoOu+gDc0unh4UihLlnqY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dE2pkhvr3zHUDQkF5Pp8ErAKgtEazgMqrQsjHRSVIJcg4Ojq72cHehAPtAcgk4QeD Sv34CXM0f1Fn/Lzqgfy9iRoXVRGGI/YiOvQSMOASEMZUYMN9W3X7SW4c02UxEYRHuo c22y3xddcM8HBbSVw17w6YAAI+m72kVicOREoEpXNoH8DTZ8iR5HXf6rExkvMXuFOg HieRlXpjbMh3/+r5gJuB89euix2YQh32ySX/hkTxlLkipW6CXZ8g1RCB5jGWZG0u9q cii2GE2W2V/BE7MhfW3dlqvVuOGoDIXs0ZxOXTNf3TpcIHuoH6oo5lrwpf+YjgzXOv kL5umaC/ALcwA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gDZzw1jfGz4wJq; Mon, 11 May 2026 20:03:24 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 6/8] packet, clang-tidy: Packet pool buffers are not NULL Date: Mon, 11 May 2026 20:03:20 +1000 Message-ID: <20260511100322.1016757-7-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260511100322.1016757-1-david@gibson.dropbear.id.au> References: <20260511100322.1016757-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: YIDWEDVMH5VUOKEW6WNGKHFYPFSQMZMT X-Message-ID-Hash: YIDWEDVMH5VUOKEW6WNGKHFYPFSQMZMT X-MailFrom: dgibson@gandalf.ozlabs.org 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 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: struct pool always needs a non-NULL buf field: it points either to the actual memory used to store packets, or for vhost-user to the vhost user memory structure which will contain the packets. We set this pointer when we initialise the pool. However, clang-tidy (as of 22.1.4, at least) doesn't realise this in packet_check_range(), causing UB warnings due to the subtraction of ptr and p->buf. Clue it in with an assert(). Signed-off-by: David Gibson --- packet.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packet.c b/packet.c index 1cb74b74..7a347be6 100644 --- a/packet.c +++ b/packet.c @@ -51,6 +51,8 @@ static int packet_check_range(const struct pool *p, const char *ptr, size_t len, { struct vdev_memory *memory; + assert(p->buf); + if (len > PACKET_MAX_LEN) { debug("packet range length %zu (max %zu), %s:%i", len, PACKET_MAX_LEN, func, line); -- 2.54.0