From patchwork Tue Aug 20 13:14:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1974412 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=OgVws9EJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (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 4Wp91K1YxPz1yfg for ; Tue, 20 Aug 2024 23:15:01 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 1852280B12; Tue, 20 Aug 2024 13:14:59 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 7EDEs0sWirIm; Tue, 20 Aug 2024 13:14:58 +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 smtp1.osuosl.org CA50180ABE Authentication-Results: smtp1.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=OgVws9EJ Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id CA50180ABE; Tue, 20 Aug 2024 13:14:57 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4B3EFC102A; Tue, 20 Aug 2024 13:14:57 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3C637C087F for ; Tue, 20 Aug 2024 13:14:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 2BD1980AB0 for ; Tue, 20 Aug 2024 13:14:55 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id v4h_DYVl-M5p for ; Tue, 20 Aug 2024 13:14:54 +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 smtp1.osuosl.org 73D8480AA3 Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 73D8480AA3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 73D8480AA3 for ; Tue, 20 Aug 2024 13:14:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724159693; 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=e8oojZiNxyckeE2D+WpoBLoJUXIFJ6uktwjSU6/srF8=; b=OgVws9EJkUz4gM86IxhdmFfvDCjcjzpVuWR6AOXQ0YuBla43rGp2r6zRT0Nwuj4oEMA3Il dfqRuKBHq9mUeZCEFpuHuylQM6GKVsfHZ/39f//UO5izI2FXXWzC8o/z/88LuOpRfRrE/b RYYpi00xGtV3G338yKJh2Pu3HOOLnuo= Received: from mx-prod-mc-01.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-576-OwmVzRX5MXOGd31JbHMTQQ-1; Tue, 20 Aug 2024 09:14:52 -0400 X-MC-Unique: OwmVzRX5MXOGd31JbHMTQQ-1 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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5D9AC195421E for ; Tue, 20 Aug 2024 13:14:51 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.33.24]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 95ADE1955DD6; Tue, 20 Aug 2024 13:14:50 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Tue, 20 Aug 2024 09:14:37 -0400 Message-ID: <20240820131444.1724438-2-mkp@redhat.com> In-Reply-To: <20240820131444.1724438-1-mkp@redhat.com> References: <20240820131444.1724438-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH 1/8] ovsdb-error: Annotate nonnull functions 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 detecting that functions can never return null in certain conditions, this results in several false "Dereference of null pointer" detections. This patch annotates functiosn that call ovsdb_error_valist() unconditionally as nonnull, as this function will either return a valid pointer or call abort(). Signed-off-by: Mike Pattrick --- lib/ovsdb-error.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ovsdb-error.h b/lib/ovsdb-error.h index 77a60e074..a63e92b15 100644 --- a/lib/ovsdb-error.h +++ b/lib/ovsdb-error.h @@ -20,12 +20,15 @@ struct json; +OVS_RETURNS_NONNULL struct ovsdb_error *ovsdb_error(const char *tag, const char *details, ...) OVS_PRINTF_FORMAT(2, 3) OVS_WARN_UNUSED_RESULT; +OVS_RETURNS_NONNULL struct ovsdb_error *ovsdb_io_error(int error, const char *details, ...) OVS_PRINTF_FORMAT(2, 3) OVS_WARN_UNUSED_RESULT; +OVS_RETURNS_NONNULL struct ovsdb_error *ovsdb_syntax_error(const struct json *, const char *tag, const char *details, ...) OVS_PRINTF_FORMAT(3, 4) @@ -35,12 +38,14 @@ struct ovsdb_error *ovsdb_wrap_error(struct ovsdb_error *error, const char *details, ...) OVS_PRINTF_FORMAT(2, 3); +OVS_RETURNS_NONNULL struct ovsdb_error *ovsdb_internal_error(struct ovsdb_error *error, const char *file, int line, const char *details, ...) OVS_PRINTF_FORMAT(4, 5) OVS_WARN_UNUSED_RESULT; +OVS_RETURNS_NONNULL struct ovsdb_error *ovsdb_perm_error(const char *details, ...) OVS_PRINTF_FORMAT(1, 2) OVS_WARN_UNUSED_RESULT; From patchwork Tue Aug 20 13:14:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1974414 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=ZJY5bDRy; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (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 4Wp91N2y7Mz1ygh for ; Tue, 20 Aug 2024 23:15:04 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id DE9BB608C2; Tue, 20 Aug 2024 13:15:00 +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 g7GVppECf1AD; Tue, 20 Aug 2024 13:14:59 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org EF7F3608D4 Authentication-Results: smtp3.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=ZJY5bDRy Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id EF7F3608D4; Tue, 20 Aug 2024 13:14:58 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B4091C102B; Tue, 20 Aug 2024 13:14:58 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id CB83FC1029 for ; Tue, 20 Aug 2024 13:14:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id AB59C405B8 for ; Tue, 20 Aug 2024 13:14:56 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id VFyMrHSp3A29 for ; Tue, 20 Aug 2024 13:14:56 +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 smtp4.osuosl.org BF698405B7 Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org BF698405B7 Authentication-Results: smtp4.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZJY5bDRy Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id BF698405B7 for ; Tue, 20 Aug 2024 13:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724159694; 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=kCCCtucAW5eYoHFK/IIfF6hJttHl8SgnR1phLRoYitg=; b=ZJY5bDRya8Iec/OCDXSGXIOKiUfzemdM4psAUKJdW9/klmpG4FlAWGmi28umQMtt67Wl2m y+MvLcndZKEVQTUwy0BJlhshXccaBo2HIPbalEaUKkmnnEJRcgbERO/Xv2py/tIN8Hp62d ccRfJFPFhVOxTAFoUrjqM6Tf9MGwhGg= 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-60-Q6DJ065iNlap657Kyw0HFA-1; Tue, 20 Aug 2024 09:14:53 -0400 X-MC-Unique: Q6DJ065iNlap657Kyw0HFA-1 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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A4C771954B22 for ; Tue, 20 Aug 2024 13:14:52 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.33.24]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AEC1A1955DD6; Tue, 20 Aug 2024 13:14:51 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Tue, 20 Aug 2024 09:14:38 -0400 Message-ID: <20240820131444.1724438-3-mkp@redhat.com> In-Reply-To: <20240820131444.1724438-1-mkp@redhat.com> References: <20240820131444.1724438-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH 2/8] dpif-netdev: Remove undefined integer division. 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" Clang analyzer will complain about floating point operations conducted with integer types as rounding is undefined. In pmd_info_show_rxq() a percentage was calculated inside uint64 integers instead of a floating pointer variable for a user visible message. There isn't a good reason not to use dloating point types here. Signed-off-by: Mike Pattrick Acked-by: Simon Horman --- lib/dpif-netdev.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index f0594e5f5..69d5ddfa1 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -900,8 +900,8 @@ pmd_info_show_rxq(struct ds *reply, struct dp_netdev_pmd_thread *pmd, if (pmd->core_id != NON_PMD_CORE_ID) { struct rxq_poll *list; size_t n_rxq; - uint64_t total_pmd_cycles = 0; - uint64_t busy_pmd_cycles = 0; + double total_pmd_cycles = 0; + double busy_pmd_cycles = 0; uint64_t total_rxq_proc_cycles = 0; unsigned int intervals; @@ -930,7 +930,7 @@ pmd_info_show_rxq(struct ds *reply, struct dp_netdev_pmd_thread *pmd, for (int i = 0; i < n_rxq; i++) { struct dp_netdev_rxq *rxq = list[i].rxq; const char *name = netdev_rxq_get_name(rxq->rx); - uint64_t rxq_proc_cycles = 0; + double rxq_proc_cycles = 0; rxq_proc_cycles = get_interval_values(rxq->cycles_intrvl, &rxq->intrvl_idx, @@ -942,9 +942,8 @@ pmd_info_show_rxq(struct ds *reply, struct dp_netdev_pmd_thread *pmd, ? "(enabled) " : "(disabled)"); ds_put_format(reply, " pmd usage: "); if (total_pmd_cycles) { - ds_put_format(reply, "%2"PRIu64"", - rxq_proc_cycles * 100 / total_pmd_cycles); - ds_put_cstr(reply, " %"); + ds_put_format(reply, "%2.0f %%", + (rxq_proc_cycles * 100) / total_pmd_cycles); } else { ds_put_format(reply, "%s", "NOT AVAIL"); } @@ -954,13 +953,14 @@ pmd_info_show_rxq(struct ds *reply, struct dp_netdev_pmd_thread *pmd, if (n_rxq > 0) { ds_put_cstr(reply, " overhead: "); if (total_pmd_cycles) { - uint64_t overhead_cycles = 0; + double overhead_cycles = 0; if (total_rxq_proc_cycles < busy_pmd_cycles) { overhead_cycles = busy_pmd_cycles - total_rxq_proc_cycles; } - ds_put_format(reply, "%2"PRIu64" %%", - overhead_cycles * 100 / total_pmd_cycles); + + ds_put_format(reply, "%2.0f %%", + (overhead_cycles * 100) / total_pmd_cycles); } else { ds_put_cstr(reply, "NOT AVAIL"); } From patchwork Tue Aug 20 13:14:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1974413 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=L9kAfVPI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::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 4Wp91N0fNHz1yfg for ; Tue, 20 Aug 2024 23:15:04 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 5434C40A44; Tue, 20 Aug 2024 13:15:02 +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 LV01Af3Z2248; Tue, 20 Aug 2024 13:15:01 +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 353BA40A38 Authentication-Results: smtp2.osuosl.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=L9kAfVPI Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 353BA40A38; Tue, 20 Aug 2024 13:15:01 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 069EFC1029; Tue, 20 Aug 2024 13:15:01 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 80E8EC102A for ; Tue, 20 Aug 2024 13:14:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 535F380AD9 for ; Tue, 20 Aug 2024 13:14:58 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id TroFzr7T5cau for ; Tue, 20 Aug 2024 13:14:57 +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 smtp1.osuosl.org B8BAA80ABF Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org B8BAA80ABF Authentication-Results: smtp1.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=L9kAfVPI Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id B8BAA80ABF for ; Tue, 20 Aug 2024 13:14:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724159695; 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=utnmuv+cUevnkZ2vLpskU0qb+NXcj8AHB1rpi72e9XE=; b=L9kAfVPI3DGqNVY3Tk9QcNaUOPsrqvZc5JGvG4wZwp1t2HpcSQ4y3JSYVOZW8zEStNInMU SzHpuFH9BV/GJ+q3KZ9fdX/PyPWsLt3GQxdemx9R3eV8IDYnlEB7+tg0goN6ZVArKflthN RwR5XtjYEmbUCka2d3TaXbsuEb8Ag58= 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-648-ntJog5AyO-ScwK5vVntrlA-1; Tue, 20 Aug 2024 09:14:54 -0400 X-MC-Unique: ntJog5AyO-ScwK5vVntrlA-1 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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 87BEF1955BF1 for ; Tue, 20 Aug 2024 13:14:53 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.33.24]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B83A81954B01; Tue, 20 Aug 2024 13:14:52 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Tue, 20 Aug 2024 09:14:39 -0400 Message-ID: <20240820131444.1724438-4-mkp@redhat.com> In-Reply-To: <20240820131444.1724438-1-mkp@redhat.com> References: <20240820131444.1724438-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH 3/8] jsonrpc: 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 jsonrpc_run 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 supresses clang's warning. Signed-off-by: Mike Pattrick Acked-by: Simon Horman --- lib/jsonrpc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c index f1ef70950..2e35180f8 100644 --- a/lib/jsonrpc.c +++ b/lib/jsonrpc.c @@ -120,7 +120,8 @@ jsonrpc_run(struct jsonrpc *rpc) stream_run(rpc->stream); while (!ovs_list_is_empty(&rpc->output)) { - struct ofpbuf *buf = ofpbuf_from_list(rpc->output.next); + struct ovs_list *head = ovs_list_front(&rpc->output); + struct ofpbuf *buf = ofpbuf_from_list(head); int retval; retval = stream_send(rpc->stream, buf->data, buf->size); @@ -128,7 +129,7 @@ jsonrpc_run(struct jsonrpc *rpc) rpc->backlog -= retval; ofpbuf_pull(buf, retval); if (!buf->size) { - ovs_list_remove(&buf->list_node); + ovs_list_remove(head); rpc->output_count--; ofpbuf_delete(buf); } From patchwork Tue Aug 20 13:14:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1974415 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=OgraNyTo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (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 4Wp91R0Gzzz1yXZ for ; Tue, 20 Aug 2024 23:15:07 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id A606140613; Tue, 20 Aug 2024 13:15:04 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id m6IsNYF8yYFV; Tue, 20 Aug 2024 13:15:03 +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 smtp4.osuosl.org 27C26405F5 Authentication-Results: smtp4.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=OgraNyTo Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 27C26405F5; Tue, 20 Aug 2024 13:15:03 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9F9C6C1029; Tue, 20 Aug 2024 13:15:02 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id C90A5C102D for ; Tue, 20 Aug 2024 13:14:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id A5D77405D5 for ; Tue, 20 Aug 2024 13:14:58 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Uy6T-Gwvb7m3 for ; Tue, 20 Aug 2024 13:14:58 +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 smtp4.osuosl.org B9318405C8 Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org B9318405C8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id B9318405C8 for ; Tue, 20 Aug 2024 13:14:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724159696; 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=KCZO6NOv0qquK4oPU8nZCA/zSu0zDQ1QrdDzYglLJxQ=; b=OgraNyToL01ca7ugpKwUH5+FL44LlPFN1sRGy6KJYRdmw+cWJw4DPSanVsb0Yvlp+PB/xq 7NG36qfluKMoXz1Wy5lyhe02EOVlQDbIYEygskNFiEKldkVMBgKp+1PAeEetTIMc2dkfIZ T5wCwQ9I6ae14WHba6syO31bF43RQEQ= 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-612-L3u6diQhMGyRQ7CHos-IsA-1; Tue, 20 Aug 2024 09:14:55 -0400 X-MC-Unique: L3u6diQhMGyRQ7CHos-IsA-1 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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9667A1955EA1 for ; Tue, 20 Aug 2024 13:14:54 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.33.24]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D93531954B04; Tue, 20 Aug 2024 13:14:53 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Tue, 20 Aug 2024 09:14:40 -0400 Message-ID: <20240820131444.1724438-5-mkp@redhat.com> In-Reply-To: <20240820131444.1724438-1-mkp@redhat.com> References: <20240820131444.1724438-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH 4/8] netlink-socket: Initialize socket family. 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 will alert on the use of uninitilized variable local despite the fact that this should be set by a syscall. To suprress the warning, this variable is now initialized. Signed-off-by: Mike Pattrick --- lib/netlink-socket.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c index 5cb1fc89a..737e49cfc 100644 --- a/lib/netlink-socket.c +++ b/lib/netlink-socket.c @@ -233,6 +233,7 @@ nl_sock_create(int protocol, struct nl_sock **sockp) /* Obtain pid assigned by kernel. */ local_size = sizeof local; + local.nl_family = AF_UNSPEC; if (getsockname(sock->fd, (struct sockaddr *) &local, &local_size) < 0) { VLOG_ERR("getsockname: %s", ovs_strerror(errno)); goto error; From patchwork Tue Aug 20 13:14:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1974416 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=RfDKfS/I; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (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 4Wp91V734lz1yXf for ; Tue, 20 Aug 2024 23:15:10 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id D2FAD60A3B; Tue, 20 Aug 2024 13:15:08 +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 A2H9tgSnVHDi; Tue, 20 Aug 2024 13:15:06 +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 smtp3.osuosl.org C284D608F4 Authentication-Results: smtp3.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=RfDKfS/I Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id C284D608F4; Tue, 20 Aug 2024 13:15:05 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id ABF1FC1029; Tue, 20 Aug 2024 13:15:04 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 767E6C102A for ; Tue, 20 Aug 2024 13:15:00 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 20792405F7 for ; Tue, 20 Aug 2024 13:15:00 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id LFz4dQc5r5uD for ; Tue, 20 Aug 2024 13:14:59 +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 smtp4.osuosl.org CE4DE405D5 Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org CE4DE405D5 Authentication-Results: smtp4.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RfDKfS/I Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id CE4DE405D5 for ; Tue, 20 Aug 2024 13:14:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724159697; 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=Vi6o/HuvZU6f4pIkVI3TwqWJHu5BI62k06IkJ0/ZnDY=; b=RfDKfS/ImPa6SVKignnIzbyKl4bYzNu2KvgL0iQi92LaOCWGx5AsgHTnvaSCShM7L8zPUR l34OOGOrKQj9rkiu8xnHt+4xDFVEEnlL+iRrPhfK5Hp/+CNh8/YxYzODiiVeV1p9/0+Zg9 yr293wnUvGnKKEt3g0K7xrU/jgUHw/s= Received: from mx-prod-mc-04.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-216-03HxiTb9OiiAeo7CDqqqVw-1; Tue, 20 Aug 2024 09:14:56 -0400 X-MC-Unique: 03HxiTb9OiiAeo7CDqqqVw-1 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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C13C41955D45 for ; Tue, 20 Aug 2024 13:14:55 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.33.24]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E217F1955DD6; Tue, 20 Aug 2024 13:14:54 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Tue, 20 Aug 2024 09:14:41 -0400 Message-ID: <20240820131444.1724438-6-mkp@redhat.com> In-Reply-To: <20240820131444.1724438-1-mkp@redhat.com> References: <20240820131444.1724438-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH 5/8] classifier: Store n_indices between usage. 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" Currently the Clang analyzer will complain about usage of an uninitialized variable in the classifier. This is a false positive, but not for a reason that could easily be detectable by clang. The classifier is not safe for multiple writer threads to use simultaniously so all callers protect these functions from simultanious writes. However, this is not so clear from the code's static analysis alone. To help Clang out here, the n_indicies count is saved onto the stack instead of accessed from the subtables struct repeatedly. Signed-off-by: Mike Pattrick Acked-by: Simon Horman --- lib/classifier.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/classifier.c b/lib/classifier.c index 0729bd190..55f23b976 100644 --- a/lib/classifier.c +++ b/lib/classifier.c @@ -527,6 +527,7 @@ classifier_replace(struct classifier *cls, const struct cls_rule *rule, struct cls_match *head; unsigned int mask_offset; size_t n_rules = 0; + uint8_t n_indices; uint32_t basis; uint32_t hash; unsigned int i; @@ -543,7 +544,8 @@ classifier_replace(struct classifier *cls, const struct cls_rule *rule, /* Compute hashes in segments. */ basis = 0; mask_offset = 0; - for (i = 0; i < subtable->n_indices; i++) { + n_indices = subtable->n_indices; + for (i = 0; i < n_indices; i++) { ihash[i] = minimatch_hash_range(&rule->match, subtable->index_maps[i], &mask_offset, &basis); } @@ -575,7 +577,7 @@ classifier_replace(struct classifier *cls, const struct cls_rule *rule, } /* Add new node to segment indices. */ - for (i = 0; i < subtable->n_indices; i++) { + for (i = 0; i < n_indices; i++) { ccmap_inc(&subtable->indices[i], ihash[i]); } n_rules = cmap_insert(&subtable->rules, &new->cmap_node, hash); @@ -713,6 +715,7 @@ classifier_remove(struct classifier *cls, const struct cls_rule *cls_rule) struct cls_subtable *subtable; uint32_t basis = 0, hash, ihash[CLS_MAX_INDICES]; unsigned int mask_offset; + uint8_t n_indices; size_t n_rules; unsigned int i; @@ -730,7 +733,8 @@ classifier_remove(struct classifier *cls, const struct cls_rule *cls_rule) ovs_assert(subtable); mask_offset = 0; - for (i = 0; i < subtable->n_indices; i++) { + n_indices = subtable->n_indices; + for (i = 0; i < n_indices; i++) { ihash[i] = minimatch_hash_range(&cls_rule->match, subtable->index_maps[i], &mask_offset, &basis); @@ -783,7 +787,7 @@ classifier_remove(struct classifier *cls, const struct cls_rule *cls_rule) } /* Remove rule node from indices. */ - for (i = 0; i < subtable->n_indices; i++) { + for (i = 0; i < n_indices; i++) { ccmap_dec(&subtable->indices[i], ihash[i]); } n_rules = cmap_remove(&subtable->rules, &rule->cmap_node, hash); From patchwork Tue Aug 20 13:14:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1974418 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=O6pdiNkp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::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 4Wp91d5qbhz1yXf for ; Tue, 20 Aug 2024 23:15:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 43D4240AB1; Tue, 20 Aug 2024 13:15:16 +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 3_MPQl1AFYPg; Tue, 20 Aug 2024 13:15:15 +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 59DA140B0C Authentication-Results: smtp2.osuosl.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=O6pdiNkp Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 59DA140B0C; Tue, 20 Aug 2024 13:15:11 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 74D65C102B; Tue, 20 Aug 2024 13:15:10 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0FC7DC102F for ; Tue, 20 Aug 2024 13:15:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 722AE405B8 for ; Tue, 20 Aug 2024 13:15:02 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id MHbjMzVGhEcv for ; Tue, 20 Aug 2024 13:15:00 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=mkp@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org D28B0405C9 Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org D28B0405C9 Authentication-Results: smtp4.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=O6pdiNkp Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id D28B0405C9 for ; Tue, 20 Aug 2024 13:14:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724159698; 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=K52vEmcQnFdBSmQK4jvERhxoh0aV3EZ8tYmHvzeMm+g=; b=O6pdiNkpHYrs/UJLb6Oa8cfZo5R4ekhQFlet9Yas+6M5xqW09iSMxPfsOkez9BLAKNWGEa KLIpduGUuvLr7q1g6IbYY6s4xLBgcmlXrrNxCp5glP+n/QCgSQ3npV8F7/9DzXk2ShjhND pRkvhkbTRELxjvKAJPWFWggC5wgatTs= Received: from mx-prod-mc-01.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-463-58Ru2aihN8WQmRkaWMeH4g-1; Tue, 20 Aug 2024 09:14:57 -0400 X-MC-Unique: 58Ru2aihN8WQmRkaWMeH4g-1 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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A9E7D1954223 for ; Tue, 20 Aug 2024 13:14:56 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.33.24]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 042711955DD6; Tue, 20 Aug 2024 13:14:55 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Tue, 20 Aug 2024 09:14:42 -0400 Message-ID: <20240820131444.1724438-7-mkp@redhat.com> In-Reply-To: <20240820131444.1724438-1-mkp@redhat.com> References: <20240820131444.1724438-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH 6/8] vconn: Always properly free flow stats reply. 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" Currently the error conditions in vconn_dump_flows() don't handle freeing memory in a consistent fashion. This can make it possible to reference memory after it's freed. This patch attempts to handle errors consistently. Error conditions will always cause memory to be freed and then that memory will never be referenced. Fixes: d444a914fdbd ("ovn-trace: New --ovs option to also print OpenFlow flows.") Signed-off-by: Mike Pattrick Acked-by: Simon Horman --- lib/vconn.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/vconn.c b/lib/vconn.c index e9603432d..dcede1656 100644 --- a/lib/vconn.c +++ b/lib/vconn.c @@ -1017,6 +1017,7 @@ recv_flow_stats_reply(struct vconn *vconn, ovs_be32 send_xid, VLOG_WARN_RL(&rl, "received bad reply: %s", ofp_to_string(reply->data, reply->size, NULL, NULL, 1)); + ofpbuf_delete(reply); return EPROTO; } } @@ -1041,6 +1042,7 @@ recv_flow_stats_reply(struct vconn *vconn, ovs_be32 send_xid, default: VLOG_WARN_RL(&rl, "parse error in reply (%s)", ofperr_to_string(retval)); + ofpbuf_delete(reply); return EPROTO; } } @@ -1079,16 +1081,19 @@ vconn_dump_flows(struct vconn *vconn, struct ofputil_flow_stats *fs = &fses[n_fses]; error = recv_flow_stats_reply(vconn, send_xid, &reply, fs, &ofpacts); if (error) { - if (error == EOF) { - error = 0; - } break; } fs->ofpacts = xmemdup(fs->ofpacts, fs->ofpacts_len); n_fses++; } + ofpbuf_uninit(&ofpacts); - ofpbuf_delete(reply); + + if (!error) { + ofpbuf_delete(reply); + } else if (error == EOF) { + error = 0; + } if (error) { for (size_t i = 0; i < n_fses; i++) { From patchwork Tue Aug 20 13:14:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1974419 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=aeiG8W7q; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::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 4Wp91h43DQz1yXf for ; Tue, 20 Aug 2024 23:15:20 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id C9AE740B2D; Tue, 20 Aug 2024 13:15:17 +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 2rEWBmnMg3Lf; Tue, 20 Aug 2024 13:15:14 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org F15C040B09 Authentication-Results: smtp2.osuosl.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=aeiG8W7q Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id F15C040B09; Tue, 20 Aug 2024 13:15:09 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0265EC102D; Tue, 20 Aug 2024 13:15:09 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1455FC087F for ; Tue, 20 Aug 2024 13:15:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 2E5B140602 for ; Tue, 20 Aug 2024 13:15:02 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id FpY7wTj9Kl6Q for ; Tue, 20 Aug 2024 13:15:01 +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 smtp4.osuosl.org 0E1FC405D5 Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 0E1FC405D5 Authentication-Results: smtp4.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=aeiG8W7q Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id 0E1FC405D5 for ; Tue, 20 Aug 2024 13:15:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724159699; 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=XJupNMQl8XKLm6yEF87f52yF8HOfbtlrgIX4DlRm+Tc=; b=aeiG8W7qZulQEwexYQrC/G4Ag930L7CGBQRE9OqrqfImhWgOu8t3qtomTonqdmBYtbTHH1 XZ+mSpQ1v9ATC4jdHa+n3B8JtPMuHoqsAfJkW7tWCB91p29KaIAz2ijuZzn+QHV63p1LS7 e/6lOMrlEiNoNmHWxG3gKuI1foSc0d0= 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-518-tqO00dqZNg2LsTXXE3eOMA-1; Tue, 20 Aug 2024 09:14:58 -0400 X-MC-Unique: tqO00dqZNg2LsTXXE3eOMA-1 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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CC5401955BF4 for ; Tue, 20 Aug 2024 13:14:57 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.33.24]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F2B991955DD6; Tue, 20 Aug 2024 13:14:56 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Tue, 20 Aug 2024 09:14:43 -0400 Message-ID: <20240820131444.1724438-8-mkp@redhat.com> In-Reply-To: <20240820131444.1724438-1-mkp@redhat.com> References: <20240820131444.1724438-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH 7/8] mcast-snooping: Properly check return code from group_get_lru 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" Previously error codes from group_get_lru() were ignored, possibly causing NULL pointer dereferencing. This patch appropriately checks for errors. Fixes: 4a95091d1f66 ("lib: Add IGMP snooping library bits") Signed-off-by: Mike Pattrick Acked-by: Simon Horman --- lib/mcast-snooping.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/mcast-snooping.c b/lib/mcast-snooping.c index dc5164b41..bf25e6f20 100644 --- a/lib/mcast-snooping.c +++ b/lib/mcast-snooping.c @@ -432,7 +432,9 @@ mcast_snooping_add_group(struct mcast_snooping *ms, uint32_t hash = mcast_table_hash(ms, addr, vlan); if (hmap_count(&ms->table) >= ms->max_entries) { - group_get_lru(ms, &grp); + if (!group_get_lru(ms, &grp)) { + return false; + } mcast_snooping_flush_group(ms, grp); } From patchwork Tue Aug 20 13:14:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1974417 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=hp32y9Le; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (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 4Wp91X59hxz1yXf for ; Tue, 20 Aug 2024 23:15:12 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 93B4540688; Tue, 20 Aug 2024 13:15:10 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id v4VEXN06NuuW; Tue, 20 Aug 2024 13:15:08 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org B8B3940659 Authentication-Results: smtp4.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=hp32y9Le Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id B8B3940659; Tue, 20 Aug 2024 13:15:07 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 44835C102E; Tue, 20 Aug 2024 13:15:07 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 409EDC1030 for ; Tue, 20 Aug 2024 13:15:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 2776940A56 for ; Tue, 20 Aug 2024 13:15:03 +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 gdvxeeENk-17 for ; Tue, 20 Aug 2024 13:15:02 +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 smtp2.osuosl.org E5A7D40A1F Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org E5A7D40A1F Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hp32y9Le Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id E5A7D40A1F for ; Tue, 20 Aug 2024 13:15:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724159700; 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=osD6olGfVq8qSAHsDbY7chLDsiekrwi4Nfy2Z9aOKj4=; b=hp32y9LeqEADk0tciNzWJNMZyODdXKdhrt2gRAzyH1ORyImm8qYApSuSUGJmd/K2cO+KjK 5CbUyuyV/UedVUWp+0tlMOb90ktMe+TniwvohdZ113F1QqOTAivv+IE7jvrIlr8RbpR8q5 uKViKhD+FFxQHeqfkq7fTL/DfzcNXqE= 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-526-i9W0FMcxNdSFjS3-Ir4Biw-1; Tue, 20 Aug 2024 09:14:59 -0400 X-MC-Unique: i9W0FMcxNdSFjS3-Ir4Biw-1 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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BAE591955BF8 for ; Tue, 20 Aug 2024 13:14:58 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.33.24]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 04EB31955DD6; Tue, 20 Aug 2024 13:14:57 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Tue, 20 Aug 2024 09:14:44 -0400 Message-ID: <20240820131444.1724438-9-mkp@redhat.com> In-Reply-To: <20240820131444.1724438-1-mkp@redhat.com> References: <20240820131444.1724438-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH 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 supresses clang's warning. Signed-off-by: Mike Pattrick Acked-by: Simon Horman 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;