From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: linux-erofs@lists.ozlabs.org
Cc: Gao Xiang <hsiangkao@linux.alibaba.com>
Subject: [PATCH] erofs-utils: tar: refuse negative size in tar header
Date: Fri, 17 Jul 2026 11:04:27 +0800 [thread overview]
Message-ID: <20260717030427.1769514-1-hsiangkao@linux.alibaba.com> (raw)
In-Reply-To: <20260716032401.4172874-1-hsiangkao@linux.alibaba.com>
As @oscarjhk reported:
When tar-index mode is used, the inode chunk count will be calculated
as 0 if a crafted GNU base-256 size is UINT64_MAX, which will cause
a heap out-of-bounds write.
Fixes: 95d315fd7958 ("erofs-utils: introduce tarerofs")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
lib/tar.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lib/tar.c b/lib/tar.c
index 242f27ae49fd..cf60b02daf2b 100644
--- a/lib/tar.c
+++ b/lib/tar.c
@@ -886,6 +886,13 @@ out_eot:
goto invalid_tar;
}
+ if ((s64)st.st_size < 0) {
+ erofs_err("invalid negative size=%lld @ %lld",
+ (s64)st.st_size, tar_offset);
+ ret = -EFSCORRUPTED;
+ goto out;
+ }
+
if (th->typeflag <= '7' && !eh.path) {
eh.path = path;
j = 0;
--
2.43.5
prev parent reply other threads:[~2026-07-17 3:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 3:24 [PATCH] erofs-utils: tar: fix overly large size in tar header Gao Xiang
2026-07-17 3:04 ` Gao Xiang [this message]
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=20260717030427.1769514-1-hsiangkao@linux.alibaba.com \
--to=hsiangkao@linux.alibaba.com \
--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