Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp111895ybg; Mon, 8 Jun 2020 17:56:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaK22qO3u6HyffvLEU/naILpMNgc1lmcDlTuetbNPnj/kzh+CeS61JaVPq0R46kVudjopW X-Received: by 2002:a05:6402:1ca2:: with SMTP id cz2mr23607448edb.15.1591664202875; Mon, 08 Jun 2020 17:56:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591664202; cv=none; d=google.com; s=arc-20160816; b=eMrGcHJjdCk0fYuVY5CqrsupTI/0PjpUEpAsYBfn9SiwUBxsBG04LkngeFFORf3Vqs J2srgrlgfHZ65NtZCawag0UdMbbOQrkeOgwKsMgNWVLUxnjkD3AloWBPMuFedzMqc1pL +EhKA3B+Oo/l9+R2KS3woT3PhEeDOCw67Ttp00m8F3zs22I3rX/zehoHd5rtgIUToSE1 Jlzc58et4CC4YDC4z8+1sv7vvh3BUh6L0aiDdz3lDALITodoQqibz/xju9t+lAu8P+XE RmiA731upRPryBgq0QUMqardFcvzwomBqPvdwvbZkyCt8cZ92UXW6PcBuWyvnWTPuWgi 89og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GR1UrV/tJAaUP6zo5a2daZFfLaAw9euWlkG8qgpI6qE=; b=DFYlu1TZIViCsyXFp0DpLtnHJ9xBBn6LkBSvNJ+8dXJk7TjpmlpTcl0XEeqTgpxq1d Eyte5SHUK/wfONUAiwvLdLPf+Wu1+QQ649D03pJ+7Vj0QlkNTV5CDt4KSfeSFCNcjaS3 9V0XQ6285+rhFJqHZEm4kY2l1g+J31LGBIFhQMvsgSLHrwkTEgsvkGzjhPY2k05BhCcx 0+hQznTu4PoSLv9Ykc5+Nv0Xn+aUmv0IYjjlkNvWA1EfJ83JUow4kVODboIl43ieRBk9 phzBNFfPzqoWyqW26p7B/ZcpNWePLvPgBtbK8jZLnq1J8fUiIl3BTmTiNyVuUVOV3WnT V5sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DOrNsObr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q17si10783509edb.42.2020.06.08.17.56.19; Mon, 08 Jun 2020 17:56:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DOrNsObr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728420AbgFHXJ2 (ORCPT + 99 others); Mon, 8 Jun 2020 19:09:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:53664 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728158AbgFHXIZ (ORCPT ); Mon, 8 Jun 2020 19:08:25 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EA14920842; Mon, 8 Jun 2020 23:08:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657704; bh=74wKcSC/1/uY7MLx3rVRs5Efvh1k7Obe/4c2cXj8RbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DOrNsObr2fTlDk7kgbRnhOKsNWubuEn3VgNw/DO+jO9cI/xP5U2gJEqh2i/K0tS3+ 1a+KNC/tSTsi/sKwiqAmPcTTZN4Ki2t7t9+JhuSX9EMKGjKJ/Ii/WoNyhA32J3kpFP f7/EYpnZyH+cUvULw7DVICv7s9TZUHT7mC5It5Hk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kees Cook , Aaron Brown , Jeff Kirsher , Sasha Levin , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH AUTOSEL 5.7 102/274] e1000: Distribute switch variables for initialization Date: Mon, 8 Jun 2020 19:03:15 -0400 Message-Id: <20200608230607.3361041-102-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kees Cook [ Upstream commit a34c7f5156654ebaf7eaace102938be7ff7036cb ] 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 Signed-off-by: Jeff Kirsher Signed-off-by: Sasha Levin --- 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 0d51cbc88028..05bc6e216bca 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c @@ -3136,8 +3136,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 @@ -3158,6 +3159,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, } len = skb_headlen(skb); break; + } default: /* do nothing */ break; -- 2.25.1