FreeBSD: Fix a potential null dereference in zfs_freebsd_fsync()

In general it's possible for a vnode to not have an associated VM
object.  This happens in particular with named pipes, which have
some distinct VOPs, defined in zfs_fifoops.  Thus, this chunk of
zfs_freebsd_fsync() needs to check for the FIFO case, like other
vm_object_mightbedirty() callers do.

(Note that vn_flush_cached_data() calls are predicated on
zn_has_cached_data() returning true, and it checks for a NULL v_object
pointer already.)

Fixes: ef4058fcdc
Reported-by: Collin Funk <collin.funk1@gmail.com>
Reviewed-by: Sean Eric Fagan <sef@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
Signed-off-by: Mark Johnston <markj@FreeBSD.org>
Closes #18015
This commit is contained in:
Mark Johnston 2025-12-08 16:46:30 -05:00 committed by Brian Behlendorf
parent 872266a5f3
commit a2f768f61f

View File

@ -5277,7 +5277,7 @@ zfs_freebsd_fsync(struct vop_fsync_args *ap)
* Push any dirty mmap()'d data out to the DMU and ZIL, ready for
* zil_commit() to be called in zfs_fsync().
*/
if (vm_object_mightbedirty(vp->v_object)) {
if (vp->v_object != NULL && vm_object_mightbedirty(vp->v_object)) {
zfs_vmobject_wlock(vp->v_object);
if (!vm_object_page_clean(vp->v_object, 0, 0, 0))
err = SET_ERROR(EIO);