It's time to increase the default pid_max from 32768 to avoid PID wraparounds/collossions
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
procps (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
The kernel.pid_max sysctl defaults to 32768. This is a very historic limit to provide compatibility with ancient binaries.
Moving on to the year 2020 multicore CPU:s for desktops, laptops and servers is the standard, and together with PID randomization wraparound happens rather quickly on many-core machines with lots of activity. Wraparounds in itself is not a big issue, but there are corner cases like scripts that checks if a PID is alive etc that run into trouble if another process has started using the PID it expects, scripts (erroneously) using PIDs for work/temporary files, etc.
To avoid problems within the lifetime of Ubuntu Focal, it's time to increase kernel.pid_max by default in the distribution by including tuning in a file in /etc/sysctl.d/
Our suggestion is to ship the following tuning by default:
# Make PID-rollover not happen as often.
# Default is 32768
kernel.pid_max = 999999
with the following motivation:
1) It achieves a 30-fold increase in the available number-space, reducing the likelihood of PID wraparound/
2) It only adds one digit to the PID, so it's still possible to remember a PID
3) Output in top, ps, etc is still nicely readable
3) We have used it for years on Ubuntu 14.04 and onwards, on 1000+ machines and with a wide array of commercial and scientific software without any issues.
4) One could argue that it is a preventive security measure, there are a lot of weirdly written scripts and software out there that behaves badly upon PID reuse/collissions.
This happens now on Jammy (22.04) on 64-bit (not on 32-bit due to system limits)
systemd ships a default /usr/lib/ sysctl. d/50-pid- max.conf, as per upstream commit here: /github. com/systemd/ systemd/ pull/12226
https:/