Date: Sun, 05 Jul 2020 20:30:37 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 247790] PIDs are no longer randomized after reaching pid_max Message-ID: <bug-247790-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D247790 Bug ID: 247790 Summary: PIDs are no longer randomized after reaching pid_max Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: kd-dev@pm.me Created attachment 216234 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D216234&action= =3Dedit Wrap `trypid' with a modulus. Overview: If `random' pushes `trypid' over the `max_pid' threshold then `trypid' is reset to 2 and is no-longer randomized. Steps to Reproduce: # sysctl kern.randompid=3D10240 # Unreasonably large for a smaller test # for x in `jot 100`; do > sh -c 'echo $$' > done | awk '{print length}' | sort -n | uniq -c Expected Results: Longer PIDs are orders of magnitude more likely than smaller PIDs. > 1 3 > 8 4 > 91 5 Actual Results: Two-digit PIDs are far more likely than they should be. > 5 2 > 10 4 > 85 5 Additional Information: Only CURRENT is affected. Patch: The attached patch wraps `trypid' with a modulus rather than simply setting it to 2. I have successfully compiled the patch without warnings, and am currently running the patched kernel. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-247790-227>