HomeFreeBSD

Prevent incorrect datasets being mounted

Description

Prevent incorrect datasets being mounted

During a mount, zpl_mount_impl(), uses sget() with the callback
zpl_test_super() to find a super_block with a matching objset,
stored in z_os. It does so without taking the teardown lock on
the zfsvfs.

The problem is that operations like rollback will replace the
z_os. And, there is a window where the objset in the rollback
is freed, but z_os still points to it. Then, a mount like
operation, for instance a clone, can reallocate that exact same
pointer and zpl_test_super() will then match the super_block
associated with the rollback as opposed to the clone.

This fix tests for a match and if so, takes the teardown lock
before doing the final match test.

Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: John Poduska <jpoduska@datto.com>
Closes #14518

Details

Provenance
John Poduska <jpoduska@datto.com>Authored on Feb 28 2023, 12:49 AM
GitHub <noreply@github.com>Committed on Feb 28 2023, 12:49 AM
Parents
rG4b9bc6345eb0: Add vdevprops.7 to the Makefile
Branches
Unknown
Tags
Unknown

Event Timeline

GitHub <noreply@github.com> committed rG73c383f54148: Prevent incorrect datasets being mounted (authored by John Poduska <jpoduska@datto.com>).Feb 28 2023, 12:49 AM