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=TIDT1fMM; 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 0F9035A0283 for ; Tue, 13 May 2025 11:41:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747129272; 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=8zNNDzs3M9kqUgbzFkVruoHk1CFcHDAEYzfbCR/cllA=; b=TIDT1fMMxDqg68yAFkond+TEYf/GssCEDqtWPlKD98PVyMr97gws/ABppXOHG1Rm2PPV+o Y0qI8MjPz15P2nwm4Nf+F5HujQvI19NcABgHfmxANDRfwrTDzX3lHFyp260TQiqjs/RnKq ntm6rhNMOc2R3qBc3Q6jwp3IBH77e0Q= 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-508-_fVWBYNuN2WKvuwSwj4fdA-1; Tue, 13 May 2025 05:41:11 -0400 X-MC-Unique: _fVWBYNuN2WKvuwSwj4fdA-1 X-Mimecast-MFC-AGG-ID: _fVWBYNuN2WKvuwSwj4fdA_1747129270 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 BD5E71801A13 for ; Tue, 13 May 2025 09:41:10 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.44.33.64]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9A9EB1945CB4; Tue, 13 May 2025 09:41:09 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH 3/4] ndp: Fix Clang analyzer warning (clang-analyzer-security.PointerSub) Date: Tue, 13 May 2025 11:41:01 +0200 Message-ID: <20250513094102.1372330-4-lvivier@redhat.com> In-Reply-To: <20250513094102.1372330-1-lvivier@redhat.com> References: <20250513094102.1372330-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: E-zAJ4f-OSHkDzzNfXmDQTnponJFihAuc75c3WLMPzQ_1747129270 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: AN7E3UDGI7QAFJV45QWL2MMDVW2W7BCE X-Message-ID-Hash: AN7E3UDGI7QAFJV45QWL2MMDVW2W7BCE X-MailFrom: lvivier@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: 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: Addresses Clang warning: "Subtraction of two pointers that do not point into the same array is undefined behavior" for the line: `ndp_send(c, dst, &ra, ptr - (unsigned char *)&ra);` Here, `ptr` is `&ra.var[0]`. The subtraction calculates the offset of `var[0]` within the `struct ra_options ra`. Since `ptr` points inside `ra`, this pointer arithmetic is well-defined for calculating the size of the data to send, even if `ptr` and `&ra` are not strictly considered part of the same "array" by the analyzer. Signed-off-by: Laurent Vivier --- ndp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ndp.c b/ndp.c index ded2081ddd1d..b664034b00b1 100644 --- a/ndp.c +++ b/ndp.c @@ -328,6 +328,7 @@ static void ndp_ra(const struct ctx *c, const struct in6_addr *dst) memcpy(&ra.source_ll.mac, c->our_tap_mac, ETH_ALEN); + /* NOLINTNEXTLINE(clang-analyzer-security.PointerSub) */ ndp_send(c, dst, &ra, ptr - (unsigned char *)&ra); } -- 2.49.0