]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Avoid a null pointer dereference in zfs_mount() on FreeBSD
authorAllan Jude <allan@klarasystems.com>
Mon, 28 Nov 2022 21:40:49 +0000 (16:40 -0500)
committerGitHub <noreply@github.com>
Mon, 28 Nov 2022 21:40:49 +0000 (13:40 -0800)
When mounting the root filesystem, vfs_t->mnt_vnodecovered is null

This will cause zfsctl_is_node() to dereference a null pointer when
mounting, or updating the mount flags, on the root filesystem, both
of which happen during the boot process.

Reported-by: Martin Matuska <mm@FreeBSD.org>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Signed-off-by: Allan Jude <allan@klarasystems.com>
Closes #14218

module/os/freebsd/zfs/zfs_vfsops.c

index b4c122bdf4c8b42e39c9e989a87742801d927da2..ffe63176459d140ce3ce23ff75c96e14ffd5861e 100644 (file)
@@ -1328,7 +1328,8 @@ zfs_mount(vfs_t *vfsp)
        }
 
        fetch_osname_options(osname, &checkpointrewind);
-       isctlsnap = (zfsctl_is_node(mvp) && strchr(osname, '@') != NULL);
+       isctlsnap = (mvp != NULL && zfsctl_is_node(mvp) &&
+           strchr(osname, '@') != NULL);
 
        /*
         * Check for mount privilege?