Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp127019pxf; Wed, 17 Mar 2021 00:44:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmKXILwRx05UA5Nls2DcNP4jf+kdiNxspX2zXpkHX0h1Hlx76K9139/GiES9Xp+y/da0wr X-Received: by 2002:a17:906:ada:: with SMTP id z26mr34012864ejf.438.1615967066153; Wed, 17 Mar 2021 00:44:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615967066; cv=none; d=google.com; s=arc-20160816; b=Mg+3DW3NBOUD6C/5I1riYpLJnZrw2X/EhGaVdVwp3O0g9dCfz67m9pQhBUpvY/Md6+ tS5ISG1onfqk+DX/5cduUH7KB8AtiGVKapxix7YwpB1iQpZXRWDHjZLJkdEa+GBZ2H3h 1U+zfygaqbSXU1vnr1N2bxXKXAVGxCrLJOTCKrI8D2hdcDX0/rKEP1eexzlovggJWTlu aQU2Av8jmZss+qj1wmXWCGEyUdBoglsif7+FyR3oYsj0lkfNMfzjBMukrfkLzA7JUi2a XT5y89DsNPJ1M1iFZSMCxNcjZKarIm6G+yk2e6omCECv/t/uOVWMO93aStv7YHvToRWR PXpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=J+rZ0LNcwtq9uyjjjuUyu2u1RffJLilINd4nmQT4RW8=; b=yhRN9/TfkuhMTVbgA3Oi7WRysSWySC0oQLFqlIEot4lKFdiKfbWo1zmEbA3XAmdB6p ESzRYY11bs0RqtcZgWJKqWuOKT92FJhx4VCy4bVa9NNdm8bmKedYoIJUDQ0HPQx7V490 CUJk2I5yFqCES/w2lguACyugN/cdN5oxU9snkTmdpVDkJLWcX+PPJl+rvKo8ePZ4BxYR TD86dbbCkhTRajnuPiN/UPJ94nVtMlOt57C2fLgtWblnic9/eFClOZY6GZ/od8xwGFns 0IhazcJaon75NUAN/veMIVYHPltxbLFU6Fd8QZyCpPPoWqCQTBxUUfKnKYDIef3Zbmm4 v+ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=opVdpcE6; 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 bz20si3490290ejc.70.2021.03.17.00.44.03; Wed, 17 Mar 2021 00:44:26 -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=k20201202 header.b=opVdpcE6; 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 S229873AbhCQHmQ (ORCPT + 99 others); Wed, 17 Mar 2021 03:42:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:32878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbhCQHmA (ORCPT ); Wed, 17 Mar 2021 03:42:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CC80264F7E; Wed, 17 Mar 2021 07:41:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615966920; bh=EYGJXau039RZLyL38UOfqfxwXxGxY0dFocwb73Hllnk=; h=Date:From:To:Cc:Subject:From; b=opVdpcE6BozNAt187Nv5guzqHXXdZIL/CO9KsOCPP+dnYbXVBfkRio46QrzoRNN5I ff2B13XPhWGhGBU+y/1Mze5xfFUtQ0xX6GqdEJ9kz6C0j3Uzs/kXpX4aCQyAQ7UAQA +JA3gCpKajN50U1WUNyxpZQPBQo4wElcoI1WDUUJEuRv6U0CnK71rEAnCEaAGD+Mz9 dTzMhpkf+mV+9FTbTvnGZ39gZTorw6uxRKTNzFQLmYtwDjslvjRgBe0C8C23nKT19r LTOcCn/Ku7OnvZ5+akmumHxLLF+H+7HYAxEy7pIW8nf+ha442kF1gbTACRyb6RFCGr mMRYGrWLP5APg== Date: Wed, 17 Mar 2021 01:41:48 -0500 From: "Gustavo A. R. Silva" To: Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Jakub Kicinski Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] ixgbe: Fix out-of-bounds warning in ixgbe_host_interface_command() Message-ID: <20210317064148.GA55123@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix the following out-of-bounds warning by replacing the one-element array in an anonymous union with a pointer: CC [M] drivers/net/ethernet/intel/ixgbe/ixgbe_common.o drivers/net/ethernet/intel/ixgbe/ixgbe_common.c: In function ‘ixgbe_host_interface_command’: drivers/net/ethernet/intel/ixgbe/ixgbe_common.c:3729:13: warning: array subscript 1 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds] 3729 | bp->u32arr[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi); | ~~~~~~~~~~^~~~ drivers/net/ethernet/intel/ixgbe/ixgbe_common.c:3682:7: note: while referencing ‘u32arr’ 3682 | u32 u32arr[1]; | ^~~~~~ This helps with the ongoing efforts to globally enable -Warray-bounds. Notice that, the usual approach to fix these sorts of issues is to replace the one-element array with a flexible-array member. However, flexible arrays should not be used in unions. That, together with the fact that the array notation is not being affected in any ways, is why the pointer approach was chosen in this case. Link: https://github.com/KSPP/linux/issues/109 Signed-off-by: Gustavo A. R. Silva --- drivers/net/ethernet/intel/ixgbe/ixgbe_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c index 62ddb452f862..bff3dc1af702 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c @@ -3679,7 +3679,7 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, void *buffer, u32 hdr_size = sizeof(struct ixgbe_hic_hdr); union { struct ixgbe_hic_hdr hdr; - u32 u32arr[1]; + u32 *u32arr; } *bp = buffer; u16 buf_len, dword_len; s32 status; -- 2.27.0