public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] fix unexpected type conversions and potential overflows
@ 2026-03-25 14:13 Qi Zheng
  2026-03-25 14:13 ` [PATCH v2 1/4] mm: memcontrol: correct the type of stats_updates to unsigned long Qi Zheng
                   ` (6 more replies)
  0 siblings, 7 replies; 25+ messages in thread
From: Qi Zheng @ 2026-03-25 14:13 UTC (permalink / raw)
  To: hannes, hughd, mhocko, roman.gushchin, shakeel.butt, muchun.song,
	david, ljs, ziy, harry.yoo, yosry.ahmed, imran.f.khan,
	kamalesh.babulal, axelrasmussen, yuanchu, weixugc, chenridong,
	mkoutny, akpm, hamzamahfooz, apais, lance.yang, bhe, usamaarif642
  Cc: linux-mm, linux-kernel, Qi Zheng

From: Qi Zheng <zhengqi.arch@bytedance.com>

Hi all,

As Harry Yoo pointed out [1], in scenarios where massive state updates occur
(e.g., during the reparenting of LRU folios), the values passed to memcg stat
update functions can accumulate and exceed the upper limit of a 32-bit integer.

If the parameter types are not large enough (like 'int') or are handled
incorrectly, it can lead to severe truncation, potential overflow issues,
and unexpected type conversion bugs.

This series aims to address these issues by correcting the parameter types
in the relevant functions, and fixing an implicit conversion bug in
memcg_state_val_in_pages().

This series is based on the next-20260323.

Comments and suggestions are welcome!

Thanks,
Qi

[1]. https://lore.kernel.org/all/acDxaEgnqPI-Z4be@hyeyoo/

Qi Zheng (4):
  mm: memcontrol: correct the type of stats_updates to unsigned long
  mm: memcontrol: change val type to long in
    __mod_memcg_{lruvec_}state()
  mm: memcontrol: correct the nr_pages parameter type of
    mem_cgroup_update_lru_size()
  mm: memcontrol: fix unexpected massive positive number in
    memcg_state_val_in_pages()

 include/linux/memcontrol.h   |  2 +-
 include/trace/events/memcg.h | 10 +++++-----
 mm/memcontrol.c              | 37 +++++++++++++++++++-----------------
 3 files changed, 26 insertions(+), 23 deletions(-)

-- 
2.20.1



^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2026-03-26 14:37 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-25 14:13 [PATCH v2 0/4] fix unexpected type conversions and potential overflows Qi Zheng
2026-03-25 14:13 ` [PATCH v2 1/4] mm: memcontrol: correct the type of stats_updates to unsigned long Qi Zheng
2026-03-25 15:28   ` Lorenzo Stoakes (Oracle)
2026-03-26  2:32     ` Qi Zheng
2026-03-26  8:05       ` Lorenzo Stoakes (Oracle)
2026-03-26  8:19         ` Harry Yoo (Oracle)
2026-03-26  8:20         ` Qi Zheng
2026-03-25 14:13 ` [PATCH v2 2/4] mm: memcontrol: change val type to long in __mod_memcg_{lruvec_}state() Qi Zheng
2026-03-26  9:19   ` Lorenzo Stoakes (Oracle)
2026-03-26 14:37     ` David Laight
2026-03-25 14:13 ` [PATCH v2 3/4] mm: memcontrol: correct the nr_pages parameter type of mem_cgroup_update_lru_size() Qi Zheng
2026-03-25 14:13 ` [PATCH v2 4/4] mm: memcontrol: fix unexpected massive positive number in memcg_state_val_in_pages() Qi Zheng
2026-03-26  9:16   ` Lorenzo Stoakes (Oracle)
2026-03-26  9:21     ` Lorenzo Stoakes (Oracle)
2026-03-26  9:32     ` Qi Zheng
2026-03-26  9:38       ` Lorenzo Stoakes (Oracle)
2026-03-25 14:24 ` [PATCH v2 0/4] fix unexpected type conversions and potential overflows Qi Zheng
2026-03-25 23:57 ` Andrew Morton
2026-03-26  0:28   ` Andrew Morton
2026-03-26  2:30   ` Qi Zheng
2026-03-26  3:27     ` Andrew Morton
2026-03-26  7:14 ` Michal Hocko
2026-03-26  7:51   ` Harry Yoo (Oracle)
2026-03-26  8:18     ` Michal Hocko
2026-03-26  9:22       ` Lorenzo Stoakes (Oracle)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox