]> git.proxmox.com Git - mirror_zfs.git/commitdiff
FreeBSD: Ensure that zfs_getattr() initializes the va_rdev field
authorMark Johnston <markjdb@gmail.com>
Thu, 7 Dec 2023 16:20:11 +0000 (11:20 -0500)
committerGitHub <noreply@github.com>
Thu, 7 Dec 2023 16:20:11 +0000 (08:20 -0800)
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 <behlendorf1@llnl.gov>
Reviewed-by: Ed Maste <emaste@FreeBSD.org>
Signed-off-by: Mark Johnston <markj@FreeBSD.org>
Closes #15639

module/os/freebsd/zfs/zfs_vnops_os.c

index aa1d4855e6639ad3a71fc765edb111e1d597660f..d9a8c8a0d7699ce9e3ee240380024168746657c3 100644 (file)
@@ -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;