Skip to content

Commit 0ece614

Browse files
LiBaokun96brauner
authored andcommitted
cachefiles: propagate errors from vfs_getxattr() to avoid infinite loop
In cachefiles_check_volume_xattr(), the error returned by vfs_getxattr() is not passed to ret, so it ends up returning -ESTALE, which leads to an endless loop as follows: cachefiles_acquire_volume retry: ret = cachefiles_check_volume_xattr ret = -ESTALE xlen = vfs_getxattr // return -EIO // The ret is not updated when xlen < 0, so -ESTALE is returned. return ret // Supposed to jump out of the loop at this judgement. if (ret != -ESTALE) goto error_dir; cachefiles_bury_object // EIO causes rename failure goto retry; Hence propagate the error returned by vfs_getxattr() to avoid the above issue. Do the same in cachefiles_check_auxdata(). Fixes: 32e1500 ("fscache, cachefiles: Store the volume coherency data") Fixes: 72b9578 ("cachefiles: Implement metadata/coherency data storage in xattrs") Signed-off-by: Baokun Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Gao Xiang <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 5d8f805 commit 0ece614

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/cachefiles/xattr.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,11 @@ int cachefiles_check_auxdata(struct cachefiles_object *object, struct file *file
110110
if (xlen == 0)
111111
xlen = vfs_getxattr(&nop_mnt_idmap, dentry, cachefiles_xattr_cache, buf, tlen);
112112
if (xlen != tlen) {
113-
if (xlen < 0)
113+
if (xlen < 0) {
114+
ret = xlen;
114115
trace_cachefiles_vfs_error(object, file_inode(file), xlen,
115116
cachefiles_trace_getxattr_error);
117+
}
116118
if (xlen == -EIO)
117119
cachefiles_io_error_obj(
118120
object,
@@ -252,6 +254,7 @@ int cachefiles_check_volume_xattr(struct cachefiles_volume *volume)
252254
xlen = vfs_getxattr(&nop_mnt_idmap, dentry, cachefiles_xattr_cache, buf, len);
253255
if (xlen != len) {
254256
if (xlen < 0) {
257+
ret = xlen;
255258
trace_cachefiles_vfs_error(NULL, d_inode(dentry), xlen,
256259
cachefiles_trace_getxattr_error);
257260
if (xlen == -EIO)

0 commit comments

Comments
 (0)