udf: fix udf_readdir() to not loop on corrupted entry
Subsystems (2)
Jan Kara
reviewerPATCH 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.
Reported-by Scott Carter <[email protected]>
Link https://lore.kernel.org/all/CA+UmNqbcPPegp=x8rsV8t3mbOsseknKo54=fsru6gb3PQjg+Dw@mail.gmail.com open here
Signed-off-by Jan Kara <[email protected]>
--- 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
@@ -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