From patchwork Thu Feb 20 06:23:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 1241236 X-Patchwork-Delegate: jeffrey.t.kirsher@intel.com 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=osuosl.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=mqTSY/qA; 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 48NPfS1gh0z9sRs for ; Thu, 20 Feb 2020 17:23:11 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id A6D1385EB4; Thu, 20 Feb 2020 06:23:08 +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 nR_AHZSxOysl; Thu, 20 Feb 2020 06:23:08 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 1A64E85E93; Thu, 20 Feb 2020 06:23:08 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 5B1391BF2FC for ; Thu, 20 Feb 2020 06:23:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 4E02485E93 for ; Thu, 20 Feb 2020 06:23:07 +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 Eufdc6VpUk37 for ; Thu, 20 Feb 2020 06:23:06 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 9AC2485E6B for ; Thu, 20 Feb 2020 06:23:06 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id j15so1392792pgm.6 for ; Wed, 19 Feb 2020 22:23:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xQ2hH1WuA3WIBV0TGGs6V9kr1LqyBnjsbugRrEFt9Ew=; b=mqTSY/qAB/RCNO8ZmyzzeSV454kKhoI4MrnzIubx8FG9Hs1YDY8qgkYCOOZ03fnOpj M9d3mq2QPbxb8DI9+NencQP10TelM1jX3r75i6nEudJJNC0pyPwTl5Zo70spE5jj6nwC RYRBy2U0gZtVNXuoqBFMSLZN6PyqSMEXMIPUo= 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:mime-version :content-transfer-encoding; bh=xQ2hH1WuA3WIBV0TGGs6V9kr1LqyBnjsbugRrEFt9Ew=; b=ZbtpTdK7Ct70K3TARgbe3R1GIpheWedj5e4GbPex+XQR0bf3kke30g92FJxYisnlGw 2E2i1itvWo1eBuVBqcvBAC4WDbU+6R5iIfsRzVAc5RwzacJw/UlTBxyBKOppCIN+TvxV lGdi8id35ZShmdd4fqn9A/KQ57VPkgZURD+0tSb4EvCow0njVuhwxvGYJVidnO+aKwyh P+FIyyfdvTP07KoZzppM6L4X0TxTlwLREIwBzRACjIOZ6gT/T8Yspb4CB3xsOvP7NCVS HLFhBaXfKxrU/Gp1EKtDFHAsDKlAskCgDwS+9anzp0va379c314USP1iYdIXUZ2hlyvi AT4Q== X-Gm-Message-State: APjAAAVneayqmIT9I1C+MuPZKugUWF5pOGfG8t2Zfr+4KykBw4ciW4B7 YhBw2z0zLgQ9AtQAwsDxjEbBlg== X-Google-Smtp-Source: APXvYqzAN57Ts+Ho0KQDmWMLWunp5OP1KQlTHt9upDJZGi6oUtxg6xEDyffRcacLKD/SVypLHcvH+Q== X-Received: by 2002:a63:9251:: with SMTP id s17mr31193888pgn.127.1582179786195; Wed, 19 Feb 2020 22:23:06 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id u126sm1728668pfu.182.2020.02.19.22.23.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 22:23:05 -0800 (PST) From: Kees Cook To: Jeff Kirsher Date: Wed, 19 Feb 2020 22:23:02 -0800 Message-Id: <20200220062302.68898-1-keescook@chromium.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH] e1000: Distribute switch variables for initialization X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-wired-lan@lists.osuosl.org, Alexander Potapenko , Kees Cook , linux-kernel@vger.kernel.org Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" 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. drivers/net/ethernet/intel/e1000/e1000_main.c: In function ‘e1000_xmit_frame’: drivers/net/ethernet/intel/e1000/e1000_main.c:3143:18: warning: statement will never be executed [-Wswitch-unreachable] 3143 | unsigned int pull_size; | ^~~~~~~~~ [1] https://bugs.llvm.org/show_bug.cgi?id=44916 Signed-off-by: Kees Cook Tested-by: Aaron Brown --- drivers/net/ethernet/intel/e1000/e1000_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c index 2bced34c19ba..a540d0206129 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c @@ -3140,8 +3140,9 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); if (skb->data_len && hdr_len == len) { switch (hw->mac_type) { + case e1000_82544: { unsigned int pull_size; - case e1000_82544: + /* Make sure we have room to chop off 4 bytes, * and that the end alignment will work out to * this hardware's requirements @@ -3162,6 +3163,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, } len = skb_headlen(skb); break; + } default: /* do nothing */ break;