From 11656234b560c401dec6a16e1bf048b20fd31aac Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Thu, 7 Dec 2023 11:20:11 -0500 Subject: [PATCH] FreeBSD: Ensure that zfs_getattr() initializes the va_rdev field Otherwise the field is left uninitialized, leading to a possible kernel memory disclosure to userspace or to the network. Use the same initialization value we use in zfsctl_common_getattr(). Reported-by: KMSAN Sponsored-by: The FreeBSD Foundation Reviewed-by: Brian Behlendorf Reviewed-by: Ed Maste Signed-off-by: Mark Johnston Closes #15639 --- module/os/freebsd/zfs/zfs_vnops_os.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/module/os/freebsd/zfs/zfs_vnops_os.c b/module/os/freebsd/zfs/zfs_vnops_os.c index aa1d4855e6..d9a8c8a0d7 100644 --- a/module/os/freebsd/zfs/zfs_vnops_os.c +++ b/module/os/freebsd/zfs/zfs_vnops_os.c @@ -2011,6 +2011,8 @@ zfs_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr) vap->va_size = zp->z_size; if (vp->v_type == VBLK || vp->v_type == VCHR) vap->va_rdev = zfs_cmpldev(rdev); + else + vap->va_rdev = 0; vap->va_gen = zp->z_gen; vap->va_flags = 0; /* FreeBSD: Reset chflags(2) flags. */ vap->va_filerev = zp->z_seq;