From 240b887cf0d119ba076822e4427102fa034927af Mon Sep 17 00:00:00 2001 From: Yuanhe Shu Date: Mon, 2 Nov 2026 17:00:55 +0800 Subject: [PATCH] anolis: mm: pagecache_limit: reject reclaim_interval_ms values above UINT_MAX ANBZ: #54819 The memory.pagecache_limit.reclaim_interval_ms cgroup v1 interface parses its input with kstrtou64() but passes the value directly to msecs_to_jiffies(), whose parameter type is unsigned int. Values above UINT_MAX therefore lose their high bits silently: writing 4294967296 (2^32) succeeds and stores/reads back 0, which disables the reclaim worker's interval-based re-arming in memcg_pgcache_limit_work_func(), and writing 2^32+1000 is treated as 1000 ms. The saturation guard inside __msecs_to_jiffies() only sees the already-narrowed value and cannot catch this. Reject inputs above UINT_MAX with -EINVAL in the write callback, so over-range configurations fail loudly instead of silently changing the configured interval. All values within [0, UINT_MAX] keep their exact previous behavior. Fixes: 0d2c9219090f ("anolis: mm: pagecache_limit: reclaim pagecache smoothly") Signed-off-by: Yuanhe Shu --- mm/memcontrol.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 1d4ca7f8d404..d39867ef5d2e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6830,6 +6830,8 @@ mem_cgroup_pgcache_reclaim_interval_write(struct kernfs_open_file *of, if (kstrtou64(strstrip(buf), 0, &interval)) return -EINVAL; + if (interval > UINT_MAX) + return -EINVAL; memcg->pgcache_limit_reclaim_interval = msecs_to_jiffies(interval); return nbytes; -- Gitee