]> git.ipfire.org Git - thirdparty/dbus.git/commit
spawn-unix: On Linux, don't try to increase OOM-killer protection
authorSimon McVittie <smcv@collabora.com>
Mon, 21 Feb 2022 15:53:38 +0000 (15:53 +0000)
committerSimon McVittie <smcv@collabora.com>
Fri, 25 Feb 2022 14:57:18 +0000 (14:57 +0000)
commit4ed9f00a7cbff498f74b7c5f4861280a50497c20
treeb4d12f05c5b5b21b066a012aa3681a74620c5418
parent7200555694ed614cc91ddbc5dd17805f7d6d4111
spawn-unix: On Linux, don't try to increase OOM-killer protection

The oom_score_adj parameter is a signed integer, with increasingly
positive values being more likely to be killed by the OOM-killer,
and increasingly negative values being less likely.

Previously, we assumed that oom_score_adj would be negative or zero,
and reset it to zero, which does not require privileges because it
meant we're voluntarily giving up our OOM-killer protection.
In particular, bus/dbus.service.in has OOMScoreAdjust=-900, which
we don't want system services to inherit.

However, systemd >= 250 has started putting a positive oom_score_adj
on user processes, to make it more likely that the OOM killer will kill
a user process rather than a system process. Changing from a positive
oom_score_adj to zero is increasing protection from the OOM-killer,
which only a privileged process is allowed to do, resulting in warnings
whenever we carry out traditional (non-systemd) service activation
on the session bus.

To avoid this, do the equivalent of:

    if (oom_score_adj < 0)
        oom_score_adj = 0;

which is always allowed.

Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/374
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit c42bb64457c3b31e561ad9885c618e051af1171a)
dbus/dbus-sysdeps-util-unix.c