[PATCH] fsck.erofs: fix xattr verification being skipped during extraction
Utkal Singh
singhutkal015 at gmail.com
Tue Mar 17 06:45:51 AEDT 2026
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().
Signed-off-by: Utkal Singh <singhutkal015 at gmail.com>
---
fsck/main.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/fsck/main.c b/fsck/main.c
index cf07829..1d50aed 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -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;
--
2.43.0
More information about the Linux-erofs
mailing list