From f43bb3ccc749fc8242f324eba03274b1e9bb3ce5 Mon Sep 17 00:00:00 2001 From: Allan Jude Date: Mon, 28 Nov 2022 16:40:49 -0500 Subject: [PATCH] Avoid a null pointer dereference in zfs_mount() on FreeBSD 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 Reviewed-by: Richard Yao Reviewed-by: Alexander Motin Reviewed-by: Richard Yao Signed-off-by: Allan Jude Closes #14218 --- module/os/freebsd/zfs/zfs_vfsops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/os/freebsd/zfs/zfs_vfsops.c b/module/os/freebsd/zfs/zfs_vfsops.c index b4c122bdf4c8..ffe63176459d 100644 --- a/module/os/freebsd/zfs/zfs_vfsops.c +++ b/module/os/freebsd/zfs/zfs_vfsops.c @@ -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?