Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp947036rwb; Thu, 10 Nov 2022 09:13:25 -0800 (PST) X-Google-Smtp-Source: AMsMyM4nFGuCjeeQnIzcILJCVuq2n8ubNEGTVdH3rHdNlOWRWd4UHqXxkOauC8lGKjoaACXyet/5 X-Received: by 2002:a17:90a:a891:b0:213:a95:88bd with SMTP id h17-20020a17090aa89100b002130a9588bdmr1499997pjq.98.1668100404853; Thu, 10 Nov 2022 09:13:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668100404; cv=none; d=google.com; s=arc-20160816; b=T4TeHI3EJXD9cCPy0bB743e6220S8ceCL9qr8px/2YHilA+o36SgTdMr8q4GJKkIl+ wO+CvCZ96tHncyDFLYm+86hvjtkmRNOz7VNbKv+mnbSg5cTABfYi5C/Ch+/LVErTA0t5 S5f96RYAP4GbE7ifnYHe1xCSY6GPC9FH94dZtaeUe5Z9MJ+eyuOi5uTHOS4wSoOznb9m idZ7aRiQldDn8pqH5SQbhG1G2f/CHjPUSf2hpnuahjyC7npfd53ACkDQzJMJA6HdVewx dwwtm7cN9S/ET9uLPIxqvwGjdpnhmhJ79QhNcSQeSa+tOP8e6fpsFS0wt0kr7Qnr+BwG a7gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wowe/IeNpoBDtK4I7JxK0XxuRhOAEAb8tqZASsxHneE=; b=myQ38Rt694kY7eSWME+JrZ4TvRqKzZppIjc2eBc7M+TiqOjXwewi7P7XQ56i4B/bvX fKu+kpbB8KG0E/XEQ7shyYrO1R6MFyETK68qSNGdjLP8RIa2+HB8San94lwK61/aj2qL 6sV6zMuIfdUvJgdut+qGqQSEEF1bXTDC0wvj0PfF5cNthySXMtOUJ/oM3JXsgVcWuSfO wdlsFRS4w/IZyixK213kPQmHNLcgdEyx8RWa+f92TyD32p125bplryCU/zDZK4MhFq4S nXJN64Zmw2LgzguwLh0gion8AwVtxv/eYYXhNEqfdTAErmR4HvmPi/bKVvckvTDgrpXB ePkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GTJ5zzZV; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j13-20020a056a00130d00b0056dea1fd0f9si22028350pfu.318.2022.11.10.09.13.12; Thu, 10 Nov 2022 09:13:24 -0800 (PST) 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=@intel.com header.s=Intel header.b=GTJ5zzZV; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232623AbiKJQtS (ORCPT + 92 others); Thu, 10 Nov 2022 11:49:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232599AbiKJQsp (ORCPT ); Thu, 10 Nov 2022 11:48:45 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8451DD6F; Thu, 10 Nov 2022 08:47:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668098874; x=1699634874; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sLTSISWzUr5ww4UVTAKQbU1w81C51YBDl84qwQHSgtI=; b=GTJ5zzZVjI+YpVEU0Mjl7tKrdV5XH/5FWRPtRwePYYKvI07NWtU5bkTh 7hdtcOSqrBbqlFKLR6TyRmr5/U5PTZZ3QVUCOgPQvllGneGhrr53nwVNz 3mepKocRHqOq2JblspEse8wy39e92rgC9SSSg1xzpZLiYjZGW3275yiJd /aaa2LfuQxNjItHjlRS/2R+fa3sMrv8AyZl1w+P0qaOG/p1ARMf4QqG3e rlM9lFeiJaXPDfX04WG5zQD4NQQbxMCBafYp0jZb2AJKQJe4Rd47iYl2C EFwIU6w2QHIl5WUqCG0wGSBFMSIa1nY1JvJrpdzSGEeUaaESLk4Zu+By7 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="310078421" X-IronPort-AV: E=Sophos;i="5.96,154,1665471600"; d="scan'208";a="310078421" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2022 08:46:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="882418907" X-IronPort-AV: E=Sophos;i="5.96,154,1665471600"; d="scan'208";a="882418907" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by fmsmga006.fm.intel.com with ESMTP; 10 Nov 2022 08:46:38 -0800 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 2AAGkbeC023491; Thu, 10 Nov 2022 16:46:37 GMT From: Alexander Lobakin To: Shenwei Wang Cc: Alexander Lobakin , Paolo Abeni , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "imx@lists.linux.dev" Subject: Re: [PATCH v2 RESEND 1/1] net: fec: add xdp and page pool statistics Date: Thu, 10 Nov 2022 17:43:21 +0100 Message-Id: <20221110164321.3534977-1-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: <20221109023147.242904-1-shenwei.wang@nxp.com> <4349bc93a5f2130a95305287141fde369245f921.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 From: Shenwei Wang Date: Thu, 10 Nov 2022 13:29:56 +0000 > > -----Original Message----- > > From: Paolo Abeni > > Sent: Thursday, November 10, 2022 5:54 AM > > To: Shenwei Wang ; David S. Miller > > ; Eric Dumazet ; Jakub > > Kicinski > > > case ETH_SS_STATS: > > > - for (i = 0; i < ARRAY_SIZE(fec_stats); i++) > > > - memcpy(data + i * ETH_GSTRING_LEN, > > > - fec_stats[i].name, ETH_GSTRING_LEN); > > > + for (i = 0; i < ARRAY_SIZE(fec_stats); i++) { > > > + memcpy(data, fec_stats[i].name, ETH_GSTRING_LEN); > > > + data += ETH_GSTRING_LEN; > > > + } > > > + for (i = 0; i < ARRAY_SIZE(fec_xdp_stat_strs); i++) { > > > + memcpy(data, fec_xdp_stat_strs[i], ETH_GSTRING_LEN); > > > + data += ETH_GSTRING_LEN; > > > > The above triggers a warning: > > > > In function 'fortify_memcpy_chk', > > inlined from 'fec_enet_get_strings' > > at ../drivers/net/ethernet/freescale/fec_main.c:2788:4: > > ../include/linux/fortify-string.h:413:25: warning: call to '__read_overflow2_field' > > declared with attribute warning: detected read beyond size of field (2nd > > parameter); maybe use struct_group()? [-Wattribute-warning] > > 413 | __read_overflow2_field(q_size_field, size); > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > I think you can address it changing fec_xdp_stat_strs definition to: > > > > static const char fec_xdp_stat_strs[XDP_STATS_TOTAL][ETH_GSTRING_LEN] = > > That does a problem. How about just change the memcpy to strncpy? Don't use a static char array, it would consume more memory than the current code. Just replace memcpy()s with strscpy(). Why u32 for the stats tho? It will overflow sooner or later. "To keep it simple and compatible" you can use u64_stats API :) > > Regards, > Shenwei > > > { // ... > > > > Cheers, > > > > Paolo Thanks, Olek