Bug 94291

Summary: Bad xattr names (prefix.) allowed to be set
Product: File System Reporter: William Douglas (william.douglas)
Component: btrfsAssignee: Josef Bacik (josef)
Status: RESOLVED PATCH_ALREADY_AVAILABLE    
Severity: normal CC: dsterba
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.18 Subsystem:
Regression: No Bisected commit-id:

Description William Douglas 2015-03-04 22:38:21 UTC
The btrfs_is_valid_xattr function allows names of the form "prefix." which don't make much sense as valid names. Having at least "prefix.*" should be required for a valid name and is the behavior exhibited by the ext filesystems (and expected in the attr test suite).
Comment 1 David Sterba 2015-03-17 14:46:27 UTC
Do you have a reproducer?

$ touch file
$ setfattr -n btrfs. -v 1 file

straced, shows that it does not pass:

setxattr("file", "btrfs.", "1", 1, 0)   = -1 EINVAL (Invalid argument)
Comment 2 William Douglas 2015-03-17 16:44:46 UTC
Yes sorry I didn't include that.

Your example fails because the attributes have to have a valid prefix (see xattr.c:330 btrfs_is_valid_xattr for the prefixes allowed).

$ touch file
$ setfattr -n user. -v 1 file
$ getfattr file
# file: file
user.
Comment 3 David Sterba 2015-03-25 18:27:31 UTC
Fixed by:

https://patchwork.kernel.org/patch/6094101/