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=TqnMojtq; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id 9055D5A026D for ; Mon, 08 Jun 2026 02:50:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780879831; 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; bh=2VJ8nYNI6Gyia/HChHt4HQWU3Sxy8tqPr4BTbkywkGU=; b=TqnMojtqg2LhIwWTJ60QXBah0V4lCVU1L1/WKphP29KOXKWsBslDRyXNREBDWn+RZ7AKqM OY6BpP/h6iZp9ZzgTMwlnzkdz+XY1khfzjm6Le2Q1RGARCqW5HMfdA8GKhzcYlamRwPhw2 IjLisCowsZS2QFfJS8ff1yjY84hnxA8= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-225-sR2Ejz-tO0a0AD9UzBbU8Q-1; Sun, 07 Jun 2026 20:50:29 -0400 X-MC-Unique: sR2Ejz-tO0a0AD9UzBbU8Q-1 X-Mimecast-MFC-AGG-ID: sR2Ejz-tO0a0AD9UzBbU8Q_1780879829 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A390D1800366; Mon, 8 Jun 2026 00:50:28 +0000 (UTC) Received: from jmaloy-thinkpadp16vgen1.rmtcaqc.csb (unknown [10.22.80.65]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D0413195608E; Mon, 8 Jun 2026 00:50:26 +0000 (UTC) From: Jon Maloy To: sbrivio@redhat.com, david@gibson.dropbear.id.au, jmaloy@redhat.com, passt-dev@passt.top Subject: [PATCH v2] udp: Provide dummy iov in udp_peek_addr() to avoid Coverity warning Date: Sun, 7 Jun 2026 20:50:26 -0400 Message-ID: <20260608005026.515574-1-jmaloy@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ee6gq0LY38WLQ0WNSeftQqi41mC6FVtIGt_GaetOwR8_1780879829 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: 72XUBIK564BX5HQQFJSVR4URLHEVE7CV X-Message-ID-Hash: 72XUBIK564BX5HQQFJSVR4URLHEVE7CV 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: udp_peek_addr() initialises struct msghdr without setting msg_iov, leaving it implicitly NULL. Coverity flags this as FORWARD_NULL, believing recvmsg() will dereference the NULL pointer. In practice, msg_iovlen being zero means the kernel never touches msg_iov, so the warning is a false positive. We now provide a one-byte dummy iov to make msg_iov non-NULL, hence suppressing this warning without changing the function's behaviour. Signed-off-by: Jon Maloy ---- v2: - Make the dummy iov conditional on an ANALYZER macro, so it has zero runtime cost in production builds. - Add a new 'analyzer' Makefile target (similar to 'valgrind') that defines ANALYZER via CPPFLAGS for use with static analysis builds. --- Makefile | 3 +++ udp.c | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/Makefile b/Makefile index 0a0a60b0..4dcf4cd1 100644 --- a/Makefile +++ b/Makefile @@ -122,6 +122,9 @@ passt-repair: $(PASST_REPAIR_SRCS) $(PASST_REPAIR_HEADERS) seccomp_repair.h pesto: BASE_CPPFLAGS += -DPESTO pesto: $(PESTO_SRCS) $(PESTO_HEADERS) seccomp_pesto.h +analyzer: BASE_CPPFLAGS += -DANALYZER +analyzer: all + valgrind: EXTRA_SYSCALLS += rt_sigprocmask rt_sigtimedwait rt_sigaction \ rt_sigreturn getpid gettid kill clock_gettime \ mmap|mmap2 munmap open unlink gettimeofday futex \ diff --git a/udp.c b/udp.c index c28d6ee2..36c8c070 100644 --- a/udp.c +++ b/udp.c @@ -734,9 +734,20 @@ static int udp_peek_addr(int s, union sockaddr_inany *src, { char sastr[SOCKADDR_STRLEN], dstr[INANY_ADDRSTRLEN]; char cmsg[PKTINFO_SPACE]; +#ifdef ANALYZER + char dummy; + struct iovec iov = { + .iov_base = &dummy, + .iov_len = sizeof(dummy), + }; +#endif /* ANALYZER */ struct msghdr msg = { .msg_name = src, .msg_namelen = sizeof(*src), +#ifdef ANALYZER + .msg_iov = &iov, + .msg_iovlen = 1, +#endif /* ANALYZER */ .msg_control = cmsg, .msg_controllen = sizeof(cmsg), }; -- 2.52.0