From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,shakeel.butt@linux.dev,roman.gushchin@linux.dev,muchun.song@linux.dev,mhocko@kernel.org,hannes@cmpxchg.org,disclosure@aisle.com,stanislav.fort@aisle.com,akpm@linux-foundation.org
Subject: + mm-memcg-v1-account-event-registrations-and-drop-world-writable-cgroupevent_control.patch added to mm-new branch
Date: Fri, 05 Sep 2025 18:30:49 -0700 [thread overview]
Message-ID: <20250906013050.98A7FC4CEF1@smtp.kernel.org> (raw)
The patch titled
Subject: mm/memcg: v1: account event registrations and drop world-writable cgroup.event_control
has been added to the -mm mm-new branch. Its filename is
mm-memcg-v1-account-event-registrations-and-drop-world-writable-cgroupevent_control.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-memcg-v1-account-event-registrations-and-drop-world-writable-cgroupevent_control.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.
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 the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days
------------------------------------------------------
From: Stanislav Fort <stanislav.fort@aisle.com>
Subject: mm/memcg: v1: account event registrations and drop world-writable cgroup.event_control
Date: Fri, 5 Sep 2025 12:38:51 +0300
In cgroup v1, the legacy cgroup.event_control file is world-writable and
allows unprivileged users to register unbounded events and thresholds.
Each registration allocates kernel memory without capping or memcg
charging, which can be abused to exhaust kernel memory in affected
configurations.
Make the following minimal changes:
- Account allocations with __GFP_ACCOUNT in event and threshold registration.
- Remove CFTYPE_WORLD_WRITABLE from cgroup.event_control to make it
owner-writable.
This does not affect cgroup v2. Allocations are still subject to kmem
accounting being enabled, but this reduces unbounded global growth.
Link: https://lkml.kernel.org/r/20250905093851.80596-1-disclosure@aisle.com
Signed-off-by: Stanislav Fort <disclosure@aisle.com>
Acked-by: Roman Gushchin <roman.gushchin@linux.dev>
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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/memcontrol-v1.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- a/mm/memcontrol-v1.c~mm-memcg-v1-account-event-registrations-and-drop-world-writable-cgroupevent_control
+++ a/mm/memcontrol-v1.c
@@ -761,7 +761,7 @@ static int __mem_cgroup_usage_register_e
size = thresholds->primary ? thresholds->primary->size + 1 : 1;
/* Allocate memory for new array of thresholds */
- new = kmalloc(struct_size(new, entries, size), GFP_KERNEL);
+ new = kmalloc(struct_size(new, entries, size), GFP_KERNEL_ACCOUNT);
if (!new) {
ret = -ENOMEM;
goto unlock;
@@ -924,7 +924,7 @@ static int mem_cgroup_oom_register_event
{
struct mem_cgroup_eventfd_list *event;
- event = kmalloc(sizeof(*event), GFP_KERNEL);
+ event = kmalloc(sizeof(*event), GFP_KERNEL_ACCOUNT);
if (!event)
return -ENOMEM;
@@ -1087,7 +1087,7 @@ static ssize_t memcg_write_event_control
CLASS(fd, cfile)(cfd);
- event = kzalloc(sizeof(*event), GFP_KERNEL);
+ event = kzalloc(sizeof(*event), GFP_KERNEL_ACCOUNT);
if (!event)
return -ENOMEM;
@@ -2053,7 +2053,7 @@ struct cftype mem_cgroup_legacy_files[]
{
.name = "cgroup.event_control", /* XXX: for compat */
.write = memcg_write_event_control,
- .flags = CFTYPE_NO_PREFIX | CFTYPE_WORLD_WRITABLE,
+ .flags = CFTYPE_NO_PREFIX,
},
{
.name = "swappiness",
_
Patches currently in -mm which might be from stanislav.fort@aisle.com are
mm-damon-sysfs-fix-use-after-free-in-state_show.patch
mm-memcg-v1-account-event-registrations-and-drop-world-writable-cgroupevent_control.patch
reply other threads:[~2025-09-06 1:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250906013050.98A7FC4CEF1@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=disclosure@aisle.com \
--cc=hannes@cmpxchg.org \
--cc=mhocko@kernel.org \
--cc=mm-commits@vger.kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=stanislav.fort@aisle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.