Skip to content

Commit b65917d

Browse files
author
Sage Weil
committed
ceph: fix listxattr handling for vxattrs
Only include vxattrs in the result if they are not hidden and exist (as determined by the exists_cb callback). Note that the buffer size we return when 0 is passed in always includes vxattrs that *might* exist, forming an upper bound. Signed-off-by: Sage Weil <sage@inktank.com> Reviewed-by: Sam Lang <sam.lang@inktank.com>
1 parent 0bee82f commit b65917d

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

‎fs/ceph/xattr.c‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -657,23 +657,30 @@ ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size)
657657
vir_namelen = ceph_vxattrs_name_size(vxattrs);
658658

659659
/* adding 1 byte per each variable due to the null termination */
660-
namelen = vir_namelen + ci->i_xattrs.names_size + ci->i_xattrs.count;
660+
namelen = ci->i_xattrs.names_size + ci->i_xattrs.count;
661661
err = -ERANGE;
662-
if (size && namelen > size)
662+
if (size && vir_namelen + namelen > size)
663663
goto out;
664664

665-
err = namelen;
665+
err = namelen + vir_namelen;
666666
if (size == 0)
667667
goto out;
668668

669669
names = __copy_xattr_names(ci, names);
670670

671671
/* virtual xattr names, too */
672-
if (vxattrs)
672+
err = namelen;
673+
if (vxattrs) {
673674
for (i = 0; vxattrs[i].name; i++) {
674-
len = sprintf(names, "%s", vxattrs[i].name);
675-
names += len + 1;
675+
if (!vxattrs[i].hidden &&
676+
!(vxattrs[i].exists_cb &&
677+
!vxattrs[i].exists_cb(ci))) {
678+
len = sprintf(names, "%s", vxattrs[i].name);
679+
names += len + 1;
680+
err += len + 1;
681+
}
676682
}
683+
}
677684

678685
out:
679686
spin_unlock(&ci->i_ceph_lock);

0 commit comments

Comments
 (0)