Skip to content

Commit

Permalink
Linux: Defer loading the object set in zfs_setattr()
Browse files Browse the repository at this point in the history
We need to wait until after having done a zfs_enter() to load some
fields from the zfsvfs structure.  Otherwise a use-after-free is
possible in the face of a concurrent rollback.

Other functions in this file are careful to avoid this bug, I believe
this is the only instance.

Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Mark Johnston <markj@FreeBSD.org>
Closes #15752
  • Loading branch information
markjdb authored and behlendorf committed Jan 29, 2024
1 parent 7bccf98 commit 22e4f08
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion module/os/linux/zfs/zfs_vnops_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -1853,7 +1853,7 @@ zfs_setattr(znode_t *zp, vattr_t *vap, int flags, cred_t *cr, zidmap_t *mnt_ns)
{
struct inode *ip;
zfsvfs_t *zfsvfs = ZTOZSB(zp);
objset_t *os = zfsvfs->z_os;
objset_t *os;
zilog_t *zilog;
dmu_tx_t *tx;
vattr_t oldva;
Expand Down Expand Up @@ -1885,6 +1885,7 @@ zfs_setattr(znode_t *zp, vattr_t *vap, int flags, cred_t *cr, zidmap_t *mnt_ns)
if ((err = zfs_enter_verify_zp(zfsvfs, zp, FTAG)) != 0)
return (err);
ip = ZTOI(zp);
os = zfsvfs->z_os;

/*
* If this is a xvattr_t, then get a pointer to the structure of
Expand Down

0 comments on commit 22e4f08

Please sign in to comment.