lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu,  5 Jan 2023 14:01:53 -0800
From:   Kees Cook <keescook@...omium.org>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     Kees Cook <keescook@...omium.org>,
        Dan Williams <dan.j.williams@...el.com>,
        Alex Sierra <alex.sierra@....com>,
        Felix Kuehling <Felix.Kuehling@....com>,
        "Matthew Wilcox (Oracle)" <willy@...radead.org>,
        Shiyang Ruan <ruansy.fnst@...itsu.com>,
        "Gustavo A. R. Silva" <gustavoars@...nel.org>, linux-mm@...ck.org,
        Alistair Popple <apopple@...dia.com>,
        Joao Martins <joao.m.martins@...cle.com>,
        Mike Rapoport <rppt@...nel.org>, linux-kernel@...r.kernel.org,
        linux-hardening@...r.kernel.org
Subject: [PATCH] memremap: Replace 0-length array with flexible array

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 <unknown> 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 <akpm@...ux-foundation.org>
Cc: Dan Williams <dan.j.williams@...el.com>
Cc: Alex Sierra <alex.sierra@....com>
Cc: Felix Kuehling <Felix.Kuehling@....com>
Cc: "Matthew Wilcox (Oracle)" <willy@...radead.org>
Cc: Shiyang Ruan <ruansy.fnst@...itsu.com>
Cc: "Gustavo A. R. Silva" <gustavoars@...nel.org>
Cc: linux-mm@...ck.org
Signed-off-by: Kees Cook <keescook@...omium.org>
---
 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ