Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151089158
D12238.id32799.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
902 B
Referenced Files
None
Subscribers
None
D12238.id32799.diff
View Options
Index: sys/kern/kern_fork.c
===================================================================
--- sys/kern/kern_fork.c
+++ sys/kern/kern_fork.c
@@ -210,8 +210,12 @@
if (error == 0 && req->newptr != NULL) {
if (pid < 0 || pid > pid_max - 100) /* out of range */
pid = pid_max - 100;
- else if (pid < 2) /* NOP */
- pid = 0;
+ else if (pid == 1) {
+ /*
+ * Generate a random PID modulus, range: 100 to 999
+ */
+ pid = (uint64_t) arc4random() * (999 + 1 - 100) / UINT32_MAX + 100;
+ }
else if (pid < 100) /* Make it reasonable */
pid = 100;
randompid = pid;
@@ -221,7 +225,7 @@
}
SYSCTL_PROC(_kern, OID_AUTO, randompid, CTLTYPE_INT|CTLFLAG_RW,
- 0, 0, sysctl_kern_randompid, "I", "Random PID modulus");
+ 0, 0, sysctl_kern_randompid, "I", "Random PID modulus. Special values: 0: disable, 1: choose random value");
static int
fork_findpid(int flags)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Apr 6, 10:48 PM (3 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31001341
Default Alt Text
D12238.id32799.diff (902 B)
Attached To
Mode
D12238: Implement random modulus with kern.randompid=1
Attached
Detach File
Event Timeline
Log In to Comment