Skip to content

Commit

Permalink
bcachefs: Fix missing locking for dentry->d_parent access
Browse files Browse the repository at this point in the history
Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
  • Loading branch information
Kent Overstreet committed Nov 16, 2023
1 parent 61b85cb commit ba276ce
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fs/bcachefs/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,14 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
s.v = v + 1;
s.defined = true;
} else {
/*
* Check if this option was set on the parent - if so, switched
* back to inheriting from the parent:
*
* rename() also has to deal with keeping inherited options up
* to date - see bch2_reinherit_attrs()
*/
spin_lock(&dentry->d_lock);
if (!IS_ROOT(dentry)) {
struct bch_inode_info *dir =
to_bch_ei(d_inode(dentry->d_parent));
Expand All @@ -560,6 +568,7 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
} else {
s.v = 0;
}
spin_unlock(&dentry->d_lock);

s.defined = false;
}
Expand Down

0 comments on commit ba276ce

Please sign in to comment.