git: c5c5705e6496 - stable/13 - sys: Fix heap disclosure in compat7 kern.proc.filedesc sysctl

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Wed, 13 May 2026 14:06:19 UTC
The branch stable/13 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=c5c5705e649642810552559a3b849d9ff5d573b6

commit c5c5705e649642810552559a3b849d9ff5d573b6
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2026-05-12 16:25:01 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2026-05-13 14:06:04 +0000

    sys: Fix heap disclosure in compat7 kern.proc.filedesc sysctl
    
    Reported by: Yuxiang Yang, Yizhou Zhao, Ao Wang, Xuewei Feng, Qi Li, and Ke Xu from Tsinghua University using GLM-5.1 from Z.ai
    
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D56976
    
    (cherry picked from commit e68433e1990d5f1bcc1bdd270d65f1e4792a8e1b)
    (cherry picked from commit 0cef1a9ae5ec90b2c4717de9bc33fc7c3b1fd705)
    (cherry picked from commit 5e6b16f4555cba4422dde7c63344359019a23722)
---
 sys/kern/kern_descrip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 2412c5e4e332..40046ef9110f 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -4902,7 +4902,7 @@ sysctl_kern_proc_ofiledesc(SYSCTL_HANDLER_ARGS)
 		return (ENOENT);
 	}
 	kif = malloc(sizeof(*kif), M_TEMP, M_WAITOK);
-	okif = malloc(sizeof(*okif), M_TEMP, M_WAITOK);
+	okif = malloc(sizeof(*okif), M_TEMP, M_WAITOK | M_ZERO);
 	PWDDESC_XLOCK(pdp);
 	pwd = pwd_hold_pwddesc(pdp);
 	if (pwd != NULL) {