Unverified Commit 891ac937 authored by Richard Yao's avatar Richard Yao Committed by GitHub
Browse files

Linux: Fix use-after-free in zfsvfs_create()


Coverity reported that we pass a pointer to zfsvfs to
`dmu_objset_disown()` after freeing zfsvfs in zfsvfs_create_impl() after
a failure in zfsvfs_init().

We have nearly identical duplicate versions of this code for FreeBSD and
Linux, but interestingly, the FreeBSD version of this code differs in
such a way that it does not suffer from this bug. We remove the
difference from the FreeBSD version to fix this bug.
Reviewed-by: default avatarBrian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: default avatarRichard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13883 
parent 042d43a1
base NAS-116738 NAS-116738-prev NAS-117807 NAS-117845-dbg2-ozfs-mater NAS-117880 NAS-122915 NAS-122949 NAS-123279-2 NAS-124189-cobia NAS-124564 NAS-124699 NAS-124699-2 NAS-124699-3 NAS-124699-3-test NAS-125150 NAS-125882 NAS-125882-2 NAS-125916 NAS-125916-1 NAS-127352 NAS-127352-tn NAS-127702 NAS-127702-1 NAS-127702-df NAS-127822 NAS-127822-debug NAS-127888 NAS-127888-truenas TS-23.10 dragonfish/zfs-2.2.4-staging master nfsacl nfsacl-1 nfsacl-a nfsacl-review nfsv4acl nfsv4acls ozfs_master_test pkg-test raidz-expansion-rebase rel-v0.0.1 release/23.10-BETA.1 release/23.10-RC.1 release/23.10.0 release/23.10.1 release/23.10.1.2 release/23.10.1.3 release/23.10.2 release/24.04-BETA.1 release/24.04-RC.1 release/24.04.0 set-sast-config-1 stable/cobia stable/dragonfish test test-ci test_pkg testing-refine-branchout-process testing-refine-branchout-process2 tn_master truenas/NAS-127822-debug truenas/dragonfish-2.2.2-test truenas/zfs-2.2-release truenas/zfs-2.2.1-hutter truenas/zfs-2.2.1-hutter2 truenas/zfs-2.2.1-release truenas/zfs-2.2.1-release-dragonfish truenas/zfs-2.2.3-staging-dragonfish truenas/zfs-2.2.3-testing truenas/zfs-2.2.4-staging truenas/zfs-2.3-release truenas/zfs-2.3-testing truenas/zfs-cobia-rc1-test truenas/zvol-multi-taskq truenas/zvol-multiq truenas/zvol-multiq-clean truenas/zvol-thread-property zfetch_reorder zfetch_reorder10 zfs-json zfs-ozfs-master zvol-cleanup zvol-improvements-2.2.1 zvol-ro-property zvol-thread-property zvol_multi_taskq zvol_multiq TS-24.04-RC.1 TS-24.04-BETA.1 TS-23.10.2 TS-23.10.1.3 TS-23.10.1.2 TS-23.10.1.1 TS-23.10.1 TS-23.10.0.1 TS-23.10.0 TS-23.10-RC.1 TS-23.10-BETA.1 DN110M-CS-v2.0
No related merge requests found
Showing with 2 additions and 3 deletions
+2 -3
......@@ -784,9 +784,7 @@ zfsvfs_create(const char *osname, boolean_t readonly, zfsvfs_t **zfvp)
}
error = zfsvfs_create_impl(zfvp, zfsvfs, os);
if (error != 0) {
dmu_objset_disown(os, B_TRUE, zfsvfs);
}
return (error);
}
......@@ -826,6 +824,7 @@ zfsvfs_create_impl(zfsvfs_t **zfvp, zfsvfs_t *zfsvfs, objset_t *os)
error = zfsvfs_init(zfsvfs, os);
if (error != 0) {
dmu_objset_disown(os, B_TRUE, zfsvfs);
*zfvp = NULL;
zfsvfs_free(zfsvfs);
return (error);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment