libfs: end offset readdir at positions past DIR_OFFSET_EOD

offset_dir_llseek() takes any position up to LONG_MAX but
offset_readdir() only skips the walk for DIR_OFFSET_EOD itself. For a
position past it mas_find_rev() starts the walk at the highest offset
in the directory. So an lseek() past the end makes the next
getdents64() return the whole directory again.

Before commit b9b588f22a ("libfs: Use d_children list to iterate
simple_offset directories") the walk went up from the position and
found nothing past the end, and dcache_readdir() returns nothing there
either. So only walk for positions below DIR_OFFSET_EOD.

Fixes: b9b588f22a ("libfs: Use d_children list to iterate simple_offset directories")
Link: https://patch.msgid.link/[email protected]
Reviewed-by: Chuck Lever <[email protected]>
Signed-off-by: Christian Brauner (Amutable) <[email protected]>
This commit is contained in:
Christian Brauner
2026-11-05 15:52:40 +01:00
parent 309f7a5585
commit 45eb973705
+1 -1
View File
@@ -530,7 +530,7 @@ static int offset_readdir(struct file *file, struct dir_context *ctx)
if (!dir_emit_dots(file, ctx))
return 0;
if (ctx->pos != DIR_OFFSET_EOD)
if (ctx->pos < DIR_OFFSET_EOD)
offset_iterate_dir(file, ctx);
return 0;
}