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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6fffd2fe-0cee-405f-af78-b57b5e5d02e8@suse.cz>
Date: Wed, 4 Jun 2025 11:56:42 +0200
From: Vlastimil Babka <vbabka@...e.cz>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
 Andrew Morton <akpm@...ux-foundation.org>,
 David Hildenbrand <david@...hat.com>
Cc: lorenzo.stoakes@...cle.com, Liam.Howlett@...cle.com, rppt@...nel.org,
 surenb@...gle.com, mhocko@...e.com, hannes@...xchg.org,
 shakeel.butt@...ux.dev, muchun.song@...ux.dev, linux-mm@...ck.org,
 linux-kernel@...r.kernel.org, Randy Dunlap <rdunlap@...radead.org>,
 Konstantin Khlebnikov <koct9i@...il.com>
Subject: Re: [PATCH] mm/vmstat: Fix build with MEMCG=y and VM_EVENT_COUNTERS=n

On 6/4/25 11:51, Kirill A. Shutemov wrote:
> When compiling with MEMCG enabled but VM_EVENT_COUNTERS disabled,
> BUILD_BUG_ON() is triggered in vmstat_start because the vmstat_text
> array is larger than NR_VMSTAT_ITEMS.
> 
> This issue arises because some elements of the vmstat_text array are
> present when either MEMCG or VM_EVENT_COUNTERS is enabled, but
> NR_VMSTAT_ITEMS only accounts for these elements if VM_EVENT_COUNTERS is
> enabled.
> 
> The recent change in the BUILD_BUG_ON() check made it more strict,
> disallowing extra elements in the array, which revealed the issue.
> 
> Instead of adjusting the NR_VMSTAT_ITEMS definition to account for
> MEMCG, make MEMCG select VM_EVENT_COUNTERS. VM_EVENT_COUNTERS is
> enabled in most configurations anyway.
> 
> There is no need to backport this fix to stable trees. Without the
> strict BUILD_BUG_ON(), the issue is not harmful. The elements in
> question would only be read by the memcg code, not by /proc/vmstat.
> 
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
> Reported-by: Randy Dunlap <rdunlap@...radead.org>
> Fixes: ebc5d83d0443 ("mm/memcontrol: use vmstat names for printing statistics")

Well in that case I think we should put Fixes: to the BUILD_BUG_ON() change.
And if it's not yet a stable sha1, squash that together with this?
It doesn't seem ebc5d83d0443 alone needs this fix.

> Cc: Konstantin Khlebnikov <koct9i@...il.com>

Otherwise,
Acked-by: Vlastimil Babka <vbabka@...e.cz>

> ---
>  include/linux/vmstat.h | 4 ++--
>  init/Kconfig           | 1 +
>  mm/vmstat.c            | 4 ++--
>  3 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
> index b2ccb6845595..c287998908bf 100644
> --- a/include/linux/vmstat.h
> +++ b/include/linux/vmstat.h
> @@ -507,7 +507,7 @@ static inline const char *lru_list_name(enum lru_list lru)
>  	return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
>  }
>  
> -#if defined(CONFIG_VM_EVENT_COUNTERS) || defined(CONFIG_MEMCG)
> +#if defined(CONFIG_VM_EVENT_COUNTERS)
>  static inline const char *vm_event_name(enum vm_event_item item)
>  {
>  	return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
> @@ -516,7 +516,7 @@ static inline const char *vm_event_name(enum vm_event_item item)
>  			   NR_VM_STAT_ITEMS +
>  			   item];
>  }
> -#endif /* CONFIG_VM_EVENT_COUNTERS || CONFIG_MEMCG */
> +#endif /* CONFIG_VM_EVENT_COUNTERS */
>  
>  #ifdef CONFIG_MEMCG
>  
> diff --git a/init/Kconfig b/init/Kconfig
> index ab83abe0fd9d..dd332cac6036 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -989,6 +989,7 @@ config MEMCG
>  	select PAGE_COUNTER
>  	select EVENTFD
>  	select SLAB_OBJ_EXT
> +	select VM_EVENT_COUNTERS
>  	help
>  	  Provides control over the memory footprint of tasks in a cgroup.
>  
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index 27dc37168cfd..c3114b8826e4 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -1301,7 +1301,7 @@ const char * const vmstat_text[] = {
>  	[I(NR_MEMMAP_BOOT_PAGES)]		= "nr_memmap_boot_pages",
>  #undef I
>  
> -#if defined(CONFIG_VM_EVENT_COUNTERS) || defined(CONFIG_MEMCG)
> +#if defined(CONFIG_VM_EVENT_COUNTERS)
>  	/* enum vm_event_item counters */
>  #define I(x) (NR_VM_ZONE_STAT_ITEMS + NR_VM_NUMA_EVENT_ITEMS + \
>  	     NR_VM_NODE_STAT_ITEMS + NR_VM_STAT_ITEMS + x)
> @@ -1498,7 +1498,7 @@ const char * const vmstat_text[] = {
>  #endif
>  #endif
>  #undef I
> -#endif /* CONFIG_VM_EVENT_COUNTERS || CONFIG_MEMCG */
> +#endif /* CONFIG_VM_EVENT_COUNTERS */
>  };
>  #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA || CONFIG_MEMCG */
>  


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ