From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6969EE49A0 for ; Mon, 21 Aug 2023 07:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233551AbjHUHDj (ORCPT ); Mon, 21 Aug 2023 03:03:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229666AbjHUHDi (ORCPT ); Mon, 21 Aug 2023 03:03:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6985AAC for ; Mon, 21 Aug 2023 00:03:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EEEBA62B51 for ; Mon, 21 Aug 2023 07:03:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD898C433C7; Mon, 21 Aug 2023 07:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692601416; bh=vRar8l9ILaoEFw2+hFnxiFjdmBLeNqB26P7+WKEFpEs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kmnUrr+ijfI+YGEqR+Dwr+2FoqGPF814T8gAkuNXxPnMFtxclMIt6kb/18LEtRBU/ eC4f8rSexpWfvcMeD2j4Bzr1s5ZlX6hc3bln2n4HhWsdWoa0hZPRb6iqOOmrJru9LQ SXBl7UL/zgnbqnZNdCjUdWZ/QOnvdAsBDJr+FOofLaDNW7SnMDTwW3xic+ZMtveILc vps3FXciom+5+DWOK5WXGIngg/+WjfQxo0EqGboc1Yc+Gv1ouqG0x+qiQ5E0kmoW9s Fogp5aNi2IXPrNBUHT/ihu0mmbuV2YCNxup2AfpYcupXhefJ7x04SOLPEAYqO0XgRL n2H95Iugz0rrw== Date: Mon, 21 Aug 2023 09:03:31 +0200 From: Simon Horman To: "GONG, Ruiqi" Cc: Chris Snook , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Sabrina Dubroca , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook , "Gustavo A . R . Silva" , gongruiqi1@huawei.com Subject: Re: [PATCH RESEND net-next] alx: fix OOB-read compiler warning Message-ID: <20230821070331.GA2711035@kernel.org> References: <20230821013218.1614265-1-gongruiqi@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230821013218.1614265-1-gongruiqi@huaweicloud.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 21, 2023 at 09:32:18AM +0800, GONG, Ruiqi wrote: > From: "GONG, Ruiqi" > > The following message shows up when compiling with W=1: > > In function ‘fortify_memcpy_chk’, > inlined from ‘alx_get_ethtool_stats’ at drivers/net/ethernet/atheros/alx/ethtool.c:297:2: > ./include/linux/fortify-string.h:592:4: error: call to ‘__read_overflow2_field’ > declared with attribute warning: detected read beyond size of field (2nd parameter); > maybe use struct_group()? [-Werror=attribute-warning] > 592 | __read_overflow2_field(q_size_field, size); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > In order to get alx stats altogether, alx_get_ethtool_stats() reads > beyond hw->stats.rx_ok. Fix this warning by directly copying hw->stats, > and refactor the unnecessarily complicated BUILD_BUG_ON btw. > > Signed-off-by: GONG, Ruiqi Reviewed-by: Simon Horman