From: Kirill A. Shutemov Date: Thu, 29 May 2025 11:05:41 +0000 (+0300) Subject: mm: strictly check vmstat_text array size X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a63ff68e5ead16ab384dcbed6103f9ad371e246;p=thirdparty%2Flinux.git mm: strictly check vmstat_text array size /proc/vmstat displays counters from various sources. It is easy to forget to add or remove a label when a new counter is added or removed. There is a BUILD_BUG_ON() function that catches missing labels. However, for some reason, it ignores extra labels. Let's make the check strict. This would help to catch issues when a counter is removed. Link: https://lkml.kernel.org/r/20250529110541.2960330-1-kirill.shutemov@linux.intel.com Signed-off-by: Kirill A. Shutemov Reviewed-by: Vlastimil Babka Acked-by: Michal Hocko Reviewed-by: David Hildenbrand Cc: Konstantin Khlebnikov Cc: Kirill A. Shuemov Cc: Liam Howlett Cc: Lorenzo Stoakes Cc: Mike Rapoport Cc: Suren Baghdasaryan Signed-off-by: Andrew Morton --- diff --git a/mm/vmstat.c b/mm/vmstat.c index 01d76216d65a2..41f6a64e5c39f 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1867,7 +1867,7 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos) if (*pos >= NR_VMSTAT_ITEMS) return NULL; - BUILD_BUG_ON(ARRAY_SIZE(vmstat_text) < NR_VMSTAT_ITEMS); + BUILD_BUG_ON(ARRAY_SIZE(vmstat_text) != NR_VMSTAT_ITEMS); fold_vm_numa_events(); v = kmalloc_array(NR_VMSTAT_ITEMS, sizeof(unsigned long), GFP_KERNEL); m->private = v;