Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2905402ybk; Mon, 18 May 2020 10:46:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHf5E9gAinCYmP1RlbEw+HNq3AtaP4FGLslrVCRX2h/5L+FdX/mVMN0IsU/hVm5DhLBu7t X-Received: by 2002:a05:6402:c2:: with SMTP id i2mr15022442edu.224.1589824015491; Mon, 18 May 2020 10:46:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589824015; cv=none; d=google.com; s=arc-20160816; b=Vrr8ZN+wJneuUaWiy+YyJr+wP8PA49zHn9wIuQUvt4KvF7gT/cXdYTEgOAfabBvech oaZLeQ1tZ+AocuspmDT4M1S15cyE6OGSzBbsgUj9EpEHyxXQepK6jk21LF/YFvE4w9P0 a3MEpSgGlWnSrVF4b+lDKQVyvac44tzxvxt1Q3d2vYqJ1PgUFU5qP0LRfieWQn4qfLyh uV85bf6Zulc2mZrhOV7To1uK35yv7F+yYFAyFaSy0cgxDTCDQufP4/wMrK0uCT1NYa+G Ke9TXUnPDVaQS0Y5ObVeM4FGfw/oP8sLMfi2VqnQm+yuFx/9Fnfbp7s7EEfunIfEKZeo s2gw== 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=2mdXz6x2oeDcwWhYg+nWWTvDstnEZ0uZmwioiPZl8yw=; b=Dw8uEB+K50CbO8oTEBD7RszrzmCLSt+Sy6T6gH4ecAp/CeZRX0zDL0p9C+v6Gb+m6F LHkJ8zK0614B1CwLjN9mzxMViFUesdYbLXmZ25xRX95T/Jz4tnU7a4tl8M0FqsCMticA 83+fyUb4+6BHuF8z9q3c1//cOHFCPVQxU3qJqkCrBiQHnou+GhlFnqJISPYpX/ViaZlA MFatqF/Ea/Xlmt8nD/uuyj0tl4SiN8URV7okFD/LSUPGl6mZb15rIDv3qwjBunRezKjC ID96Crc7Y/7kFdLPnULqFALF+W3mUJXzCfEF8gLS1PARM6nXAzSNY08OssCj6tQWqIWs y3Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MeHs8rx5; 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 q11si5713032edb.536.2020.05.18.10.46.32; Mon, 18 May 2020 10:46:55 -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=MeHs8rx5; 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 S1729678AbgERRoF (ORCPT + 99 others); Mon, 18 May 2020 13:44:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:42032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729650AbgERRoB (ORCPT ); Mon, 18 May 2020 13:44:01 -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 43F52207C4; Mon, 18 May 2020 17:44:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589823840; bh=55PKlhmg1rmfRguUkGNgpg1h9UfCnaM6roGxuu9k3bA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MeHs8rx51KjpLOeGLfBxFioS3orUU6j2CSay1DozoCbChJywlgKCCmz9snO9MUwaF LfVXiL52tr45QpJW3xGzbZaiRnhd6hQlhBKlrmr0p0p3X0PCd/nY4RFa8PTdkCBxTt q+cAICmtfaFPawRxwTKaPo6LGXBT26BFuUyWaqAo= 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 4.9 56/90] netfilter: conntrack: avoid gcc-10 zero-length-bounds warning Date: Mon, 18 May 2020 19:36:34 +0200 Message-Id: <20200518173502.512499313@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518173450.930655662@linuxfoundation.org> References: <20200518173450.930655662@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 b57a9f37c297b..7befec513295d 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h @@ -103,7 +103,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 1bdae8f188e1f..d507d0fc7858a 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -1124,9 +1124,9 @@ __nf_conntrack_alloc(struct net *net, *(unsigned long *)(&ct->tuplehash[IP_CT_DIR_REPLY].hnnode.pprev) = hash; ct->status = 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