Skip to contentSkip to conversation

udf: fix udf_readdir() to not loop on corrupted entry

PATCH New Jan Kara 1 participant 1 message Nov 13

Subsystems (2)
lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

PATCH 1/1 udf: fix udf_readdir() to not loop on corrupted entry

When UDF directory entry is invalid, udf_fiiter_advance() will first update iter->pos to point to it and then report error. However udf_readdir() will not store iter->pos to ctx->pos in this case and hence next udf_readdir() call will again emit the last correct directory entry and fail again thus looping indefinitely. Store the current position in ctx->pos whenever it was determined as valid, even if the current entry is corrupted to ensure progress beyond the last correct entry.

---
 fs/udf/dir.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

- I plan to merge this fix through my tree

fs/udf/dir.c +1 -3
index 425e3c162935..12869b19acfa 100644
@@ -115,10 +115,8 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
 			goto out_iter;
 	}
 
-	if (!ret) {
+	if (pos_valid)
 		ctx->pos = (iter.pos >> 2) + 1;
-		pos_valid = true;
-	}
 out_iter:
 	udf_fiiter_release(&iter);
 out:
Signature · 1 line
2.53.0