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=1796248734; b=nDHzl97pxb2qxVgcDMoqIYZP++UWeUSgsicLitkmb3SfXXo5kLIadb5r1P+wSfrMWmIj 6744JCvF2orAHaqlCpNmV/e7ap40pWCMBbk6k0b1nkdnzgvBAEBsBO2CN2vEnsSoT8FH+ 6tw0WQJZLjzB5DiH6Xjq/lcUypRZZWYFIg2yNNOAe8CYQSq0IxUlWzY4eHd+X4Ynm9vFn ZZafK/ttZaXNNHdKcq3lst21ZG0UCCBBWK5Q40Tjj8tcdcJLH3ZWXhYP7DGr7HuNDfhwl kLPEKWxBq7VsNHUa8nn3ni1t3HSgCf8yYjfoSLDLBcT2n9AunkTbq5kve9xq6AeUzJA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796248734; h=Received:DKIM-Signature:Content-Type:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=g6ILhcmnUeywaqBNkDuVlI1uiKJkIdI9PgoYmHj2XFk=; b=INlAcFAp/y9drNigYzV5lh4e9uqxIzmiItxXS4odWvSiDhi1AsQeJ1mz6CiWIoVVyxgo Q+UwFKhDNhcbT+uk6t4dt2xtP8Jfd5UX3R/WlpToa4c/cKv+ad96tahj6ASMo9GiZoyUn Q2pzDC+mgOyFvyHThtoh3XwLjQtUThC8oreRCPvIX3Q4lhLejSpglRXTm9G9gBA2kmO7O ca52qWqXYUIKOe8NVZbCPW/YZ4p+zynFLZuRjnaqEDc3L0SZH/dgzUVP016Ud7uxDxz+2 w3PZT0fZVVGjm2soq0JzyKDyr9Rxn/p/4bh3ZAn6bAUnRRvHMHXa0s/ml/GSAZloiVQ== 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=IitHUOSs; 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 7DAD0606A68F; Wed, 2 Dec 2026 21:58:54 +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=IitHUOSs Received: by smtp.kernel.org (Postfix) with ESMTPSA id D251A1F00899; Wed, 2 Dec 2026 21:58:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796248734; bh=g6ILhcmnUeywaqBNkDuVlI1uiKJkIdI9PgoYmHj2XFk=; h=In-Reply-To:References:Subject:From:To:Cc:Date; b=IitHUOSsyhzICvpZGj5U6sBLN9mW7z5aVn24ekE2g0PEPSQ/LoqnXsqTf+AZhpZ8A K+rHVZjaoeaxy5K68692CCh6z4CFiczJGBxMciaVkk5rswsEtZBi+fSCv+GLAHEkqt UNlWvkKezIlUzcvVkImNXrexR345425BD8tPBUZ7774Uu9xnybbmtFzpQEVGpF2hvj L0uIJ5TZ+Sff3ki9+UNjT+D28aVy3PTYCfb1fZGYEqBKyUsjX0vBtWP7Vtg9d4WNSl vS3HnjQFE/Xs7qHxj03X94tdmnzmQVEC7YoDX7il9TJXznT7d/VQcVTW9YHx/gC/DZ lTQnTkjpNAFcQ== Content-Type: multipart/mixed; boundary="===============6612693469847642308==" 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: <9e09910d27a7b276fe3b1120e52d1b4b2960a6a512caed5d73db2f18be43c32a@mail.kernel.org> In-Reply-To: <20261202210415.517651-13-bgardon@google.com> References: <20261202210415.517651-13-bgardon@google.com> Subject: Re: [PATCH bpf-next v4 12/17] mm, bpf: introduce bpf_oom_proactive_kill() for proactive OOM prevention 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,mhocko@suse.com,brauner@kernel.org,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:50 +0000 (UTC) --===============6612693469847642308== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit > mm, bpf: introduce bpf_oom_proactive_kill() for proactive OOM prevention TL;DR: - bpf_oom_proactive_kill() may let a CAP_BPF-only syscall program SIGKILL any task; KF_PERFMON or capable() check missing? - Changelog claims direct PSI tracepoint use, but the sleepable kfunc likely can't be called there > bpf_out_of_memory() invokes out_of_memory(), which falls back to > select_bad_process() if no attached bpf_oom_ops policy handles the event. > It cannot directly terminate a specific task chosen by a proactive > userspace/BPF policy. > > Existing userspace options (pidfd_send_signal(SIGKILL) + process_mrelease() > or cgroup.kill) cannot atomically honor memory.oom.group expansion from > a chosen task, do not record memory.events oom_kill / oom_group_kill > counters or unified kernel OOM logging, and cannot be invoked directly > from a PSI tracepoint callback. The changelog lists "cannot be invoked directly from a PSI tracepoint callback" as a limitation of the userspace options, which implies the new kfunc can be called directly from such a callback. Is that accurate? bpf_oom_proactive_kill() is registered KF_SLEEPABLE, and psi_avgs_work_tp is declared with DECLARE_TRACE(psi_avgs_work, ...), which is not a faultable tracepoint. A sleepable tp_btf/psi_avgs_work_tp program is refused, and the verifier rejects a KF_SLEEPABLE call in a non-sleepable context. The earlier patch in this series says the OOM kfuncs are reached from tracepoint programs "asynchronously via a sleepable callback (such as bpf_task_work or bpf_wq)", and Documentation/bpf/bpf_oom.rst says the same. Could the changelog say that the kill is reached from a PSI tracepoint program through a bpf_wq/bpf_task_work callback instead of "directly"? > diff --git a/mm/oom_kill.c b/mm/oom_kill.c > --- a/mm/oom_kill.c > +++ b/mm/oom_kill.c [ ... ] > @@ -1413,6 +1483,7 @@ static const struct btf_kfunc_id_set bpf_oom_kfunc_set = { > > BTF_KFUNCS_START(bpf_declare_oom_kfuncs) > BTF_ID_FLAGS(func, bpf_out_of_memory, KF_SLEEPABLE) > +BTF_ID_FLAGS(func, bpf_oom_proactive_kill, KF_SLEEPABLE) > BTF_KFUNCS_END(bpf_declare_oom_kfuncs) Should this kfunc be registered with KF_PERFMON (or have an explicit capable() check), like bpf_send_signal_task()? bpf_declare_oom_syscall_kfunc_set has no .filter, and a BPF_PROG_TYPE_SYSCALL program needs only CAP_BPF to load. With that, a program can do: task = bpf_task_from_pid(pid); bpf_oom_proactive_kill(NULL, task, "x", 0); The call chain is: bpf_oom_proactive_kill() bpf_oom_kill_process() oom_kill_process() __oom_kill_process() do_send_sig_info(SIGKILL, SEND_SIG_PRIV, victim, PIDTYPE_TGID) This can SIGKILL any task that is not init, a kthread or oom_score_adj -1000, including tasks of other users. With a NULL origin, mem_cgroup_get_oom_group() uses root as the domain, so the highest ancestor cgroup with memory.oom.group set is killed as well. bpf_send_signal_task() in the same generic set is registered with KF_PERFMON, and bpf_oom_kill_process() was previously reachable only from bpf_oom_ops struct_ops programs, which need CAP_PERFMON. This wrapper reaches the same kill path with less privilege and without the kill(2) permission checks. Neither the changelog nor the kfunc documentation discusses who may call it. --- 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 --===============6612693469847642308==--