]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ovl: fix trusted xattr escape prefix matching
authorYichong Chen <chenyichong@uniontech.com>
Wed, 8 Jul 2026 08:22:21 +0000 (16:22 +0800)
committerChristian Brauner <brauner@kernel.org>
Wed, 22 Jul 2026 11:48:00 +0000 (13:48 +0200)
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.

Fixes: dad02fad84cbc ("ovl: Support escaped overlay.* xattrs")
Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
Link: https://patch.msgid.link/20260708082221.633602-1-chenyichong@uniontech.com
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
fs/overlayfs/xattrs.c

index aa95855c70237b3fc399ebf1bd96e94551cee332..859e80ae6f40573ede4988832797a38a5a8604ce 100644 (file)
@@ -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)