Blame SOURCES/0317-sysctl-let-s-by-default-increase-the-numeric-PID-ran.patch

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