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 X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADAC3C4724C for ; Fri, 1 May 2020 12:41:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 92C6220708 for ; Fri, 1 May 2020 12:41:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728791AbgEAMlr (ORCPT ); Fri, 1 May 2020 08:41:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728712AbgEAMlr (ORCPT ); Fri, 1 May 2020 08:41:47 -0400 X-Greylist: delayed 4393 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 01 May 2020 05:41:47 PDT Received: from smtp.tuxdriver.com (tunnel92311-pt.tunnel.tserv13.ash1.ipv6.he.net [IPv6:2001:470:7:9c9::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1C41CC061A0C; Fri, 1 May 2020 05:41:47 -0700 (PDT) Received: from [107.15.85.130] (helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1jUTq8-0005B2-96; Fri, 01 May 2020 07:28:26 -0400 Date: Fri, 1 May 2020 07:28:14 -0400 From: Neil Horman To: Arnd Bergmann Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Jakub Kicinski , Ido Schimmel , Jiri Pirko , Joe Perches , netdev@vger.kernel.org Subject: Re: [PATCH 07/15] drop_monitor: work around gcc-10 stringop-overflow warning Message-ID: <20200501112814.GA2175875@hmswarspite.think-freely.org> References: <20200430213101.135134-1-arnd@arndb.de> <20200430213101.135134-8-arnd@arndb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200430213101.135134-8-arnd@arndb.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 30, 2020 at 11:30:49PM +0200, Arnd Bergmann wrote: > The current gcc-10 snapshot produces a false-positive warning: > > net/core/drop_monitor.c: In function 'trace_drop_common.constprop': > cc1: error: writing 8 bytes into a region of size 0 [-Werror=stringop-overflow=] > In file included from net/core/drop_monitor.c:23: > include/uapi/linux/net_dropmon.h:36:8: note: at offset 0 to object 'entries' with size 4 declared here > 36 | __u32 entries; > | ^~~~~~~ > > I reported this in the gcc bugzilla, but in case it does not get > fixed in the release, work around it by using a temporary variable. > > Fixes: 9a8afc8d3962 ("Network Drop Monitor: Adding drop monitor implementation & Netlink protocol") > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94881 > Signed-off-by: Arnd Bergmann > --- > net/core/drop_monitor.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c > index 8e33cec9fc4e..2ee7bc4c9e03 100644 > --- a/net/core/drop_monitor.c > +++ b/net/core/drop_monitor.c > @@ -213,6 +213,7 @@ static void sched_send_work(struct timer_list *t) > static void trace_drop_common(struct sk_buff *skb, void *location) > { > struct net_dm_alert_msg *msg; > + struct net_dm_drop_point *point; > struct nlmsghdr *nlh; > struct nlattr *nla; > int i; > @@ -231,11 +232,13 @@ static void trace_drop_common(struct sk_buff *skb, void *location) > nlh = (struct nlmsghdr *)dskb->data; > nla = genlmsg_data(nlmsg_data(nlh)); > msg = nla_data(nla); > + point = msg->points; > for (i = 0; i < msg->entries; i++) { > - if (!memcmp(&location, msg->points[i].pc, sizeof(void *))) { > - msg->points[i].count++; > + if (!memcmp(&location, &point->pc, sizeof(void *))) { > + point->count++; > goto out; > } > + point++; > } > if (msg->entries == dm_hit_limit) > goto out; > @@ -244,8 +247,8 @@ static void trace_drop_common(struct sk_buff *skb, void *location) > */ > __nla_reserve_nohdr(dskb, sizeof(struct net_dm_drop_point)); > nla->nla_len += NLA_ALIGN(sizeof(struct net_dm_drop_point)); > - memcpy(msg->points[msg->entries].pc, &location, sizeof(void *)); > - msg->points[msg->entries].count = 1; > + memcpy(point->pc, &location, sizeof(void *)); > + point->count = 1; > msg->entries++; > > if (!timer_pending(&data->send_timer)) { Acked-by: Neil Horman