From patchwork Wed Sep 16 17:33:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gregory Rose X-Patchwork-Id: 1365757 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=UqrwaQzQ; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BsK111Kh4z9sVh for ; Thu, 17 Sep 2020 11:21:09 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 51DC78742B; Wed, 16 Sep 2020 17:35:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JnUo1opKUIdz; Wed, 16 Sep 2020 17:35:34 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id BD45C8734C; Wed, 16 Sep 2020 17:35:29 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 870C4C0891; Wed, 16 Sep 2020 17:35:29 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 87BC0C0864 for ; Wed, 16 Sep 2020 17:35:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 5B6312E12E for ; Wed, 16 Sep 2020 17:35:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ej20i8V2KgFT for ; Wed, 16 Sep 2020 17:35:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by silver.osuosl.org (Postfix) with ESMTPS id 38B742E132 for ; Wed, 16 Sep 2020 17:33:39 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id d6so4378883pfn.9 for ; Wed, 16 Sep 2020 10:33:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8tj8AjNAVBaoQ5jSRSS8zaCUJv9NbldneYD0gozte/4=; b=UqrwaQzQnkfDn5BXbaEW+0DoNBJ9enk1xHFNv9D6VrZGJrW+sB32QY6IEM0SPLV+ZH lfwUvqprDzYYAnoBfhY1DbJDghjwWhP3zaAHTtXkgP5O3aIHsOrSXwpFe32+6ByNAVHC xJZ+PV6JWehzLriafftF5yY2CGFBYtdMZtOb+Ny/De8O9qSRPTDH6hFkwqV6xG9CgsDR /JlAf9J3AuLNOeZOxse+MoXsmgOkeJuapVYEG0LCdyHPALTrQiUioUm8Px2005Q1RNms ZhFXnXTiMhftjcvXDIwa5WGOMXVVPdOE06prDD3Bwlh7wwmSjICAOQ2ygKaQSJic/G0t VFew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8tj8AjNAVBaoQ5jSRSS8zaCUJv9NbldneYD0gozte/4=; b=tdhTaXwviXS+6Ba650s7jBCg5AiZ7QynQEBzUSe3DyBrczYL2jxnD6ZAumJF42xQXW iYW3kwiolDryldVvOZTPNGFWALqL4lPP+vpMpHZFLuPmLq2zGa3z6QQjj6W8etWwYjRC zYtbNJgy7IjVOXxnYTXTMLEiDLQiJxgNQCr4MjfC0I1ZFWZh/mvFyoKDQldlHEZ6SSeP SH4hwcnth/d6OelG2hLkVReldXSyAWCNbvVjcu+7IoWPENX86YwGrfJ2NGFDacg+TqUQ mGOa5MGiuoXgTC2CgArOfVhEVJkGwEefkaHJJmuYo3n3GFbUiOWT7V2BPzYdoW1Of+Wu +LtQ== X-Gm-Message-State: AOAM5335EPADQ6QJuwksxkZ0zUEWaubkF4Dag0oPym+4PQ3eHUird2Vx 3tGCKRHjDy2JPvnyOW61nn5G94sEYTn4Ow== X-Google-Smtp-Source: ABdhPJy19fSbm3Pev+LB933lKfx3Yi5GH3OAWS9xhgmZ63wXHWdRTcMKVYG+M+XGzcXZ9DsH5YWPOA== X-Received: by 2002:a63:6782:: with SMTP id b124mr20321705pgc.308.1600277618417; Wed, 16 Sep 2020 10:33:38 -0700 (PDT) Received: from VMware-box.domain ([97.115.183.169]) by smtp.googlemail.com with ESMTPSA id o20sm16248519pgh.63.2020.09.16.10.33.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 10:33:37 -0700 (PDT) From: Greg Rose To: dev@openvswitch.org Date: Wed, 16 Sep 2020 10:33:07 -0700 Message-Id: <20200916173311.30956-21-gvrose8192@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200916173311.30956-1-gvrose8192@gmail.com> References: <20200916173311.30956-1-gvrose8192@gmail.com> MIME-Version: 1.0 Cc: Kees Cook Subject: [ovs-dev] [PATCH V3 20/24] datapath: Distribute switch variables for initialization X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Kees Cook Upstream commit: commit 16a556eeb7ed2dc3709fe2c5be76accdfa4901ab Author: Kees Cook Date: Wed Feb 19 22:23:09 2020 -0800 openvswitch: Distribute switch variables for initialization Variables declared in a switch statement before any case statements cannot be automatically initialized with compiler instrumentation (as they are not part of any execution flow). With GCC's proposed automatic stack variable initialization feature, this triggers a warning (and they don't get initialized). Clang's automatic stack variable initialization (via CONFIG_INIT_STACK_ALL=y) doesn't throw a warning, but it also doesn't initialize such variables[1]. Note that these warnings (or silent skipping) happen before the dead-store elimination optimization phase, so even when the automatic initializations are later elided in favor of direct initializations, the warnings remain. To avoid these problems, move such variables into the "case" where they're used or lift them up into the main function body. net/openvswitch/flow_netlink.c: In function ‘validate_set’: net/openvswitch/flow_netlink.c:2711:29: warning: statement will never be executed [-Wswitch-unreachable] 2711 | const struct ovs_key_ipv4 *ipv4_key; | ^~~~~~~~ [1] https://bugs.llvm.org/show_bug.cgi?id=44916 Signed-off-by: Kees Cook Signed-off-by: David S. Miller Cc: Kees Cook Signed-off-by: Greg Rose Acked-by: Yi-Hung Wei --- datapath/flow_netlink.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/datapath/flow_netlink.c b/datapath/flow_netlink.c index d3fd77106..996041602 100644 --- a/datapath/flow_netlink.c +++ b/datapath/flow_netlink.c @@ -2700,10 +2700,6 @@ static int validate_set(const struct nlattr *a, return -EINVAL; switch (key_type) { - const struct ovs_key_ipv4 *ipv4_key; - const struct ovs_key_ipv6 *ipv6_key; - int err; - case OVS_KEY_ATTR_PRIORITY: case OVS_KEY_ATTR_SKB_MARK: case OVS_KEY_ATTR_CT_MARK: @@ -2715,7 +2711,9 @@ static int validate_set(const struct nlattr *a, return -EINVAL; break; - case OVS_KEY_ATTR_TUNNEL: + case OVS_KEY_ATTR_TUNNEL: { + int err; + #ifndef USE_UPSTREAM_TUNNEL if (eth_p_mpls(eth_type)) return -EINVAL; @@ -2728,8 +2726,10 @@ static int validate_set(const struct nlattr *a, if (err) return err; break; + } + case OVS_KEY_ATTR_IPV4: { + const struct ovs_key_ipv4 *ipv4_key; - case OVS_KEY_ATTR_IPV4: if (eth_type != htons(ETH_P_IP)) return -EINVAL; @@ -2749,8 +2749,10 @@ static int validate_set(const struct nlattr *a, return -EINVAL; } break; + } + case OVS_KEY_ATTR_IPV6: { + const struct ovs_key_ipv6 *ipv6_key; - case OVS_KEY_ATTR_IPV6: if (eth_type != htons(ETH_P_IPV6)) return -EINVAL; @@ -2777,7 +2779,7 @@ static int validate_set(const struct nlattr *a, return -EINVAL; break; - + } case OVS_KEY_ATTR_TCP: if ((eth_type != htons(ETH_P_IP) && eth_type != htons(ETH_P_IPV6)) ||