fsck.erofs: fix xattr verification being skipped during extraction
PATCH 1/1 fsck.erofs: fix xattr verification being skipped during extraction
When fsck.erofs is invoked with both --extract and --xattrs, erofs_verify_xattr() is currently skipped due to a logic error:
if (!(fsckcfg.check_decomp && fsckcfg.dump_xattrs))
erofs_verify_xattr(&inode);This means xattr integrity is never verified when the user requests xattr extraction, which defeats the purpose of the check.
Additionally, erofsfsck_dump_xattrs() is unnecessarily gated on check_decomp, so --xattrs has no effect unless --check is also passed, which is wrong.
Fix by always running erofs_verify_xattr() unconditionally, and decouple erofsfsck_dump_xattrs() from check_decomp so that --xattrs works correctly in both extraction and dump-only modes.
The ordering is preserved: file creation, then xattr application, then permission/ownership restoration via erofsfsck_set_attributes().
--- fsck/main.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
fsck/main.c +6 -7
@@ -990,18 +990,17 @@ static int erofsfsck_check_inode(erofs_nid_t pnid, erofs_nid_t nid) goto out; } -if (!(fsckcfg.check_decomp && fsckcfg.dump_xattrs)) { -/* verify xattr field */ - ret =erofs_verify_xattr (&inode); -if (ret) - goto out; - } +/* always verify xattr integrity regardless of dump mode */ + ret =erofs_verify_xattr (&inode); +if (ret) + goto out; ret =erofsfsck_extract_inode (&inode);if (ret && ret != -ECANCELED ) goto out; -if (fsckcfg.check_decomp && fsckcfg.dump_xattrs) { +/* apply xattrs after file creation but before permission restoration */ +if (fsckcfg.dump_xattrs) { ret =erofsfsck_dump_xattrs (&inode);if (ret)return ret;
Signature · 1 line
2.43.0