Created attachment 216234 [details] 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=10240 # 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.