Skip to content

Commit

Permalink
erofs: zero out when listxattr is called with no xattr
Browse files Browse the repository at this point in the history
As David reported [1], ENODATA returns when attempting
to modify files by using EROFS as an overlayfs lower layer.

The root cause is that listxattr could return unexpected
-ENODATA by mistake for inodes without xattr. That breaks
listxattr return value convention and it can cause copy
up failure when used with overlayfs.

Resolve by zeroing out if no xattr is found for listxattr.

[1] https://lore.kernel.org/r/CAEvUa7nxnby+rxK-KRMA46=exeOMApkDMAV08AjMkkPnTPV4CQ@mail.gmail.com
Link: https://lore.kernel.org/r/[email protected]
Fixes: cadf1cc ("staging: erofs: add error handling for xattr submodule")
Cc: <[email protected]> # 4.19+
Reviewed-by: Chao Yu <[email protected]>
Signed-off-by: Gao Xiang <[email protected]>
  • Loading branch information
Gao Xiang committed Dec 4, 2019
1 parent 219d543 commit 926d165
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/erofs/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,8 @@ ssize_t erofs_listxattr(struct dentry *dentry,
struct listxattr_iter it;

ret = init_inode_xattrs(d_inode(dentry));
if (ret == -ENOATTR)
return 0;
if (ret)
return ret;

Expand Down

0 comments on commit 926d165

Please sign in to comment.