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=1796248739; b=CVR/8UzAhijHPuwXIdhSMf2749LFev7MP/su5ez3JrKEUzGPTeJYrnQO16VEFKO/sueo ZJvRrJLXDBjjWjAiUsfA2rLa+yz8z8quPlrNs4DIL/Qe1QYvw6QZJRWUzRbN/uLQX0UxC pfhZ3dsp5yrTEwxpo8sGjwwa6nI2V7s5BJcDd3Kg4CW3rcGooBQ4AyZU2MmTNR9fPSmVe 2qS3xyhJns5R57qirNSNSAHKbreWfd3OrRevxBzBA/yyY7We6L4S2y81kK2Gp0mDMHfgy Bdl5QNqKcE3uoM8B5bVNhcjtwb4J5Sz3QgKywB9TYPn+TDdZkBfPb97Z6fNeSiGOrRg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796248739; h=Received:DKIM-Signature:Content-Type:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=h+0IhSfrxFADo4CpptUmbRst2l8dDfkzSvD/U28sZ6U=; b=KB8b9lzjAhKT4QD3Ho9354tSWYXWlXoXa5nh7Tn1CZNbYay79zZ4dVWf1onRx4MMacJ0 3WFHgRXoDqWNlPTaZ1SJobmsdv/X8879oOrzefn9CcDLNtu8xUzFHuEilA6F9aQferpcT 1/utQyj23DLp4KqQMEg/CHPmZYlQPVO99MWp3oHSSP3Lnu9gyzKcrWVGQNjSJNRYUgMuA Mb8UhW10NHNE4Y0GS3r5Y7Bs8R3vWqvXBYH0Um7z1U/sd1jY6YGqcmR2cCLMp9XHS1y6O TFiZYzpwp3TAn5FxkTXqumEn7+wpxW/4vo1rxqUxgLQJBjQ1LyY7fIAxAYj36p4Jtng== 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=kiUmMKv8; 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 AD8A7606A33E; Wed, 2 Dec 2026 21:58:59 +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=kiUmMKv8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 490001F000C1; Wed, 2 Dec 2026 21:58:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796248739; bh=h+0IhSfrxFADo4CpptUmbRst2l8dDfkzSvD/U28sZ6U=; h=In-Reply-To:References:Subject:From:To:Cc:Date; b=kiUmMKv8hYJSoTk0KWyvnfR88ykUrm/OoPkH6OsW5UmyWLURzvpdpTx1vyMV2vM3T 3fkN1wkpOKAI249z/0OqThyV2y15qzdxOdxzDXKBkZ64Hkgcm5ZhE6o66tXTAMe0se 7bZkJUt/rPD9vZ+427YCkl9+IP6Q44rH/4hKYN1t3EKSWmR8pK9ahzIsSsje2ZVkTo rA4WTtVS1hlk6H2kpIx7WRRVVqu1Q1MmYKaiVrHpDDzcdDOYKOSEzBX6IZPC2CZX17 OQTCelJH/yiwQ0RPE1Vjkz1jiDY0WWPwR4k2sF4qGgfUAhPkvPU8G+DC8kGNqJY46T eFZd4/AD1m9qg== Content-Type: multipart/mixed; boundary="===============0501742986785720925==" 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: <20affc97bc9fd53eb70536943780fc009072d6d3b5bafc0c33f0ae913cf2f070@mail.kernel.org> In-Reply-To: <20261202210415.517651-4-bgardon@google.com> References: <20261202210415.517651-4-bgardon@google.com> Subject: Re: [PATCH bpf-next v4 03/17] mm, bpf: introduce bpf_oom_kill_process() BPF 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:56 +0000 (UTC) --===============0501742986785720925== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit > mm, bpf: introduce bpf_oom_kill_process() BPF kfunc TL;DR: bpf_oom_kill_process() may kill an OOM_SCORE_ADJ_MIN-protected vfork parent, because it doesn't reject in_vfork() tasks like oom_badness() does. The kill could also free no memory. > diff --git a/mm/oom_kill.c b/mm/oom_kill.c > --- a/mm/oom_kill.c > +++ b/mm/oom_kill.c [ ... ] > +__bpf_kfunc int bpf_oom_kill_process(struct oom_control *oc, > + struct task_struct *task, > + const char *message__str) > +{ > + struct task_struct *p; > + > + if (oom_unkillable_task(task)) > + return -EPERM; > + > + if (oc->memcg && !mem_cgroup_task_in_hierarchy(task, oc->memcg)) > + return -EINVAL; > + > + p = find_lock_task_mm(task); > + if (!p) > + return -ESRCH; > + > + if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) { > + task_unlock(p); > + return -EINVAL; > + } > + > + if (mm_flags_test(MMF_OOM_SKIP, p->mm)) { > + task_unlock(p); > + return -ESRCH; > + } > + > + /* paired with put_task_struct() in oom_kill_process() */ > + get_task_struct(p); > + task_unlock(p); > + > + oc->chosen = p; > + oom_kill_process(oc, message__str); Can this kill a task that is protected with OOM_SCORE_ADJ_MIN? The checks here mirror the exclusions in oom_badness(), but in_vfork() is not among them: adj = (long)p->signal->oom_score_adj; if (adj == OOM_SCORE_ADJ_MIN || mm_flags_test(MMF_OOM_SKIP, p->mm) || in_vfork(p)) { __set_oom_adj() skips vfork children, so a vfork child can hold a different oom_score_adj than the parent it shares an mm with. For example: P has oom_score_adj = OOM_SCORE_ADJ_MIN and calls vfork() child C raises its own oom_score_adj to 0 before exec the bpf_oom_ops handler picks C (it reports the full RSS of P's mm) bpf_oom_kill_process(oc, C, ...) passes every check above oom_kill_process() then reaches __oom_kill_process(), which sends SIGKILL to every process sharing the victim's mm without checking oom_score_adj: for_each_process(p) { if (!process_shares_mm(p, mm)) continue; ... do_send_sig_info(SIGKILL, SEND_SIG_PRIV, p, PIDTYPE_TGID); } So P is killed as well, which contradicts the commit message statement that tasks protected with OOM_SCORE_ADJ_MIN "are rejected in the kernel". Killing C also frees no memory, since P still pins the mm. If init is the vfork parent, __oom_kill_process() sets MMF_OOM_SKIP on init's mm and skips the reaper, so the kill makes no progress. Should the kfunc also reject in_vfork(p) while holding task_lock(p), as oom_badness() does? bpf_oom_kill_process() is unchanged at the end of the series, so this is not fixed by a later patch. > + oc->chosen = NULL; > + > + return 0; > +} [ ... ] --- 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 --===============0501742986785720925==--