From: Utkal Singh <singhutkal015@gmail.com>
To: linux-erofs@lists.ozlabs.org
Cc: hsiangkao@linux.alibaba.com, yifan.yfzhao@foxmail.com,
Utkal Singh <singhutkal015@gmail.com>
Subject: [PATCH] fsck.erofs: fix xattr verification being skipped during extraction
Date: Mon, 16 Mar 2026 19:45:51 +0000 [thread overview]
Message-ID: <20260316194551.32141-1-singhutkal015@gmail.com> (raw)
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@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
reply other threads:[~2026-03-16 19:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260316194551.32141-1-singhutkal015@gmail.com \
--to=singhutkal015@gmail.com \
--cc=hsiangkao@linux.alibaba.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=yifan.yfzhao@foxmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox