naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
5d2ee9
From b9be2c6b48227642ba85c5a741f121cc99655904 Mon Sep 17 00:00:00 2001
5d2ee9
From: =?UTF-8?q?Michal=20Sekleta=CC=81r?= <msekleta@redhat.com>
5d2ee9
Date: Mon, 6 Jan 2020 12:30:58 +0100
5d2ee9
Subject: [PATCH] sysctl: let's by default increase the numeric PID range from
5d2ee9
 2^16 to 2^22
5d2ee9
5d2ee9
This should PID collisions a tiny bit less likely, and thus improve
5d2ee9
security and robustness.
5d2ee9
5d2ee9
2^22 isn't particularly a lot either, but it's the current kernel
5d2ee9
limitation.
5d2ee9
5d2ee9
Bumping this limit was suggested by Linus himself:
5d2ee9
5d2ee9
https://lwn.net/ml/linux-kernel/CAHk-=wiZ40LVjnXSi9iHLE_-ZBsWFGCgdmNiYZUXn1-V5YBg2g@mail.gmail.com/
5d2ee9
5d2ee9
Let's experiment with this in systemd upstream first. Downstreams and
5d2ee9
users can after all still comment this easily.
5d2ee9
5d2ee9
Besides compat concern the most often heard issue with such high PIDs is
5d2ee9
usability, since they are potentially hard to type. I am not entirely sure though
5d2ee9
whether 4194304 (as largest new PID) is that much worse to type or to
5d2ee9
copy than 65563.
5d2ee9
5d2ee9
This should also simplify management of per system tasks limits as by
5d2ee9
this move the sysctl /proc/sys/kernel/threads-max becomes the primary
5d2ee9
knob to control how many processes to have in parallel.
5d2ee9
5d2ee9
Resolves: #1744214
5d2ee9
---
5d2ee9
 sysctl.d/50-pid-max.conf | 17 +++++++++++++++++
5d2ee9
 sysctl.d/meson.build     |  1 +
5d2ee9
 2 files changed, 18 insertions(+)
5d2ee9
 create mode 100644 sysctl.d/50-pid-max.conf
5d2ee9
5d2ee9
diff --git a/sysctl.d/50-pid-max.conf b/sysctl.d/50-pid-max.conf
5d2ee9
new file mode 100644
5d2ee9
index 0000000000..3a8393d185
5d2ee9
--- /dev/null
5d2ee9
+++ b/sysctl.d/50-pid-max.conf
5d2ee9
@@ -0,0 +1,17 @@
5d2ee9
+#  This file is part of systemd.
5d2ee9
+#
5d2ee9
+#  systemd is free software; you can redistribute it and/or modify it
5d2ee9
+#  under the terms of the GNU Lesser General Public License as published by
5d2ee9
+#  the Free Software Foundation; either version 2.1 of the License, or
5d2ee9
+#  (at your option) any later version.
5d2ee9
+
5d2ee9
+# See sysctl.d(5) and core(5) for documentation.
5d2ee9
+
5d2ee9
+# To override settings in this file, create a local file in /etc
5d2ee9
+# (e.g. /etc/sysctl.d/90-override.conf), and put any assignments
5d2ee9
+# there.
5d2ee9
+
5d2ee9
+# Bump the numeric PID range to its maximum of 2^22 (from the in-kernel default
5d2ee9
+# of 2^16), to make PID collisions less likely.
5d2ee9
+kernel.pid_max = 4194304
5d2ee9
+
5d2ee9
diff --git a/sysctl.d/meson.build b/sysctl.d/meson.build
5d2ee9
index 64f6ce942e..a95957ad7d 100644
5d2ee9
--- a/sysctl.d/meson.build
5d2ee9
+++ b/sysctl.d/meson.build
5d2ee9
@@ -2,6 +2,7 @@
5d2ee9
 
5d2ee9
 install_data(
5d2ee9
         '50-default.conf',
5d2ee9
+        '50-pid-max.conf',
5d2ee9
         install_dir : sysctldir)
5d2ee9
 
5d2ee9
 in_files = []