From patchwork Wed Jul 17 12:00:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1961602 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.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 4WPDzt1sqdz20B2 for ; Wed, 17 Jul 2024 22:01:14 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 556F960BB5; Wed, 17 Jul 2024 12:01:12 +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 Sfawx1ovN6Ah; Wed, 17 Jul 2024 12:01:11 +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 5738960BC4 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 5738960BC4; Wed, 17 Jul 2024 12:01:11 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2AC88C0A98; Wed, 17 Jul 2024 12:01:11 +0000 (UTC) X-Original-To: ovs-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 B8C7AC0A96 for ; Wed, 17 Jul 2024 12:01:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id A948260B85 for ; Wed, 17 Jul 2024 12:01:09 +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 p4z434BFWnLZ for ; Wed, 17 Jul 2024 12:01:09 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2001:4b98:dc4:8::222; helo=relay2-d.mail.gandi.net; envelope-from=i.maximets@ovn.org; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org C16C9607FE Authentication-Results: smtp3.osuosl.org; dmarc=none (p=none dis=none) header.from=ovn.org DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org C16C9607FE Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by smtp3.osuosl.org (Postfix) with ESMTPS id C16C9607FE for ; Wed, 17 Jul 2024 12:01:08 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 81CB14000A; Wed, 17 Jul 2024 12:01:06 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Cc: Ilya Maximets Date: Wed, 17 Jul 2024 14:00:56 +0200 Message-ID: <20240717120101.591940-2-i.maximets@ovn.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240717120101.591940-1-i.maximets@ovn.org> References: <20240717120101.591940-1-i.maximets@ovn.org> MIME-Version: 1.0 X-GND-Sasl: i.maximets@ovn.org Subject: [ovs-dev] [PATCH 1/3] ofproto-dpif-xlate: Initialize observe_offset for sample actions. 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" For some reason gcc 14.1.1 from Fedora 41 thinks that the variable may end up not initialized: ofproto/ofproto-dpif-xlate.c: In function 'compose_sample_action': ofproto/ofproto-dpif-xlate.c:3465:40: error: 'observe_offset' may be used uninitialized 3465 | ctx->xout->last_observe_offset = observe_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~ ofproto/ofproto-dpif-xlate.c:3418:12: note: 'observe_offset' was declared here 3418 | size_t observe_offset; | ^~~~~~~~~~~~~~ We have an assertion in the code to ensure that at least one of the actions is present (userspace or psample), so the variable should actually be always initialized. Initialize explicitly just to silence the warning. Fixes: 516569d31fbf ("ofproto: xlate: Make sampled drops explicit.") Signed-off-by: Ilya Maximets Acked-by: Mike Pattrick --- ofproto/ofproto-dpif-xlate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 02567a961..850597b3a 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -3423,8 +3423,8 @@ compose_sample_action(struct xlate_ctx *ctx, * insert a meter action before the user space action. */ struct ofproto *ofproto = &ctx->xin->ofproto->up; uint32_t meter_id = ofproto->slowpath_meter_id; + size_t observe_offset = UINT32_MAX; size_t cookie_offset = 0; - size_t observe_offset; /* The meter action is only used to throttle userspace actions. * If they are not needed and the sampling rate is 100%, avoid generating From patchwork Wed Jul 17 12:00:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1961603 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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 4WPDzx09YPz20B2 for ; Wed, 17 Jul 2024 22:01:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id DB2AE409F2; Wed, 17 Jul 2024 12:01:14 +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 Ub43smKJUrLH; Wed, 17 Jul 2024 12:01:13 +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 930A840A7A Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 930A840A7A; Wed, 17 Jul 2024 12:01:13 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 56EA2C0A97; Wed, 17 Jul 2024 12:01:13 +0000 (UTC) X-Original-To: ovs-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 C496DC0A97 for ; Wed, 17 Jul 2024 12:01:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id B128460BB5 for ; Wed, 17 Jul 2024 12:01:11 +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 xCwc3LR2IREE for ; Wed, 17 Jul 2024 12:01:11 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2001:4b98:dc4:8::222; helo=relay2-d.mail.gandi.net; envelope-from=i.maximets@ovn.org; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org B5AA5607FE Authentication-Results: smtp3.osuosl.org; dmarc=none (p=none dis=none) header.from=ovn.org DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org B5AA5607FE Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by smtp3.osuosl.org (Postfix) with ESMTPS id B5AA5607FE for ; Wed, 17 Jul 2024 12:01:10 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id F40CB40008; Wed, 17 Jul 2024 12:01:08 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Cc: Ilya Maximets Date: Wed, 17 Jul 2024 14:00:57 +0200 Message-ID: <20240717120101.591940-3-i.maximets@ovn.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240717120101.591940-1-i.maximets@ovn.org> References: <20240717120101.591940-1-i.maximets@ovn.org> MIME-Version: 1.0 X-GND-Sasl: i.maximets@ovn.org Subject: [ovs-dev] [PATCH 2/3] util: Add non-NULL format assertion to xvasprintf. 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" For some reason GCC 14.1.1 on Fedora 41 assumes that format can be NULL and emits a warning: lib/util.c: In function 'xvasprintf': lib/util.c:229:14: error: null format string 229 | needed = vsnprintf(NULL, 0, format, args); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I didn't find any users where this can be true. Adding an assertion to silence the warning. In the worst case we'll find out where it is being called incorrectly. Signed-off-by: Ilya Maximets Acked-by: Mike Pattrick --- lib/util.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/util.c b/lib/util.c index 5253921b2..bdd6408b2 100644 --- a/lib/util.c +++ b/lib/util.c @@ -225,6 +225,8 @@ xvasprintf(const char *format, va_list args) size_t needed; char *s; + ovs_assert(format); + va_copy(args2, args); needed = vsnprintf(NULL, 0, format, args); From patchwork Wed Jul 17 12:00:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1961604 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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 4WPDzz2SpYz20B2 for ; Wed, 17 Jul 2024 22:01:19 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id A7F0C40E41; Wed, 17 Jul 2024 12:01: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 2dbY5I-eEz0I; Wed, 17 Jul 2024 12:01:16 +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 AB45540E3B Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id AB45540E3B; Wed, 17 Jul 2024 12:01:16 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8C40AC0A97; Wed, 17 Jul 2024 12:01:16 +0000 (UTC) X-Original-To: ovs-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 ABD31C0A99 for ; Wed, 17 Jul 2024 12:01:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 9564740E21 for ; Wed, 17 Jul 2024 12:01:14 +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 1jOeonpZlO_d for ; Wed, 17 Jul 2024 12:01:14 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2001:4b98:dc4:8::222; helo=relay2-d.mail.gandi.net; envelope-from=i.maximets@ovn.org; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 976EA40E17 Authentication-Results: smtp2.osuosl.org; dmarc=none (p=none dis=none) header.from=ovn.org DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 976EA40E17 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by smtp2.osuosl.org (Postfix) with ESMTPS id 976EA40E17 for ; Wed, 17 Jul 2024 12:01:12 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 6C91540006; Wed, 17 Jul 2024 12:01:11 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Cc: Ilya Maximets Date: Wed, 17 Jul 2024 14:00:58 +0200 Message-ID: <20240717120101.591940-4-i.maximets@ovn.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240717120101.591940-1-i.maximets@ovn.org> References: <20240717120101.591940-1-i.maximets@ovn.org> MIME-Version: 1.0 X-GND-Sasl: i.maximets@ovn.org Subject: [ovs-dev] [PATCH 3/3] match: Fix false-positive snprintf size warning. 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" GCC 14.1.1 of Fedora 41 thinks that 'i' can be in a full range and so 8 bytes is not enough to print it. lib/match.c: In function 'match_format': lib/match.c:1631:45: error: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8 1631 | snprintf(str_i, sizeof(str_i), "%d", i); | ^~ lib/match.c:1631:44: note: directive argument in the range [-2147483646, 1] 1631 | snprintf(str_i, sizeof(str_i), "%d", i); | ^~~~ lib/match.c:1631:13: note: 'snprintf' output between 2 and 12 bytes into a destination of size 8 1631 | snprintf(str_i, sizeof(str_i), "%d", i); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In practice that value can't be larger than 2, but it's not a performance critical code, so let's just increase the size to a maximum 12. Signed-off-by: Ilya Maximets Acked-by: Mike Pattrick --- lib/match.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/match.c b/lib/match.c index 0b9dc4278..9b7e06e0c 100644 --- a/lib/match.c +++ b/lib/match.c @@ -1618,7 +1618,7 @@ match_format(const struct match *match, ds_put_char(s, ','); } for (i = 0; i < FLOW_MAX_VLAN_HEADERS; i++) { - char str_i[8]; + char str_i[12]; if (!wc->masks.vlans[i].tci) { break;