Skip to contentSkip to conversation

erofs-utils: lib: fix incorrect big pcluster judgment

PATCH New Gao Xiang 1 participant 2 messages Sep 27, 2025 Library code

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/2 erofs-utils: lib: fix incorrect big pcluster judgment

params->pclusterblks_max should be greater than 1.

Fixes 0d0aa8522672 ("erofs-utils: lib: migrate pclustersize configurations")
---
 lib/compress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/compress.c +1 -1
index b4c2d1b..f879d3e 100644
@@ -2130,7 +2130,7 @@ int z_erofs_compress_init(struct erofs_importer *im)
 	 * if big pcluster is enabled, an extra CBLKCNT lcluster index needs
 	 * to be loaded in order to get those compressed block counts.
 	 */
-	if (params->pclusterblks_max) {
+	if (params->pclusterblks_max > 1) {
 		if (pclustersize_max > Z_EROFS_PCLUSTER_MAX_SIZE) {
 			erofs_err("pcluster size (%u blocks) is too large",
 				  params->pclusterblks_max);
Signature · 1 line
2.43.5
author
#1 lore raw

PATCH 2/2 erofs-utils: lib: handle duplicate dirents in incremental builds

Corrupted base images may contain duplicate dirents.

Fixes f64d9d02576b ("erofs-utils: introduce incremental builds")
---
 lib/rebuild.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/rebuild.c +5 -0
index 64779cb..e3c7eb8 100644
@@ -484,6 +484,11 @@ static int erofs_rebuild_basedir_dirent_iter(struct erofs_dir_context *ctx)
 		d->validnid = true;
 		if (!mergedir->whiteouts && erofs_dentry_is_wht(dir->sbi, d))
 			mergedir->whiteouts = true;
+	} else if (__erofs_unlikely(d->validnid)) {
+		/* The base image appears to be corrupted */
+		DBG_BUGON(1);
+		ret = -EFSCORRUPTED;
+		goto out;
 	} else {
 		struct erofs_inode *inode = d->inode;
 
Signature · 1 line
2.43.5