Skip to content

Commit

Permalink
Avoid a null pointer dereference in zfs_mount() on FreeBSD
Browse files Browse the repository at this point in the history
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 openzfs#14218
  • Loading branch information
allanjude authored and andrewc12 committed Dec 17, 2022
1 parent 50dff60 commit f43bb3c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion module/os/freebsd/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit f43bb3c

Please sign in to comment.