DragonFlyBSD Kernel Audit
DF-2684 / fix.diff
← back to finding ↓ download raw
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -3488,6 +3488,15 @@
 			kcore_make_file(&kf, fp, p->p_pid, uid, n);
+			/*
+			 * DF-2684 FIX: kinfo_file.f_file/f_data are raw
+			 * kernel heap pointers; do not disclose them to
+			 * unprivileged readers.
+			 */
+			if (info->req->td->td_ucred->cr_uid != 0) {
+				kf.f_file = NULL;
+				kf.f_data = NULL;
+			}
 			spin_unlock_shared(&fdp->fd_spin);
 			info->error = SYSCTL_OUT(info->req, &kf, sizeof(kf));
 			spin_lock_shared(&fdp->fd_spin);