Re: [PATCH v1] xfs: prevent readdir infinite loop with billions subdirs

From: Christoph Hellwig
Date: Mon Aug 11 2025 - 06:37:56 EST


On Fri, Aug 01, 2025 at 04:41:46PM +0800, liuhuan01@xxxxxxxxxx wrote:
> From: liuh <liuhuan01@xxxxxxxxxx>
>
> When a directory contains billions subdirs, readdir() repeatedly
> got same data and goes to infinate loop.
> The root cause is that the pos gets truncated during assignment.
> Fix it.

This got added in:

15440319767942a363f282d6585303d3d75088ba
Author: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Thu Jan 8 14:00:00 2009 -0500

[XFS] truncate readdir offsets to signed 32 bit values

I promised to come up with something better back them, but I could for
the fear of my life not remember what that would be.

I guess the most compatible thing we could do would be to make the
truncation dependent on is_compat_task(). You'd still get the same
issue on 32-bit systems, but I don't really see what else we could
do for them.