From e45a981f6d12fbf37bd7e0dbf7d9992da6c3e14f 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 74b7e46c0909..85449ebb9d97 100644 --- a/module/os/freebsd/zfs/zfs_vfsops.c +++ b/module/os/freebsd/zfs/zfs_vfsops.c @@ -1362,7 +1362,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?