From patchwork Thu Aug 20 22:49:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gregory Rose X-Patchwork-Id: 1348667 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.138; helo=whitealder.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=C3lNHtHy; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BXfyw1GXHz9sPB for ; Fri, 21 Aug 2020 08:51:36 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 9490588628; Thu, 20 Aug 2020 22:51:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 87KO4uiCwoND; Thu, 20 Aug 2020 22:51:27 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 29CDC8847B; Thu, 20 Aug 2020 22:50:43 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E6479C089F; Thu, 20 Aug 2020 22:50:42 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 01C32C0051 for ; Thu, 20 Aug 2020 22:50:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id E64B286BEA for ; Thu, 20 Aug 2020 22:50:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wOiFb9XklBQg for ; Thu, 20 Aug 2020 22:50:39 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by fraxinus.osuosl.org (Postfix) with ESMTPS id B35AD86C48 for ; Thu, 20 Aug 2020 22:50:39 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id i10so70197pgk.1 for ; Thu, 20 Aug 2020 15:50: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=B3kh4qB0prpCDASqOZ16SrvGGpcGEb+An65Wn8FHduI=; b=C3lNHtHyHUQVR81VGCZZwv3+h8beZgHPwDUtyYZjsltfIVoNTfsLXmMFS4tYlgUeZO w+Emi+CRI3Udw0z/N5OdyjK9DJBShCHlRVCmeKcKPWJKcFW6ZdtI81hdLDc6sXVLnvsH CfO5Li/NyVciouVusEF2i9DSfHOpR6+nfvI7g1Pipfmfqk7x8KeKU8mGr/TAG2EUIzz+ PgfbPYYdoYDDqvIK5oaYixcJBi9hAPesKwTowmU5Ah4fFKxyr2gpPreL2uzTyYZByDNg h6pRIA/wMzhsLODSg07mokwqsVtSB2XdK9BofIOWcGiTJv11YUROVVY/aX5/qVJR9uXa pDvA== 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=B3kh4qB0prpCDASqOZ16SrvGGpcGEb+An65Wn8FHduI=; b=n18pRcOQ9Bq9Y8+Ce2B8moykPbonG32mq2PZ2yHGGyClYHmOWMcBA9UTd4KIvJu6N4 mph4W84Y5ETJxvH/fVezG4eB8mN/00mHr4eJAiVDcIbF1VzsiGlainAUc3/x+zngV+St eUGr17TGHeiV0uRwMzHvQK9EILELIN+7wY5vdP6ks85rzhuhHF7p22yAwpqP/+dasHHD i0BfdB058sb8NKhzhwpGFeyf2BZxyXvSBxIV+Q6OYLHF1uOY9fwCpWkauHYpTphCcPTl Bs5QR1Fy7wXqCjG0XbgHWXBS8YhHX5YiTrHbvsSzC+5ZGZgjfvhVXTmKkV4HXBGE7KP4 r6VQ== X-Gm-Message-State: AOAM530CxzYwHydbvnRsxYbZ3CctXT0oi7wr+i4CFOzLHt1tHinoWiYP G1HQ+e+5AAVEGmbt1s0uu3UrC5O7q/YOwg== X-Google-Smtp-Source: ABdhPJyLSyUvgiB4Qp3iqfXkW+YsNrJaz7pKa5a66eX9FI0yYN4sYPRh5IUkrHRs5LA7lV+rvBFWfA== X-Received: by 2002:a63:6e01:: with SMTP id j1mr224749pgc.147.1597963838496; Thu, 20 Aug 2020 15:50:38 -0700 (PDT) Received: from gizo.domain (97-115-99-106.ptld.qwest.net. [97.115.99.106]) by smtp.gmail.com with ESMTPSA id y6sm116866pfr.61.2020.08.20.15.50.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2020 15:50:37 -0700 (PDT) From: Greg Rose To: dev@openvswitch.org Date: Thu, 20 Aug 2020 15:49:48 -0700 Message-Id: <1597963790-12362-22-git-send-email-gvrose8192@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597963790-12362-1-git-send-email-gvrose8192@gmail.com> References: <1597963790-12362-1-git-send-email-gvrose8192@gmail.com> MIME-Version: 1.0 Cc: Kees Cook Subject: [ovs-dev] [PATCH 21/23] 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 --- 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 d3fd771..9960416 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)) ||