ovl: fix trusted xattr escape prefix matching
PATCH 1/1 ovl: fix trusted xattr escape prefix matching
In the trusted.* xattr namespace, ovl_is_escaped_xattr() compares one byte less than the escaped overlay xattr prefix length. This makes it match "trusted.overlay.overlay" without requiring the trailing dot.
As a result, an xattr such as "trusted.overlay.overlayfoo" is incorrectly treated as an escaped overlay xattr. This can be reproduced by setting "trusted.overlay.overlayfoo" on a lower file and listing xattrs through an overlay mount. listxattr() then exposes it as "trusted.overlay.oo", and a following getxattr() on that listed name fails with ENODATA.
Compare the full escaped prefix, including the trailing dot, so similarly-prefixed private xattrs are not misclassified.
--- fs/overlayfs/xattrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/overlayfs/xattrs.c +1 -1
@@ -13,7 +13,7 @@ static bool ovl_is_escaped_xattr(struct super_block *sb, const char *name) OVL_XATTR_ESCAPE_USER_PREFIX_LEN) == 0; else return strncmp(name, OVL_XATTR_ESCAPE_TRUSTED_PREFIX, -OVL_XATTR_ESCAPE_TRUSTED_PREFIX_LEN -1 ) ==0 ; +OVL_XATTR_ESCAPE_TRUSTED_PREFIX_LEN ) ==0 ; }static bool ovl_is_own_xattr (struct super_block *sb,const char *name)
Signature · 1 line
2.51.0
Quoted 12 lines · Yichong Chen
In the trusted.* xattr namespace,
ovl_is_escaped_xattr()compares one byte less than the escaped overlay xattr prefix length. This makes it match "trusted.overlay.overlay" without requiring the trailing dot.As a result, an xattr such as "trusted.overlay.overlayfoo" is incorrectly treated as an escaped overlay xattr. This can be reproduced by setting "trusted.overlay.overlayfoo" on a lower file and listing xattrs through an overlay mount.
listxattr()then exposes it as "trusted.overlay.oo", and a followinggetxattr()on that listed name fails with ENODATA.
Quoted 5 lines
Compare the full escaped prefix, including the trailing dot, so similarly-prefixed private xattrs are not misclassified.
Fixes dad02fad84cbc ("ovl: Support escaped overlay.* xattrs")Signed-off-by Yichong Chen <[email protected]>
Christian,
Would you mind applying this fix via vfs.fixes?
Thanks,
Amir.
Quoted 20 lines
--- fs/overlayfs/xattrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/overlayfs/xattrs.c +1
-2@@ -13,7 +13,7 @@ static bool ovl_is_escaped_xattr(struct super_block *sb, const char *name) OVL_XATTR_ESCAPE_USER_PREFIX_LEN) == 0; else return strncmp(name, OVL_XATTR_ESCAPE_TRUSTED_PREFIX, -OVL_XATTR_ESCAPE_TRUSTED_PREFIX_LEN -1 ) ==0 ; +OVL_XATTR_ESCAPE_TRUSTED_PREFIX_LEN ) ==0 ; }static bool ovl_is_own_xattr (struct super_block *sb,const char *name) --2.51.0
Christian Brauner
AppliedQuoted 1 line · Yichong Chen
ovl: fix trusted xattr escape prefix matching
Applied to the vfs.fixes branch of the vfs/vfs.git tree. Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.fixes
[1/1] ovl: fix trusted xattr escape prefix matching
https://git.kernel.org/vfs/vfs/c/cb9db85f143a