From patchwork Mon Sep 9 04:55:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1982314 X-Patchwork-Delegate: echaudro@redhat.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FymrcmCx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X2Dzr259dz1y1l for ; Mon, 9 Sep 2024 14:55:36 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id B94CA4064D; Mon, 9 Sep 2024 04:55:34 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id aN4YO9F0Z9zM; Mon, 9 Sep 2024 04:55:32 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org C2050405E9 Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FymrcmCx Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id C2050405E9; Mon, 9 Sep 2024 04:55:31 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 050FDC0030; Mon, 9 Sep 2024 04:55:31 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3863CC001E for ; Mon, 9 Sep 2024 04:55:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 74D6060768 for ; Mon, 9 Sep 2024 04:55:25 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id orneHYqbck9s for ; Mon, 9 Sep 2024 04:55:24 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=mkp@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org ECA6B60748 Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org ECA6B60748 Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FymrcmCx Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id ECA6B60748 for ; Mon, 9 Sep 2024 04:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725857722; 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=YvitJZK6J48TpB0WV6eJWGXXLgr96igthD99E4aHjbA=; b=FymrcmCx1hrjZ3+XxO0+/iwKHgX/0SGXGBbe/2WUyr+dQO/jpL0BXzenVJX21JALcFBnwn 45Y8GVIOT+BWEMFajtQQWTVV5LAPEiMAxMgcyi27M2UcmyEu9q49Kh7+f1R2Z8+27m9lvf Kx+TqJmuysHQD2vc3GyUHHzUU8D1BgM= Received: from mx-prod-mc-02.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-20-_J6tp27NNomtHjkoUPmyNw-1; Mon, 09 Sep 2024 00:55:21 -0400 X-MC-Unique: _J6tp27NNomtHjkoUPmyNw-1 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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 98BC01953942 for ; Mon, 9 Sep 2024 04:55:20 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.9.170]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 78EC81956053; Mon, 9 Sep 2024 04:55:19 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Mon, 9 Sep 2024 00:55:05 -0400 Message-ID: <20240909045505.236657-9-mkp@redhat.com> In-Reply-To: <20240909045505.236657-1-mkp@redhat.com> References: <20240909045505.236657-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v3 8/8] mcast-snooping: Don't access ovs_list members directly. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" The Clang analyzer has trouble tracking the pointer usage in mrouter_get_lru and will report a use after free incorrectly. This patch migrates to using standard ovs_list functions instead of directly accessing the next member, which suppresses clang's warning. Acked-by: Eelco Chaudron Signed-off-by: Mike Pattrick Acked-by: Eelco Chaudron Acked-by: Simon Horman --- lib/mcast-snooping.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mcast-snooping.c b/lib/mcast-snooping.c index bf25e6f20..b279c1229 100644 --- a/lib/mcast-snooping.c +++ b/lib/mcast-snooping.c @@ -653,7 +653,7 @@ mrouter_get_lru(const struct mcast_snooping *ms, OVS_REQ_RDLOCK(ms->rwlock) { if (!ovs_list_is_empty(&ms->mrouter_lru)) { - *m = mcast_mrouter_from_lru_node(ms->mrouter_lru.next); + *m = mcast_mrouter_from_lru_node(ovs_list_front(&ms->mrouter_lru)); return true; } else { *m = NULL; @@ -726,7 +726,7 @@ mcast_snooping_port_get(const struct ovs_list *list, struct mcast_port_bundle **f) { if (!ovs_list_is_empty(list)) { - *f = mcast_port_from_list_node(list->next); + *f = mcast_port_from_list_node(ovs_list_front(list)); return true; } else { *f = NULL;