Skip to content

Commit ba276ce

Browse files
author
Kent Overstreet
committed
bcachefs: Fix missing locking for dentry->d_parent access
Reported-by: Al Viro <[email protected]> Signed-off-by: Kent Overstreet <[email protected]>
1 parent 61b85cb commit ba276ce

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

fs/bcachefs/xattr.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,14 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
552552
s.v = v + 1;
553553
s.defined = true;
554554
} else {
555+
/*
556+
* Check if this option was set on the parent - if so, switched
557+
* back to inheriting from the parent:
558+
*
559+
* rename() also has to deal with keeping inherited options up
560+
* to date - see bch2_reinherit_attrs()
561+
*/
562+
spin_lock(&dentry->d_lock);
555563
if (!IS_ROOT(dentry)) {
556564
struct bch_inode_info *dir =
557565
to_bch_ei(d_inode(dentry->d_parent));
@@ -560,6 +568,7 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
560568
} else {
561569
s.v = 0;
562570
}
571+
spin_unlock(&dentry->d_lock);
563572

564573
s.defined = false;
565574
}

0 commit comments

Comments
 (0)