Received: by 2002:a17:90a:bc8d:0:0:0:0 with SMTP id x13csp1573263pjr; Mon, 18 May 2020 16:46:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1q8uthDctpwWkKJkL0ob5XCVkf1+HCq3inawukHY4qn38qxn8kICyu3WqB2CZzns4SZE5 X-Received: by 2002:a50:fd04:: with SMTP id i4mr16242326eds.43.1589845573358; Mon, 18 May 2020 16:46:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589845573; cv=none; d=google.com; s=arc-20160816; b=V5iJ+WvfV9SxxeaIPW2pyRHmkn0Y0CucjPkvru7HgiLIv6Hk7AKjYFpLZMJu0qCuCD bxZcqPoVt7OSY3MuXfvNPTjfjiLrfW3CVHn4YJkRL9ZMS929SkNybMtdk2NHN0xi4930 6GAd+QY+dzHpdZInqERC/NPLd/V9oAhqdwYhQtw0O1w8QAPhTf9mMtscsHCD1XQVtqkE lXlLS/OF9SshMhAuBYcwomK1/evtJmdxOcQmpmM1CLJNnwBAHbMRtYWfIweauuPJOzwr 0ReXOp2PJr1KZptbqS5cUcbvg2uIqGVBUH8utqSUhP0rXyEHnuzD5QhaUBxb4M0fNhlt HpIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Bdnu7SdocKUXn6MZcEh5GrMxAQ4vpnj+kpX+WC45nkE=; b=zSOuK5solxZTjd3Us+V5X+Rpxlr/Zdh6Nl3yBshS1TnNNWsP/Q02pA9kb8FadEOKsT UnVg6StxqCpr0LvnF8b4X2XsTQhmevkO/PTeQ9YFh+S2bjQMBhSvEOv99bcGWklLVC8o gHgBkUUpYovy8U2eVf1hdgzevNTO5XEj2pqPe57zlLegvZtjMjtyyB7THZI5xQ4nFOi6 DCKiFtXp9cTud8t64ayt7RdRTD1uQNnuSOQeQbOk3lqK86s4CtG60FEiLfdZjRZrhRqr wqroSiJIk0r0B41nf4f6XFziavr1GZLar6Uru+S3NI2nOQ5cDVGKg6ETXElh/XltFmrw FFvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hwlykVNH; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id aq3si7554852ejc.439.2020.05.18.16.45.50; Mon, 18 May 2020 16:46:13 -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=default header.b=hwlykVNH; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732740AbgERSEH (ORCPT + 99 others); Mon, 18 May 2020 14:04:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:49582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732699AbgERSDv (ORCPT ); Mon, 18 May 2020 14:03:51 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1EB6920715; Mon, 18 May 2020 18:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589825030; bh=9ychuZlDSEzXZQNjTC392RG4bW5HCYLMbeH7TWLjKcA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hwlykVNHXKjiuNH3q0Vjp+QH94vDHATwr/SNuXojrp6tR6+4U/V06wo9yuO0G3duQ 0Ij2hysby1L8cEzTKkdIJfMF/RN/FV+Iwz9Gs/nAS39xgZx3XnVjnuv19ti8a54P6v r7thKrmX/Cf8cF+B84xNxY13GEZwzTZZjDkDxaPc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.6 101/194] netfilter: conntrack: avoid gcc-10 zero-length-bounds warning Date: Mon, 18 May 2020 19:36:31 +0200 Message-Id: <20200518173540.347275379@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518173531.455604187@linuxfoundation.org> References: <20200518173531.455604187@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann [ Upstream commit 2c407aca64977ede9b9f35158e919773cae2082f ] gcc-10 warns around a suspicious access to an empty struct member: net/netfilter/nf_conntrack_core.c: In function '__nf_conntrack_alloc': net/netfilter/nf_conntrack_core.c:1522:9: warning: array subscript 0 is outside the bounds of an interior zero-length array 'u8[0]' {aka 'unsigned char[0]'} [-Wzero-length-bounds] 1522 | memset(&ct->__nfct_init_offset[0], 0, | ^~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from net/netfilter/nf_conntrack_core.c:37: include/net/netfilter/nf_conntrack.h:90:5: note: while referencing '__nfct_init_offset' 90 | u8 __nfct_init_offset[0]; | ^~~~~~~~~~~~~~~~~~ The code is correct but a bit unusual. Rework it slightly in a way that does not trigger the warning, using an empty struct instead of an empty array. There are probably more elegant ways to do this, but this is the smallest change. Fixes: c41884ce0562 ("netfilter: conntrack: avoid zeroing timer") Signed-off-by: Arnd Bergmann Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- include/net/netfilter/nf_conntrack.h | 2 +- net/netfilter/nf_conntrack_core.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h index 9f551f3b69c65..90690e37a56f0 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h @@ -87,7 +87,7 @@ struct nf_conn { struct hlist_node nat_bysource; #endif /* all members below initialized via memset */ - u8 __nfct_init_offset[0]; + struct { } __nfct_init_offset; /* If we were expected by an expectation, this will be it */ struct nf_conn *master; diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 1927fc296f951..6a978d7e0d639 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -1517,9 +1517,9 @@ __nf_conntrack_alloc(struct net *net, ct->status = 0; ct->timeout = 0; write_pnet(&ct->ct_net, net); - memset(&ct->__nfct_init_offset[0], 0, + memset(&ct->__nfct_init_offset, 0, offsetof(struct nf_conn, proto) - - offsetof(struct nf_conn, __nfct_init_offset[0])); + offsetof(struct nf_conn, __nfct_init_offset)); nf_ct_zone_add(ct, zone); -- 2.20.1