]> git.ipfire.org Git - thirdparty/systemd.git/commit
oomd: Prevent corruption of cgroup paths in Killed signal
authorChris Down <chris@chrisdown.name>
Sat, 14 Feb 2026 16:05:12 +0000 (00:05 +0800)
committerMike Yuan <me@yhndnzj.com>
Sun, 15 Feb 2026 17:25:28 +0000 (18:25 +0100)
commita267656b07912ecb8e304f62646001b895b93c07
tree57ac94120058e0090ed6fe5871e097449ecc2f72
parent4e77671be723d31249e03b27ca9d83b6d17de693
oomd: Prevent corruption of cgroup paths in Killed signal

While looking at oomd behaviour in production I noticed that I always
get garbage cgroup paths for the Killed event. Looking more closely, I
noticed that while the signature is (string cgroup, string reason), we
currently erroneously pass the `OomdCGroupContext*` pointer itself as
the first argument to sd_bus_emit_signal(), rather than the ctx->path
string it contains.

The in-memory layout on affected machines in my case is:

    struct OomdCGroupContext {
        unsigned n_ref;
        /* padding */
        char *path;
        /* ... */
    }

...which explains the control characters, since they're garbage from
parsing n_ref, the path pointer, and later fields. At runtime, sd-bus
treats ctx as `const char *` and reads struct bytes as string data,
resulting in garbage being sent.

Pass ctx->path correctly so listeners receive the valid cgroup path.
src/oom/oomd-util.c