From patchwork Wed Sep 9 19:20:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gregory Rose X-Patchwork-Id: 1360974 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.137; helo=fraxinus.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=UqChJ64f; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BmsM02YTpz9sTN for ; Thu, 10 Sep 2020 05:21:16 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id D264E86F55; Wed, 9 Sep 2020 19:21:14 +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 3I8Y7Neevt1q; Wed, 9 Sep 2020 19:21:13 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9812C86F83; Wed, 9 Sep 2020 19:20:57 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 74B9DC0894; Wed, 9 Sep 2020 19:20:57 +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 B937FC08A5 for ; Wed, 9 Sep 2020 19:20:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9850D86E85 for ; Wed, 9 Sep 2020 19:20:55 +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 bm5CBYlpYP_P for ; Wed, 9 Sep 2020 19:20:54 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 3F41086EC7 for ; Wed, 9 Sep 2020 19:20:51 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id kk9so1841568pjb.2 for ; Wed, 09 Sep 2020 12:20:51 -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=UqChJ64f2uj6kcm5keKFYeB4H3zk87yg0bUldfiEBhMa1NI6X+wNfyjv9laWdXslpP MeR23BDwh8df2z940b3PxNSQmze/cTGmmWrkVfRotoPCSVtfAX2w5NNa2LJZPJ2he8yP hExzy8fg0JGNvLTTol7Nk4aRdLSO5R1j/euTbI2MT49edDEXNolTSpAEAnCDgYBeMnw+ JBrJWCGgBzjw11ZIMlgw6VVfHdYEB6ujBt/InnjWFbCoZqA1xLY/bXlMI/miaHIyFOw8 Kr2ND6TduIpgIEYqxVX8ja2tAN33+tTT5zLCilPuA+RxnQ2/uBWT+hkOzspNoi9o+woh Bh0Q== 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=RWHmJNhimF9CBTD83bY+lOfwnd96igdw0CtXDDTGNqQFxix8hBNy8FMDHZmcUu6wG5 kfF3EyaxVgnyTMq+R+juOaxyy2F+xdjI5DsoMWkV565ijOMxv7QiqWJgs76RBdbF4/l4 XBGzNiv1/ZY09JvCbAvHJ9lbrOGCJXXNXDCXXBh58YrZ9LCPWwg163iQht6Cyp/GLNTO MMX2wEsPmnjjiiyL4h3NSgnIu4A7qdzKPGjUDQBAsTjLA5GvEBjP03MHbUP8J8jwc6WP TUFirXLA1HXQQSqpTasnhoVURu8MkahJK4T+Nb7hNQa/OHb3D9xELqzlbuIh+qIDjQWi fN5A== X-Gm-Message-State: AOAM532DOBLy3m6MXeSmW4VZUtjQZLUR34C6eEOhxturuZPbfG52rHnF Ki8H8BwwcBOREBedIgo/j6l1YpqL+HzFXg== X-Google-Smtp-Source: ABdhPJz9bh40X7uLqR9oA30NNa049/V5X+/u0xK5/pw/ZcZuItJ2qwgK563E5KzyZrAUeQh64JXHKg== X-Received: by 2002:a17:90a:ee0d:: with SMTP id e13mr2145474pjy.227.1599679250511; Wed, 09 Sep 2020 12:20:50 -0700 (PDT) Received: from VMware-box.domain ([97.115.183.169]) by smtp.googlemail.com with ESMTPSA id x29sm2866338pga.23.2020.09.09.12.20.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 12:20:49 -0700 (PDT) From: Greg Rose To: dev@openvswitch.org Date: Wed, 9 Sep 2020 12:20:17 -0700 Message-Id: <20200909192021.9545-21-gvrose8192@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200909192021.9545-1-gvrose8192@gmail.com> References: <20200909192021.9545-1-gvrose8192@gmail.com> MIME-Version: 1.0 Cc: Kees Cook Subject: [ovs-dev] [PATCH v2 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 --- 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)) ||