Page MenuHomeFreeBSD

D12238.diff
No OneTemporary

D12238.diff

Index: sys/kern/kern_fork.c
===================================================================
--- sys/kern/kern_fork.c
+++ sys/kern/kern_fork.c
@@ -208,20 +208,26 @@
pid = randompid;
error = sysctl_handle_int(oidp, &pid, 0, req);
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 < 100) /* Make it reasonable */
- pid = 100;
- randompid = pid;
+ if (pid == 0)
+ randompid = 0;
+ else if (pid == 1)
+ /* generate a random PID modulus between 100 and 1123 */
+ randompid = 100 + arc4random() % 1024;
+ else if (pid < 0 || pid > pid_max - 100)
+ /* out of range */
+ randompid = pid_max - 100;
+ else if (pid < 100)
+ /* Make it reasonable */
+ randompid = 100;
+ else
+ randompid = pid;
}
sx_xunlock(&allproc_lock);
return (error);
}
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

Mime Type
text/plain
Expires
Sun, Oct 12, 12:27 PM (59 m, 42 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
23623035
Default Alt Text
D12238.diff (1 KB)

Event Timeline