Improve handling of unidentified xattrs
cover Improve handling of unidentified xattrs
Hi,
I had a report that when erofs is built from the btrfs filesystem with compression enabled, it would fail to build seemingly with error "failed to build shared xattrs". We tried to fix this by returning 0 (null) instead of error in parse_one_xattr(). However we need to actually skip it else we get a null pointer dereference in erofs_xattr_add() trying to process the same.
Thanks,
Sandeep.
Tested with btrfs with compression enabled.
$ lsattr mtpt/ --------c------------- mtpt/sample.txt
Before:
mkfs.erofs -z lz4hc,9 erofs.img mtpt/
mkfs.erofs 1.8.1-dirty
<W> erofs: parse_one_xattr() Line[285] skipped unidentified xattr: btrfs.compression Segmentation fault
After:
mkfs.erofs -z lz4hc,9 erofs.img mtpt/
mkfs.erofs 1.8.1-dirty
<W> erofs: parse_one_xattr() Line[285] skipped unidentified xattr: btrfs.compression Processing sample.txt ...
<W> erofs: parse_one_xattr() Line[285] skipped unidentified xattr: btrfs.compression Build completed.
------
Filesystem UUID: 9a1bb5a3-077a-40bc-972f-ed141059e7c8
Filesystem total blocks: 5 (of 4096-byte blocks)
Filesystem total inodes: 2
Filesystem total metadata blocks: 1
Filesystem total deduplicated bytes (of source files): 0
Sandeep Dhavale (1):
erofs-utils: lib: actually skip the unidentified xattrs
lib/xattr.c | 3 +++ 1 file changed, 3 insertions(+)
Signature · 1 line
2.46.0.184.g6999bdac58-goog
PATCH 1/1 erofs-utils: lib: actually skip the unidentified xattrs
parse_one_xattr() will return null if it detects unidentified xattr. In such cases we need to skip this xattr which was our intention than try to add it in erofs_xattr_add() which results in null pointer dereference.
--- lib/xattr.c | 3 +++ 1 file changed, 3 insertions(+)
lib/xattr.c +3 -0
@@ -448,6 +448,9 @@ static int read_xattrs_from_file(const char *path, mode_t mode, ret =PTR_ERR (item); goto err; } +/* skip unidentified xattrs */ +if (!item) +continue ; ret =erofs_xattr_add (ixattrs, item);if (ret <0 )
Signature · 1 line
2.46.0.184.g6999bdac58-goog
Gao Xiang
AppliedRe: [PATCH 1/1] erofs-utils: lib: actually skip the unidentified xattrs
Quoted 7 lines · Sandeep Dhavale
parse_one_xattr()will return null if it detects unidentified xattr. In such cases we need to skip this xattr which was our intention than try to add it inerofs_xattr_add()which results in null pointer dereference.Fixes 3037f8958f3b ("erofs-utils: skip all unidentified xattrs from local paths")Signed-off-by Sandeep Dhavale <[email protected]>
Thanks, applied.
Thanks,
Gao Xiang