Re: [PATCH bpf-next v4 15/17] mm, bpf: introduce bpf_mem_cgroup_raise_max() kfunc

From: bot+bpf-ci

Date: Wed Dec 02 2026 - 16:58:58 EST


> mm, bpf: introduce bpf_mem_cgroup_raise_max() kfunc

TL;DR: bpf_mem_cgroup_raise_max() looks registered for all program types, so
any sleepable BPF program may be able to raise memory.max on any non-root
memcg, bypassing cgroupfs permission checks; restricting it like the OOM
kfuncs is suggested.

> diff --git a/mm/bpf_memcontrol.c b/mm/bpf_memcontrol.c
> --- a/mm/bpf_memcontrol.c
> +++ b/mm/bpf_memcontrol.c

[ ... ]

> @@ -218,6 +241,7 @@ BTF_ID_FLAGS(func, bpf_mem_cgroup_memory_events)
> BTF_ID_FLAGS(func, bpf_mem_cgroup_usage)
> BTF_ID_FLAGS(func, bpf_mem_cgroup_page_state)
> BTF_ID_FLAGS(func, bpf_mem_cgroup_flush_stats, KF_SLEEPABLE)
> +BTF_ID_FLAGS(func, bpf_mem_cgroup_raise_max, KF_SLEEPABLE)
>
> BTF_KFUNCS_END(bpf_memcontrol_kfuncs)

This kfunc is added to bpf_memcontrol_kfuncs, which bpf_memcontrol_init()
registers with register_btf_kfunc_id_set(BPF_PROG_TYPE_UNSPEC, ...) and no
.filter. bpf_prog_type_to_kfunc_hook() maps BPF_PROG_TYPE_UNSPEC to
BTF_KFUNC_HOOK_COMMON, and btf_kfunc_is_allowed() checks the COMMON hook
for every program type.

Can this let any sleepable program of any type (sleepable LSM,
fentry/fmod_ret, uprobe, iterators, other struct_ops) raise memory.max on
any non-root memcg? The commit message only names bpf_oom_ops handlers and
proactive SYSCALL/PSI programs. A program only needs bpf_cgroup_from_id()
or bpf_get_mem_cgroup() plus this kfunc, and it bypasses the cgroupfs
ownership and delegation checks that apply to writes to memory.max.

The other state-changing kfuncs in this series are restricted.
bpf_proactive_reclaim() is in a separate set registered only for
BPF_PROG_TYPE_SYSCALL, bpf_oom_kill_process() is limited to bpf_oom_ops by
bpf_oom_kfunc_filter(), and bpf_out_of_memory() and bpf_oom_proactive_kill()
are registered for SYSCALL plus a tracing set restricted by
bpf_declare_oom_tracing_filter(). Neither later commit in the series
(the bpf_mem_cgroup_raise_max() selftest or the BPF OOM documentation)
narrows the registration.

Should bpf_mem_cgroup_raise_max() go in its own set, registered for
BPF_PROG_TYPE_SYSCALL and BPF_PROG_TYPE_STRUCT_OPS with a filter limited to
bpf_oom_ops, the way the OOM kfuncs are? If the wider exposure is
intended, should the commit message say so?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46974333971