]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm/memcg: v1: account event registrations and drop world-writable cgroup.event_control
authorStanislav Fort <stanislav.fort@aisle.com>
Fri, 5 Sep 2025 09:38:51 +0000 (12:38 +0300)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 12 Sep 2025 00:25:56 +0000 (17:25 -0700)
commitabfea90e04a07d245ca7e8c95a2ec45d9860eacc
treed5256852892d17f281428b7ef728daf54fc687e3
parentf6ddf0edfc4c02f2f9a7b58d880b07d84e198513
mm/memcg: v1: account event registrations and drop world-writable cgroup.event_control

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