mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
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 commitb9b588f22a("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:
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user