From 23b7e67298e9e9690c803f0cbcde1868073edb07 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Thu, 7 Dec 2023 11:20:11 -0500 Subject: [PATCH] OpenZFS: 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 (cherry picked from commit 11656234b560c401dec6a16e1bf048b20fd31aac) (cherry picked from commit af1e8b52d26502bac9a2484b87d1879334debd67) Differential Revision: https://reviews.freebsd.org/D42987 --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c index 3db00866675..1a0d4fc597c 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c @@ -2735,6 +2735,8 @@ zfs_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr, #else if (vp->v_type == VBLK || vp->v_type == VCHR) vap->va_rdev = zfs_cmpldev(rdev); + else + vap->va_rdev = 0; #endif vap->va_seq = zp->z_seq; vap->va_flags = 0; /* FreeBSD: Reset chflags(2) flags. */