⬢ DragonFlyBSD Kernel Audit
DF-3258 / fix.diff
← back to finding ↓ download raw
--- a/sys/platform/pc64/x86_64/machdep.c
+++ b/sys/platform/pc64/x86_64/machdep.c
@@ -3105,6 +3105,13 @@
 {
 	struct pcb *pcb;
 
+	/*
+	 * struct dbreg has 16 slots but only dr[0..7] are defined on x86;
+	 * dr[8..15] are reserved.  Zero the whole structure so callers that
+	 * copy it out to userland (procfs_dodbregs / PT_GETDBREGS) do not
+	 * disclose stale kernel stack memory.
+	 */
+	bzero(dbregs, sizeof(*dbregs));
 	if (lp == NULL) {
 		dbregs->dr[0] = rdr0();
 		dbregs->dr[1] = rdr1();