Linux-EROFS Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] erofs-utils: fsck: fix directory loop tracking
@ 2026-03-21 14:28 Vansh Choudhary
  2026-03-21 16:05 ` Nithurshen
  0 siblings, 1 reply; 3+ messages in thread
From: Vansh Choudhary @ 2026-03-21 14:28 UTC (permalink / raw)
  To: linux-erofs; +Cc: Vansh Choudhary

Store the current directory nid in the recursion stack.

The loop check compares inode.nid against the entries already on the
stack, so pushing pnid there can miss self-referential directory loops
and report the wrong failure later.

Signed-off-by: Vansh Choudhary <ch@vnsh.in>
---
 fsck/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fsck/main.c b/fsck/main.c
index 16a354f..3530707 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -1022,7 +1022,7 @@ static int erofsfsck_check_inode(erofs_nid_t pnid, erofs_nid_t nid)
 		for (i = 0; i < fsckcfg.dirstack.top; ++i)
 			if (inode.nid == fsckcfg.dirstack.dirs[i])
 				return -ELOOP;
-		fsckcfg.dirstack.dirs[fsckcfg.dirstack.top++] = pnid;
+		fsckcfg.dirstack.dirs[fsckcfg.dirstack.top++] = inode.nid;
 		ret = erofs_iterate_dir(&ctx, true);
 		--fsckcfg.dirstack.top;
 	}
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] erofs-utils: fsck: fix directory loop tracking
  2026-03-21 14:28 [PATCH] erofs-utils: fsck: fix directory loop tracking Vansh Choudhary
@ 2026-03-21 16:05 ` Nithurshen
  2026-03-22  0:41   ` Gao Xiang
  0 siblings, 1 reply; 3+ messages in thread
From: Nithurshen @ 2026-03-21 16:05 UTC (permalink / raw)
  To: ch; +Cc: linux-erofs, xiang, Nithurshen

Hi Xiang,

This patch LGTM.

I tested the fix by compiling fsck with a debug trace and running
it against an image with a nested directory structure. I verified
that the recursion stack now correctly pushes the current directory's
NID (inode.nid) instead of inheriting the parent's NID, successfully
fixing the loop tracking logic.

Reviewed-by: Nithurshen <nithurshen.dev@gmail.com>
Tested-by: Nithurshen <nithurshen.dev@gmail.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] erofs-utils: fsck: fix directory loop tracking
  2026-03-21 16:05 ` Nithurshen
@ 2026-03-22  0:41   ` Gao Xiang
  0 siblings, 0 replies; 3+ messages in thread
From: Gao Xiang @ 2026-03-22  0:41 UTC (permalink / raw)
  To: Nithurshen, ch; +Cc: linux-erofs, xiang



On 2026/3/22 00:05, Nithurshen wrote:
> Hi Xiang,
> 
> This patch LGTM.
> 
> I tested the fix by compiling fsck with a debug trace and running
> it against an image with a nested directory structure. I verified
> that the recursion stack now correctly pushes the current directory's
> NID (inode.nid) instead of inheriting the parent's NID, successfully
> fixing the loop tracking logic.

Please help work on a testcase too, thanks.

> 
> Reviewed-by: Nithurshen <nithurshen.dev@gmail.com>
> Tested-by: Nithurshen <nithurshen.dev@gmail.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-22  0:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-21 14:28 [PATCH] erofs-utils: fsck: fix directory loop tracking Vansh Choudhary
2026-03-21 16:05 ` Nithurshen
2026-03-22  0:41   ` Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox