diff options
author | Filipe Manana <fdmanana@suse.com> | 2014-11-09 08:38:39 +0000 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-11-20 17:20:07 -0800 |
commit | 5f5bc6b1e2d5a6f827bc860ef2dc5b6f365d1339 (patch) | |
tree | d17afbf1a528b003f34d43cf557d2da62a7a6b1b /fs/btrfs/ctree.c | |
parent | c7bc6319c59cc791743cf1b6e98f86be69444495 (diff) | |
download | linux-5f5bc6b1e2d5a6f827bc860ef2dc5b6f365d1339.tar.gz linux-5f5bc6b1e2d5a6f827bc860ef2dc5b6f365d1339.tar.bz2 linux-5f5bc6b1e2d5a6f827bc860ef2dc5b6f365d1339.zip |
Btrfs: make xattr replace operations atomic
Replacing a xattr consists of doing a lookup for its existing value, delete
the current value from the respective leaf, release the search path and then
finally insert the new value. This leaves a time window where readers (getxattr,
listxattrs) won't see any value for the xattr. Xattrs are used to store ACLs,
so this has security implications.
This change also fixes 2 other existing issues which were:
*) Deleting the old xattr value without verifying first if the new xattr will
fit in the existing leaf item (in case multiple xattrs are packed in the
same item due to name hash collision);
*) Returning -EEXIST when the flag XATTR_CREATE is given and the xattr doesn't
exist but we have have an existing item that packs muliple xattrs with
the same name hash as the input xattr. In this case we should return ENOSPC.
A test case for xfstests follows soon.
Thanks to Alexandre Oliva for reporting the non-atomicity of the xattr replace
implementation.
Reported-by: Alexandre Oliva <oliva@gnu.org>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r-- | fs/btrfs/ctree.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 19bc6162fb8e..817234168a7f 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -2939,7 +2939,7 @@ done: */ if (!p->leave_spinning) btrfs_set_path_blocking(p); - if (ret < 0) + if (ret < 0 && !p->skip_release_on_error) btrfs_release_path(p); return ret; } |