summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChengyu Zhu <hudsonzhu@tencent.com>2026-09-07 16:33:19 +0800
committerGao Xiang <xiang@kernel.org>2026-09-07 18:20:30 +0800
commit96bf9831fbf423b8104f7948cd8fe7007ecfb46c (patch)
tree4d2ec386611a641825bc7f16f92be7cd6e48f616
parent82e664cf1219c459c33aae931b222cf951af9cb7 (diff)
downloadlinux-next-96bf9831fbf423b8104f7948cd8fe7007ecfb46c.tar.gz
linux-next-96bf9831fbf423b8104f7948cd8fe7007ecfb46c.zip
erofs: delimit inode_share cache key components
Previously, inode_share keys were encoded as follows: fingerprint || domain_id It would be better to have a separator between the fingerprint and domain ID so that the fingerprint won't be parsed as part of a domain ID. Change the key encoding as follows: domain_id || '\0' || fingerprint Since domain_id is a NUL-terminated string, this makes the in-memory key indices unambiguous. Signed-off-by: Chengyu Zhu <hudsonzhu@tencent.com> Reviewed-by: Gao Xiang <xiang@kernel.org> Fixes: e0bf7d1c074d ("erofs: support user-defined fingerprint name") Signed-off-by: Gao Xiang <xiang@kernel.org>
-rw-r--r--fs/erofs/xattr.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
index df7ea019526d..57cfb7520782 100644
--- a/fs/erofs/xattr.c
+++ b/fs/erofs/xattr.c
@@ -620,8 +620,8 @@ int erofs_xattr_fill_inode_fingerprint(struct erofs_inode_fingerprint *fp,
{
struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb);
struct erofs_xattr_prefix_item *prefix;
+ int domainlen, valuelen, base_index;
const char *infix;
- int valuelen, base_index;
if (!test_opt(&sbi->opt, INODE_SHARE))
return -EOPNOTSUPP;
@@ -633,17 +633,18 @@ int erofs_xattr_fill_inode_fingerprint(struct erofs_inode_fingerprint *fp,
valuelen = erofs_getxattr(inode, base_index, infix, NULL, 0);
if (valuelen <= 0 || valuelen > (1 << sbi->blkszbits))
return -EFSCORRUPTED;
- fp->size = valuelen + (domain_id ? strlen(domain_id) : 0);
+ domainlen = strlen(domain_id);
+ fp->size = domainlen + 1 + valuelen;
fp->opaque = kmalloc(fp->size, GFP_KERNEL);
if (!fp->opaque)
return -ENOMEM;
+ memcpy(fp->opaque, domain_id, domainlen + 1);
if (valuelen != erofs_getxattr(inode, base_index, infix,
- fp->opaque, valuelen)) {
+ fp->opaque + domainlen + 1, valuelen)) {
kfree(fp->opaque);
fp->opaque = NULL;
return -EFSCORRUPTED;
}
- memcpy(fp->opaque + valuelen, domain_id, fp->size - valuelen);
return 0;
}
#endif