public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] fix unexpected type conversions and potential overflows
@ 2026-03-27 10:16 Qi Zheng
  2026-03-27 10:16 ` [PATCH v3 1/3] mm: memcontrol: correct the type of stats_updates to unsigned long Qi Zheng
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Qi Zheng @ 2026-03-27 10:16 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>

Changes in v3:
 - squash [PATCH v2 4/4] into [PATCH v2 2/4] (suggested-by Lorenzo Stoakes)
 - split complex calculation into multiple steps (suggested-by Lorenzo Stoakes)
 - collect Reviewed-bys
 - rebase onto the next-20260326

Changes in v2:
 - modified all commit messages. (suggested-by Lorenzo Stoakes)
 - added a fix patch to resolve the unexpected massive positive number
   (pointed-by Harry Yoo and sashiko)
 - fix the print type mismatch in [PATCH 3/3]
 - collect Reviewed-by

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-20260326.

Comments and suggestions are welcome!

Thanks,
Qi

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

Qi Zheng (3):
  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()

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

-- 
2.20.1



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

end of thread, other threads:[~2026-03-30  2:22 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-27 10:16 [PATCH v3 0/3] fix unexpected type conversions and potential overflows Qi Zheng
2026-03-27 10:16 ` [PATCH v3 1/3] mm: memcontrol: correct the type of stats_updates to unsigned long Qi Zheng
2026-03-27 15:45   ` Zi Yan
2026-03-30  1:14   ` Harry Yoo (Oracle)
2026-03-27 10:16 ` [PATCH v3 2/3] mm: memcontrol: change val type to long in __mod_memcg_{lruvec_}state() Qi Zheng
2026-03-27 15:48   ` Zi Yan
2026-03-30  1:25   ` Harry Yoo (Oracle)
2026-03-30  2:22     ` Qi Zheng
2026-03-27 10:16 ` [PATCH v3 3/3] mm: memcontrol: correct the nr_pages parameter type of mem_cgroup_update_lru_size() Qi Zheng
2026-03-27 10:22   ` Lorenzo Stoakes (Oracle)
2026-03-27 15:49   ` Zi Yan
2026-03-30  1:32   ` Harry Yoo (Oracle)

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