From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796248723; b=4+xjMlJwT0lQPjHXTOuvLMzJWNSusYAh5vqfSWNREXEVYLnQcxCicbkeFMmxyZvYX/Ot dzYvJ6t/CMIPBP9nATgnbvR8ebu7/N++BZmvuaG7NqGvn4JMmfyhC478/pVU1r8ukIBNi 4XtbBul6geZVIuPQXyu+UmVtA6kSazA4jYaATH7TiEr/d07nhCoizR+E8JkFRhAN5+cZE zfuoId8me+AT8imulFim55F9YvWTdaaSRrl9BdalnV6IVj9Z1UaRb7Dp2Y4YCbZCrW31C BQiAr9h5M0UUg0Sgbps3usi6wSKHY0cca+RbR4ovcEKRIO0R7srbbCOWiCP3MPsKXVw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796248723; h=Received:DKIM-Signature:Content-Type:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=S09kykJdmDFLFJuS3jacApJ+XGnZrmO2Pq3rdmQXxCM=; b=rNSnU+pxUKllHtN7a7P6G/Ft12hhHb4P/IqGqb9QC/nOIF1MJzKQUTWNmmPpafVBy/q8 zQ2Br/rJnKMyUCjL3fhCyby9MvMnG8vaPPUrSClSOmsWveCTiUmgCHCDz1CvCrC7DJhGm 6t3O6pYqShwOMCtf4wbdJwZba5aVvgZdMikURXNF0o0XIMzLlKTKH2+/9a/bOLLpMk7JU tD9qO9XEQne7PB+0UItx3TmYsxLpPFWK0zVCiARJrd0Vu/GOGZw0gLr1FcF+NUDW/4wZr LXLdLCbExTPiorPL37KBw6fTjPDQSB4tN8pzzFDnmF/If9tiaklDvf3VeSrhBZGuQCw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Lot7ZidF; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FE00606A322; Wed, 2 Dec 2026 21:58:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Lot7ZidF Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BCA81F00924; Wed, 2 Dec 2026 21:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796248723; bh=S09kykJdmDFLFJuS3jacApJ+XGnZrmO2Pq3rdmQXxCM=; h=In-Reply-To:References:Subject:From:To:Cc:Date; b=Lot7ZidFwvwhMkJdlRwdjWdVkkUapiggbpHCBig2KRMQ33frgHOEdcy2zxND2diDC c1bD+WkUZFQeNfmPCtaEUVLYKOMI+Mnk+cKwsGqKM85hbjxr2eOh/KitZgyrO6EF1f 85bZU7OH7D353BVnhiB343YscizdGFBT+FGJjaTGD+tT7v0O5GHx0TfuA6nVmbMDRO n8rvBn9hWNEySPxFUAyf0Qa3L4auG3sRpuQWs1nK/So31U3eOVm/wulQZTe8q3O0y9 OnTQHy8gzgZCGEcOXXeemIvHzRgmm7O9OQD15sVoYdPPT4fjKH7jMzsoDfl4SeuyxK LWt3sDd/DfkKw== Content-Type: multipart/mixed; boundary="===============9107379043587650691==" X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Message-Id: In-Reply-To: <20261202210415.517651-16-bgardon@google.com> References: <20261202210415.517651-16-bgardon@google.com> Subject: Re: [PATCH bpf-next v4 15/17] mm, bpf: introduce bpf_mem_cgroup_raise_max() kfunc From: bot+bpf-ci@kernel.org To: bgardon@google.com,ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,akpm@linux-foundation.org,hannes@cmpxchg.org,mhocko@kernel.org,shakeel.butt@linux.dev,roman.gushchin@linux.dev,tj@kernel.org Cc: jp.kobryn@linux.dev,eddyz87@gmail.com,memxor@gmail.com,martin.lau@linux.dev,song@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org,emil@etsalapatis.com,ihor.solodrai@linux.dev,rientjes@google.com,surenb@google.com,joshdon@google.com,sweettea-kernel@dorminy.me,zhouchuyi@bytedance.com,laoar.shao@gmail.com,benbwgardon@gmail.com,bpf@vger.kernel.org,linux-mm@kvack.org,cgroups@vger.kernel.org,linux-kernel@vger.kernel.org,bgardon@google.com,muchun.song@linux.dev,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev Date: Wed, 2 Dec 2026 21:58:39 +0000 (UTC) --===============9107379043587650691== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit > 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 --===============9107379043587650691==--