]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
bcachefs: Fix missing locking for dentry->d_parent access
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 15 Nov 2023 00:11:04 +0000 (19:11 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 16 Nov 2023 21:57:19 +0000 (16:57 -0500)
Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/xattr.c

index a39ff0c296ecfb2a000edd6aace20bdbb8db20ea..79d982674c180307f5d5a4da42fabaa480878573 100644 (file)
@@ -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));
@@ -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;
        }