Skip to content

Commit

Permalink
Revert "Fixed a use-after-free bug in zfs_zget()."
Browse files Browse the repository at this point in the history
This reverts commit 36df284.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
  • Loading branch information
behlendorf committed Apr 3, 2014
1 parent 7c05c61 commit 8ac6729
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions module/zfs/zfs_znode.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,19 +859,14 @@ zfs_zget(zfs_sb_t *zsb, uint64_t obj_num, znode_t **zpp)
znode_t *zp;
int err;
sa_handle_t *hdl;
struct inode *ip;

*zpp = NULL;

again:
ip = ilookup(zsb->z_sb, obj_num);

ZFS_OBJ_HOLD_ENTER(zsb, obj_num);

err = sa_buf_hold(zsb->z_os, obj_num, NULL, &db);
if (err) {
ZFS_OBJ_HOLD_EXIT(zsb, obj_num);
iput(ip);
return (err);
}

Expand All @@ -882,28 +877,14 @@ zfs_zget(zfs_sb_t *zsb, uint64_t obj_num, znode_t **zpp)
doi.doi_bonus_size < sizeof (znode_phys_t)))) {
sa_buf_rele(db, NULL);
ZFS_OBJ_HOLD_EXIT(zsb, obj_num);
iput(ip);
return (SET_ERROR(EINVAL));
}

hdl = dmu_buf_get_user(db);
if (hdl != NULL) {
if (ip == NULL) {
/*
* ilookup returned NULL, which means
* the znode is dying - but the SA handle isn't
* quite dead yet, we need to drop any locks
* we're holding, re-schedule the task and try again.
*/
sa_buf_rele(db, NULL);
ZFS_OBJ_HOLD_EXIT(zsb, obj_num);

schedule();
goto again;
}

zp = sa_get_userdata(hdl);


/*
* Since "SA" does immediate eviction we
* should never find a sa handle that doesn't
Expand All @@ -924,12 +905,9 @@ zfs_zget(zfs_sb_t *zsb, uint64_t obj_num, znode_t **zpp)
sa_buf_rele(db, NULL);
mutex_exit(&zp->z_lock);
ZFS_OBJ_HOLD_EXIT(zsb, obj_num);
iput(ip);
return (err);
}

ASSERT3P(ip, ==, NULL);

/*
* Not found create new znode/vnode but only if file exists.
*
Expand Down

0 comments on commit 8ac6729

Please sign in to comment.