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 <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
This commit is contained in:
Allan Jude 2022-11-28 16:40:49 -05:00 committed by GitHub
parent 3069872ef5
commit d27a00283f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -1328,7 +1328,8 @@ zfs_mount(vfs_t *vfsp)
} }
fetch_osname_options(osname, &checkpointrewind); 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? * Check for mount privilege?