> selftests/bpf: Add negative and verifier tests for BPF OOM kfuncs TL;DR: Test issue: the global proactive-kill selftest may SIGKILL unrelated host tasks or whole cgroups (test_progs included) outside the root pid namespace or with memory.oom.group set; the worker also isn't put in a test cgroup. > diff --git a/tools/testing/selftests/bpf/prog_tests/test_oom_kfunc_neg.c b/tools/testing/selftests/bpf/prog_tests/test_oom_kfunc_neg.c > new file mode 100644 > --- /dev/null > +++ b/tools/testing/selftests/bpf/prog_tests/test_oom_kfunc_neg.c [ ... ] > +void serial_test_oom_kfunc_neg(void) > +{ [ ... ] > + memory_holder_init(&worker); [ ... ] > + /* Global proactive kill (origin__nullable == NULL) must succeed */ > + args.cgroup_id = 0; > + args.pid = worker.pid; > + args.flags = 0; > + args.wait_on_oom_lock = 1; > + if (!ASSERT_OK(bpf_prog_test_run_opts(prog_fd, &topts), "run_global") || > + !ASSERT_OK((int)topts.retval, "global_retval")) > + goto cleanup; > + > + ASSERT_EQ(waitpid(worker.pid, &status, 0), worker.pid, "waitpid_global"); Can this global kill hit processes other than the worker? With origin == NULL, bpf_oom_proactive_kill() skips the mem_cgroup_task_in_hierarchy() check, so only the pid lookup and the bpf_oom_kill_process() checks guard the victim. proactive_kill_prog() resolves the victim with bpf_task_from_pid(), which uses find_task_by_pid_ns(pid, &init_pid_ns). worker.pid is the value fork() returned in test_progs' own pid namespace. If test_progs runs in a non-root pid namespace, such as a privileged container, whichever host task has that pid number gets SIGKILL and the call returns 0. The real worker is never signalled, so waitpid(worker.pid, ...) blocks until the watchdog fires. The worker is also never moved into a test cgroup, unlike test_oom.c, test_oomd.c, test_psi.c and test_oom_proactive_kill.c, which call setup_cgroup_environment(). It stays in test_progs' memory cgroup. With oc->memcg == NULL, oom_kill_process() calls mem_cgroup_get_oom_group(victim, NULL), which walks up to the root: for (; memcg; memcg = parent_mem_cgroup(memcg)) { if (READ_ONCE(memcg->oom_group)) oom_group = memcg; if (memcg == oom_domain) break; } and then mem_cgroup_scan_tasks(oom_group, oom_kill_memcg_member, ...) sends SIGKILL to every task in that group. If any non-root ancestor of test_progs' cgroup has memory.oom.group=1, for example a systemd unit with OOMPolicy=kill, would this kill test_progs and every other process in that cgroup? In the usual vmtest setup (root cgroup, root pid namespace) neither case occurs. Would it make sense to place the worker in a cgroup created with setup_cgroup_environment()/create_and_get_cgroup() as the sibling test does, and either skip the global case when not in the root pid namespace, or have the BPF program check that the task it found is the caller's child (or use bpf_task_from_vpid())? --- 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