* + mm-page_counter-reject-empty-string-in-page_counter_memparse.patch added to mm-new branch
@ 2026-08-30 0:42 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-08-30 0:42 UTC (permalink / raw)
To: mm-commits, shakeel.butt, roman.gushchin, muchun.song, mhocko,
hannes, cuitao, akpm
The patch titled
Subject: mm: page_counter: reject empty string in page_counter_memparse()
has been added to the -mm mm-new branch. Its filename is
mm-page_counter-reject-empty-string-in-page_counter_memparse.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-page_counter-reject-empty-string-in-page_counter_memparse.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Tao Cui <cuitao@kylinos.cn>
Subject: mm: page_counter: reject empty string in page_counter_memparse()
Date: Mon, 17 Aug 2026 12:26:52 +0800
memparse() consumes no characters on an empty input and leaves the end
pointer at the terminating NUL. The only validation in
page_counter_memparse() checks for trailing characters, so an empty input
slips through and the limit becomes 0.
All limit write callbacks of the memory controller strstrip() the input
before calling this helper, so a script that writes an unset variable hits
this path:
LIMIT=
echo "$LIMIT" > $CG/memory.max
echo $?
0
cat $CG/memory.max
0
Nothing reports the mistake: the limit is now 0 and the OOM killer goes
after every task in the cgroup. The same happens for memory.min,
memory.low, memory.high, memory.swap.high, memory.swap.max and
memory.zswap.max, where 0 silently removes the protection or disables swap
and zswap.
Reject the input when no characters were consumed, which is the one case
the trailing-character check cannot catch.
Link: https://lore.kernel.org/20260817042652.74136-1-cui.tao@linux.dev
Fixes: 3e32cb2e0a12 ("mm: memcontrol: lockless page counters")
Signed-off-by: Tao Cui <cuitao@kylinos.cn>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/page_counter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/mm/page_counter.c~mm-page_counter-reject-empty-string-in-page_counter_memparse
+++ a/mm/page_counter.c
@@ -281,7 +281,7 @@ int page_counter_memparse(const char *bu
}
bytes = memparse(buf, &end);
- if (*end != '\0')
+ if (*end != '\0' || end == buf)
return -EINVAL;
*nr_pages = min(bytes / PAGE_SIZE, (u64)PAGE_COUNTER_MAX);
_
Patches currently in -mm which might be from cuitao@kylinos.cn are
docs-cgroup-document-empty-write-behavior-of-memory-limit-knobs.patch
mm-page_counter-reject-empty-string-in-page_counter_memparse.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-30 0:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-30 0:42 + mm-page_counter-reject-empty-string-in-page_counter_memparse.patch added to mm-new branch Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.