From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: Aaron Tomlin <atomlin@atomlin.com>
Cc: david@kernel.org, corbet@lwn.net, akpm@linux-foundation.org,
liam@infradead.org, vbabka@kernel.org, rppt@kernel.org,
surenb@google.com, mhocko@suse.com, skhan@linuxfoundation.org,
rdunlap@infradead.org, rientjes@google.com,
shakeel.butt@linux.dev, sean@ashe.io, neelx@suse.com,
linux-mm@kvack.org, linux-doc@vger.kernel.org
Subject: Re: [RFC PATCH] mm/oom_kill: optionally log victim command-line arguments on OOM kill
Date: Wed, 25 Nov 2026 15:33:28 +0000 [thread overview]
Message-ID: <awb6I0qAySbhBIsW@gremlin> (raw)
In-Reply-To: <20261124205043.1010247-1-atomlin@atomlin.com>
Nackity nackity NACK NACK NACK!
This is terribly, horribly broken both in concept and implementation.
On Tue, Nov 24, 2026 at 03:50:43PM -0500, Aaron Tomlin wrote:
> When the OOM killer terminates a task in __oom_kill_process(), the
> kernel log records only victim->comm alongside its PID and memory
> counters. Because comm[] is truncated to TASK_COMM_LEN and typically
> reflects the interpreter binary rather than the executed programme or
> script (e.g. "python3" instead of /usr/bin/python3 -sP
> /usr/bin/firewalld --nofork --nopid), identifying which service or
> worker instance was killed during post-mortem analysis is often
> difficult once the process has exited and /proc/[pid]/cmdline is gone.
>
> The standard get_cmdline() helper cannot be called from
> __oom_kill_process(). OOM kill paths run whilst holding oom_lock, so
> blocking on mmap_read_lock_killable() risks deadlocking against a
> thread holding mmap_write_lock() whilst waiting for memory allocation
> on oom_lock. Furthermore, get_cmdline() walks user pages via
> access_process_vm(), which triggers page faults, memory allocations,
> and swap-in I/O during an active OOM condition, and drops an mm_users
> reference via mmput() that could run synchronous exit_mmap() teardown
> under oom_lock.
Also, fiddling with the memory of a soon-to-die process under extreme
memory pressure is insane, additionally _holding that lock_ under memory
pressure is insane.
>
> Introduce an opt-in vm.oom_dump_cmdline sysctl (documented in
> Documentation/admin-guide/sysctl/vm.rst), disabled by default to
'Have mm people support my code literally forever'... and make it an ABI
requirement too!
> preserve existing behaviour and avoid exposing potentially sensitive
> command-line arguments unless explicitly requested by the
> administrator. When enabled on CONFIG_MMU builds, __oom_kill_process()
> attempts a best-effort, non-blocking read of the victim's resident
> argument vector (including setproctitle(3) updates inspected via
> arg_end - 1) after releasing task_lock(victim). It snapshots the
> argument and environment bounds under mm->arg_lock, acquires mmap_lock
> via mmap_read_trylock(), bails out if MMF_OOM_SKIP or MMF_UNSTABLE is
> set, and walks only present, non-PageHWPoison() anonymous page table
> entries via folio_walk_start() without faulting or allocating memory.
> After dropping the page table lock, each pinned subpage is flushed via
> flush_anon_page() and copied across kmap_local_page() and
> copy_from_user_page(), and mmap_lock is released prior to calling
> printk.
Ah the giant slabs of impenetrable text that reviewers are supposed to read in
detail now... LLMs really have a lot to answer for.
You (or far more likely your LLM) is just describing the (horribly broken)
code in English here.
I hate how often I have to read this stuff...
>
> To preserve backwards compatibility with monitoring tools that parse
> the existing "Killed process %d (%s) ..." message, leave that line
> untouched and emit a separate rate-limited companion line sanitised
> with %*pE when resident argument bytes are recovered. For example:
>
> [ 124.819203] Out of memory: Killed process 1482 (python3) total-vm:184320kB, anon-rss:42100kB, ...
> [ 124.819215] Out of memory: Process 1482 (python3) cmdline: /usr/bin/python3 -sP /usr/bin/firewalld --nofork --nopid
>
Doubling the output in a way that is super confusing, great! :)
> Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
This patch is broken in a million different ways.
The process gets sent SIGKILL and _then_ you race it to take the mmap read
lock, which prevents the reaper from running?
You do a lock inversion between oom_lock and the mmap_lock, and hope it'll
be OK?
You take a heavy rwsem lock while the system is under extreme memory
pressure? Which, again, prevents the reaper getting to it?
You do heavy operations during one of the most sensitive, dangerous times
for a kernel for a nice-to-have annotation?
And dump_oom_victim() already outputs memcg information, which systemd
uses, your example mentions firewalld so likely that'd _already_ give you
the kind of information you are interested in (except for mutliple
workers).
You're adding a ton of totally broken complexity then, insanely, making it
a global sysctl flag that we have to support forever as an ABI too.
You intentionally abuse folio_walk_start() to do _what its kdoc tells you
not to_:
* This function must *not* be used as a naive replacement for
* get_user_pages() / pin_user_pages(), especially not to perform DMA or
* to carelessly modify page content. This function may *only* be used to grab
* short-term folio references, never to grab long-term folio references.
You're (or more likely your LLM) is literally copy/pasting code from
__access_remote_vm() combined with this mad abuse of folio_walk_*() as a
proto-GUP to... get more info about a killed process.
You also copy/pasted wrong so this is even more subtly broken.
You are also potentially exposing sensitive information. Your ratelimiting
is broken.
Oh and of course, you add 256 bytes to the VERY limited kernel stack at the
point of an OOMK.
I mean I could go on. Even the concept here is fundamentally broken, so
please don't waste our time with respins.
Thanks.
> ---
> Documentation/admin-guide/sysctl/vm.rst | 30 ++++
> mm/oom_kill.c | 206 ++++++++++++++++++++++++
> 2 files changed, 236 insertions(+)
Of course it's also a massive patch...
--
Cheers, Lorenzo
next prev parent reply other threads:[~2026-11-25 15:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 20:50 [RFC PATCH] mm/oom_kill: optionally log victim command-line arguments on OOM kill Aaron Tomlin
2026-11-25 15:33 ` Lorenzo Stoakes (ARM) [this message]
2026-11-25 16:20 ` Aaron Tomlin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=awb6I0qAySbhBIsW@gremlin \
--to=ljs@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=atomlin@atomlin.com \
--cc=corbet@lwn.net \
--cc=david@kernel.org \
--cc=liam@infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=neelx@suse.com \
--cc=rdunlap@infradead.org \
--cc=rientjes@google.com \
--cc=rppt@kernel.org \
--cc=sean@ashe.io \
--cc=shakeel.butt@linux.dev \
--cc=skhan@linuxfoundation.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox