DragonFlyBSD Kernel Audit
DF-2706 / fix.diff
← back to finding ↓ download raw
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -1686,8 +1686,10 @@ sysctl_kern_proc(SYSCTL_HANDLER_ARGS)
 	if (oid == KERN_PROC_PID) {
 		p = pfind((pid_t)name[0]);
 		if (p) {
 			crcache = pcredcache(crcache, p);
-			if (PRISON_CHECK(cr1, crcache))
+			if (PRISON_CHECK(cr1, crcache) &&
+			    (ps_showallprocs || !p_trespass(cr1, crcache))) {
 				error = sysctl_out_proc(p, req, flags);
+			}
 			PRELE(p);
 		}
 		goto post_threads;
 	}