kern - Do not allow calls to vmspace_president_count() from userland.
authorAntonio Huete Jimenez <tuxillo@quantumachine.net>
Sat, 22 Oct 2011 10:20:29 +0000 (12:20 +0200)
committerAntonio Huete Jimenez <tuxillo@quantumachine.net>
Sat, 22 Oct 2011 21:19:04 +0000 (23:19 +0200)
- Processes' vm_map is not read in by kvm_proclist() thus we cannot
  call vmspace_president_count() which entirely relies on that.
- This fixes segfaults in ps(1), w(1) and fstat(1) when using -M
  and -N parameters.

Help-from: @corecode

sys/kern/kern_kinfo.c

index 71717b9..aa6f442 100644 (file)
@@ -155,7 +155,9 @@ fill_kinfo_proc(struct proc *p, struct kinfo_proc *kp)
 #endif
                kp->kp_vm_map_size = vm->vm_map.size;
                kp->kp_vm_rssize = vmspace_resident_count(vm);
+#ifdef _KERNEL
                kp->kp_vm_prssize = vmspace_president_count(vm);
+#endif
                kp->kp_vm_swrss = vm->vm_swrss;
                kp->kp_vm_tsize = vm->vm_tsize;
                kp->kp_vm_dsize = vm->vm_dsize;