Received: by 2002:a17:90a:bc8d:0:0:0:0 with SMTP id x13csp1569851pjr; Mon, 18 May 2020 16:40:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6Ve00RtCp+65fWYqIA4XCvl4KDsNRxmOLDcikLsD12SWqqcCy3ksteYWrdLVI+GEkgiZ6 X-Received: by 2002:a50:eb84:: with SMTP id y4mr2560047edr.374.1589845226096; Mon, 18 May 2020 16:40:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589845226; cv=none; d=google.com; s=arc-20160816; b=OlLI2k3wz3/BCLWea28kXKlTI/vtb+UarFmBQpegVcOvEh+OX13Q181ywAk8EjN4Ga niakNn5M3jSU23TmZlAtuhcvwwMXEe3QK5BTVUYkG8WUnrdLjMD74804ZuAL5wXLzgyC 6bYIIfhsNfCQsz2uGa9ee2aBshQfsk4b7pgAwWzGiwHOGRY18rnfTaYhdwbw+YEUOR1u HuUu6jlnGUS9Zs+8/sJ+RsKklsrY/Iw0IrphIgSBBCuJiPrx4tqvPumEngEhNfgZCyvM SjsPZVR8XpOTVJEkHWdiTJILO7tzKY1p3wbBrtV62KQ5MfVQf8ym0GMwCk3tRhiB5YO7 Ekbw== 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=5cioEZDMKpN8K6wanW24DCBHn6Vulo9m+0O1OQUAAck=; b=de+gcbUp+Agro6pOMwIwTr3BOG4EliHYzHIdIIQtNdipClgovFWzzoYotZ/gGofx1i 1SnHHRgTWgYmbSEP5JB7fBa26BKcKVDKioBJ1NsRzrwc4cl1WcBSKjvuFZrWouMeXvMG cOH9eWuoZRFNnLGPfjhodY1aMd80SqqskGbUdMLHBKK3A0VW0R+CfFKKZQ+OvozlveVH eEv3sE2Xa/M1h7H6Az7C6oxMvca5Ivb320WRGBIzNQTVartik5P9k/YAHOTHcdphkNx6 8BopiKP1N1uBmSmGFATmBhP1fqNWjrW+mZQfRHg3VyL/wMAssX4EeoJYFi8hTOlCTQK6 uKhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Pf8Nx2EI; 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 u29si6495741edl.329.2020.05.18.16.40.02; Mon, 18 May 2020 16:40:26 -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=Pf8Nx2EI; 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 S1729271AbgERRl1 (ORCPT + 99 others); Mon, 18 May 2020 13:41:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:37650 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728622AbgERRlY (ORCPT ); Mon, 18 May 2020 13:41:24 -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 CBAEC207C4; Mon, 18 May 2020 17:41:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589823682; bh=JqRgiC5oYKqAVpV4yT7oxR7d3y6q8ssrO6NFSNzpyT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pf8Nx2EIjoTYIsQW0reBYxgCgs/4peMnXWlSJLyfQ1wGmRe++V8Gr19elSqq5d6Ag L5t2S+GOXj3krCWAF78HgAONLjaB9ojWsono2537lPAQGwenLqA+A2IuJ3RWMkivGS f2ljdXZI4dv45BawbHy6HgJUL119QdTAREfyCzXQ= 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.4 53/86] netfilter: conntrack: avoid gcc-10 zero-length-bounds warning Date: Mon, 18 May 2020 19:36:24 +0200 Message-Id: <20200518173501.293333661@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518173450.254571947@linuxfoundation.org> References: <20200518173450.254571947@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 636e9e11bd5f6..e3f73fd1d53a9 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h @@ -98,7 +98,7 @@ struct nf_conn { possible_net_t ct_net; /* 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 de0aad12b91d2..e58516274e86a 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -898,9 +898,9 @@ __nf_conntrack_alloc(struct net *net, /* Don't set timer yet: wait for confirmation */ setup_timer(&ct->timeout, death_by_timeout, (unsigned long)ct); 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)); if (zone && nf_ct_zone_add(ct, GFP_ATOMIC, zone) < 0) goto out_free; -- 2.20.1