Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp1481530rwl; Thu, 5 Jan 2023 14:23:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXucNSssNxaL7VHobDDOj5gSYmXQjlHotv2IxfDoePfLCThCGR+oG3qYQr/lbYttAbGh+kWp X-Received: by 2002:a17:907:2c6c:b0:828:7581:f01f with SMTP id ib12-20020a1709072c6c00b008287581f01fmr40180254ejc.23.1672957410812; Thu, 05 Jan 2023 14:23:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672957410; cv=none; d=google.com; s=arc-20160816; b=gsM0CeBO+tVpNxgklBPqznDX1PXV1LwqvwxZ7x1l54Hc+okmL/qKbD1PqnMyBc1/zi t3YyyZNVWo7cf3pwcyVj1q3MaaqU7svFsB0PbJFk6zfpWgx27G4GCu9HqH24AcxDmEU8 a6kz8DXRHMsrD9ywTzh8BeXxNtxNdHCCzfhOHtb5ZslupCVGlBVFPUs+pSJqXlL+n4id dwJtwLY2RCiWg3sZqZHYaH3Ie+lkjrL4Db7OVnYSBHxeJpv6JArrQc/tYShCSvgfCfj9 ZPnSCjYyb99y7yi0DYEBio3fXIR51Y8zuuAE1ohlbgkW719hGrdrbG+BEk7SxUg2gvNQ TDUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=g7ARxzRg4qeZnxsuTwCkOlUDNOTEW0lHQtXXNhpQJUw=; b=bhOwPCH0BO6va2DL0e39I26L1yulxujEVOImhU1vLF2nbO8CSRn3i8VjGmM7O/Cfzj NIwdJlp2XOj+LFp2pz8T2sxjwIBXAkuHOYtAp65Jvcur8l+YbDHZMgygT9VNHlKLH8xx kO0SvOEO2ce4lk+jwIzjF3AWVvee9rdJLCM4wNVGxny0XWDWA4oeA5pOviToK8s+lSYX GgnSmBtNlXHIc/8teR+GZ9NP+2UELX5PQFPgVd33IXNKCFPhPLg8ahZuRG00Fmda0z1q AHuy7bVlnU07kUr0/RG9N2km1j7oA46+K3kPoR8qfoda4aR6Bsvo4fqtQb7TAHm3oUku XCCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tlelhkEs; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr18-20020a170906d55200b0084b895b6a22si31209829ejc.947.2023.01.05.14.23.17; Thu, 05 Jan 2023 14:23:30 -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=@kernel.org header.s=k20201202 header.b=tlelhkEs; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235525AbjAEWOG (ORCPT + 55 others); Thu, 5 Jan 2023 17:14:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229694AbjAEWOE (ORCPT ); Thu, 5 Jan 2023 17:14:04 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62B3CFD07; Thu, 5 Jan 2023 14:14:03 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1BA4FB81BFA; Thu, 5 Jan 2023 22:14:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46326C433D2; Thu, 5 Jan 2023 22:13:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672956840; bh=Z4eOuR/y0KdIFBiLFGkqOAfGHfUV0LGrmKrUyXhuSV4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tlelhkEsD3B8WqyKGrMXIm8RCLl1yfMt2vGBhC6/cVb4OMXRRtrjPJAhXhcxi2ISf oN+R7lcR+jEJnjCg31rTpKG8cDWlunogBxAVOiIF9fVnKL+bJPmUq3Z5V/aYErMbRS 8T+4kYUm94xf2UDnHZIQ7ZLN0OGh0iiiunTjyiWnvdV962DxZZUgdechk0jMNcf4AH OoSpoYtRYoN5l7QFYlw8htQGW9WGgMaUQck1X13q8RmnZw+t7x2PJ6+qOWHsyEPloF FAzPsZrkStxLEWFdk7EB0OHqSlihf/yROoiqlw2wYo4f8t/j4DavEIhiSgTDCLz9h2 bm2smTqzvhP8g== Date: Thu, 5 Jan 2023 16:14:05 -0600 From: "Gustavo A. R. Silva" To: Kees Cook Cc: Andrew Morton , Dan Williams , Alex Sierra , Felix Kuehling , "Matthew Wilcox (Oracle)" , Shiyang Ruan , linux-mm@kvack.org, Alistair Popple , Joao Martins , Mike Rapoport , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] memremap: Replace 0-length array with flexible array Message-ID: References: <20230105220151.never.343-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230105220151.never.343-kees@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 I think this is the same patch: https://lore.kernel.org/linux-hardening/YxKO%2FjY1x0xTpl4r@work/ It's actually in linux-next. -- Gustavo On Thu, Jan 05, 2023 at 02:01:53PM -0800, Kees Cook wrote: > Zero-length arrays are deprecated[1]. Replace struct ethtool_rxnfc's > "rule_locs" 0-length array with a flexible array. Detected with GCC 13, > using -fstrict-flex-arrays=3: > > In file included from include/asm-generic/memory_model.h:5, > from arch/x86/include/asm/page.h:86, > from arch/x86/include/asm/thread_info.h:12, > from include/linux/thread_info.h:60, > from arch/x86/include/asm/preempt.h:9, > from include/linux/preempt.h:78, > from include/linux/spinlock.h:56, > from include/linux/mmzone.h:8, > from include/linux/gfp.h:7, > from include/linux/mm.h:7, > from mm/sparse-vmemmap.c:21: > In function 'reuse_compound_section', > inlined from 'vmemmap_populate_compound_pages' at mm/sparse-vmemmap.c:407:6, > inlined from '__populate_section_memmap' at mm/sparse-vmemmap.c:463:7: > mm/sparse-vmemmap.c:376:39: warning: array subscript is outside array bounds of 'struct range[0]' [-Warray-bounds=] > 376 | PHYS_PFN(pgmap->ranges[pgmap->nr_range].start); > | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ > include/linux/pfn.h:22:43: note: in definition of macro 'PHYS_PFN' > 22 | #define PHYS_PFN(x) ((unsigned long)((x) >> PAGE_SHIFT)) > | ^ > In file included from include/linux/mm.h:31: > include/linux/memremap.h: In function '__populate_section_memmap': > include/linux/memremap.h:138:30: note: while referencing 'ranges' > 138 | struct range ranges[0]; > | ^~~~~~ > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays > > Cc: Andrew Morton > Cc: Dan Williams > Cc: Alex Sierra > Cc: Felix Kuehling > Cc: "Matthew Wilcox (Oracle)" > Cc: Shiyang Ruan > Cc: "Gustavo A. R. Silva" > Cc: linux-mm@kvack.org > Signed-off-by: Kees Cook > --- > include/linux/memremap.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/memremap.h b/include/linux/memremap.h > index 7fcaf3180a5b..1314d9c5f05b 100644 > --- a/include/linux/memremap.h > +++ b/include/linux/memremap.h > @@ -135,7 +135,7 @@ struct dev_pagemap { > int nr_range; > union { > struct range range; > - struct range ranges[0]; > + DECLARE_FLEX_ARRAY(struct range, ranges); > }; > }; > > -- > 2.34.1 >