From: Vansh Choudhary <ch@vnsh.in>
To: linux-erofs@lists.ozlabs.org
Subject: [PATCH] erofs-utils: lib: check NULL from erofs_rebuild_get_dentry()
Date: Mon, 20 Apr 2026 23:17:52 +0530 [thread overview]
Message-ID: <20260420174752.50132-1-ch@vnsh.in> (raw)
erofs_rebuild_get_dentry() returns NULL when the input path
normalizes to nothing (".", "/", "//", or paths that collapse via
".."). The tar hardlink branch and the S3 import loop only check
IS_ERR() and then dereference the result.
Reject a hardlink target that resolves to root with -EISDIR, and
treat a root-normalized S3 key as the root inode itself.
Fixes: 95d315fd7958 ("erofs-utils: introduce tarerofs")
Fixes: 29728ba8f6f6 ("erofs-utils: mkfs: support EROFS meta-only image generation from S3")
Signed-off-by: Vansh Choudhary <ch@vnsh.in>
---
lib/remotes/s3.c | 5 ++++-
lib/tar.c | 4 ++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/remotes/s3.c b/lib/remotes/s3.c
index e552ed0..d386a32 100644
--- a/lib/remotes/s3.c
+++ b/lib/remotes/s3.c
@@ -1129,7 +1129,10 @@ int s3erofs_build_trees(struct erofs_importer *im, struct erofs_s3 *s3,
ret = PTR_ERR(d);
goto err_iter;
}
- if (d->type == EROFS_FT_DIR) {
+ if (!d) {
+ inode = root;
+ inode->i_mode = S_IFDIR | 0755;
+ } else if (d->type == EROFS_FT_DIR) {
inode = d->inode;
inode->i_mode = S_IFDIR | 0755;
} else {
diff --git a/lib/tar.c b/lib/tar.c
index d2dc141..b08bd77 100644
--- a/lib/tar.c
+++ b/lib/tar.c
@@ -1024,6 +1024,10 @@ out_eot:
ret = PTR_ERR(d2);
goto out;
}
+ if (!d2) {
+ ret = -EISDIR;
+ goto out;
+ }
if (d2->type == EROFS_FT_UNKNOWN) {
ret = -ENOENT;
goto out;
--
2.43.0
next reply other threads:[~2026-04-20 17:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 17:47 Vansh Choudhary [this message]
2026-04-21 2:16 ` [PATCH] erofs-utils: lib: check NULL from erofs_rebuild_get_dentry() Gao Xiang
2026-04-21 17:23 ` [PATCH] erofs-utils: tests: add test for hardlink-to-root tar entries Vansh Choudhary
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=20260420174752.50132-1-ch@vnsh.in \
--to=ch@vnsh.in \
--cc=linux-erofs@lists.ozlabs.org \
/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