Received: by 2002:a05:7412:1492:b0:e2:908c:2ebd with SMTP id s18csp59117rdh; Mon, 21 Aug 2023 07:43:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXqem3buiE19P0uovE54hNOWUWsCku3zu4LBcXj9RYdJbHUEkpU7Y21ejQH0EpuBuneHJ8 X-Received: by 2002:aa7:da18:0:b0:523:1901:d19c with SMTP id r24-20020aa7da18000000b005231901d19cmr5400308eds.24.1692628993084; Mon, 21 Aug 2023 07:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692628993; cv=none; d=google.com; s=arc-20160816; b=xeQR/gA5ln98/kItwA0z55YxcKxousTnEk8yUhSG4q70zZCYc99mczuwzbgb02CFf0 5Bpq15sgVikdsMBYmM+HNu0LnayhzaJ3Dc5oKekO7rgA3R4GBVF329MmF1DtXa7o7hZC gTshh5D6JY6fF3+k0U1YLgk2IbtHltKAivrbNnq+cyD4mLVL4PWbEpObdVtGIvbs2Dbs qrmXU1hZTMbLq406uXUsr1AnBdQmq1FF0C6WeB746yvyckWnsfaRrcbDJPpL+tQKAMTq 9jCIy0vTao7Dswo9tEArCWyE52hoMnMIVdRzc/6T320oSExftFdLKQmyfwQlNhf+VPcd 66XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9IeyvyH29EfUz4L37TEafK1x5mSklosPdCLqiQq6ZvI=; fh=nLJZ9OCSl1mPlQdJa1+1C8Nn+XJdF686TvzXQyyGBvA=; b=FCaWPP+hEaZPxK9OsSa5oDAFmnmB6nr/bw5fDq3xze8lgh7K8LYSrpHbJ/uJjNEQR5 WeJ3cf3UyQnoAwfoDnBTLuDBHbtfExwB2Mcz9wLGIkiy3kyUG3T3nH8F3VwGAiTs7eHK z0s2gdTz68WjSwNv9h9yey1G058R+59zdepVDTi/cQ1S+Rw3N7K/+Xif0FaJwoHTtrTB QvtcYhKyYrDeSM3Xe/kHWnxV+5HYAGxdE6wOliG1I+vIXtTVkCw/Hj7CKKUIe8SyRJcY qJaJZ+GgKNvSjTxHY8xfeYldktgkFPq9N3IQJOs4E7YOL9FPZOUZHZp/Px9bM+q/991y Em/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kmnUrr+i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f18-20020a056402151200b0052a10293879si1186982edw.446.2023.08.21.07.42.48; Mon, 21 Aug 2023 07:43:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kmnUrr+i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233548AbjHUHDj (ORCPT + 99 others); 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> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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