DragonFlyBSD Kernel Audit
DF-1056 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/platform/pc64/x86_64/machdep.c b/sys/platform/pc64/x86_64/machdep.c
--- a/sys/platform/pc64/x86_64/machdep.c
+++ b/sys/platform/pc64/x86_64/machdep.c
@@ -3079,6 +3079,13 @@
 {
 	if (lp->lwp_thread == NULL || lp->lwp_thread->td_pcb == NULL)
 		return EINVAL;
+	/*
+	 * fill_fpregs_xmm() only initializes env87 + sv_ac[8] (108 bytes) of the
+	 * 512-byte struct fpreg.  Zero the whole struct first so we never leak
+	 * kernel stack to ptrace(PT_GETFPREGS) / /proc/<pid>/fpregs callers that
+	 * uiomove all 512 bytes out.  Fixes DF-1056.
+	 */
+	bzero(fpregs, sizeof(*fpregs));
 	if (cpu_fxsr) {
 		fill_fpregs_xmm(&lp->lwp_thread->td_pcb->pcb_save.sv_xmm,
 				(struct save87 *)fpregs);