Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop in nffs_gc() #19

Open
yashi opened this issue Sep 10, 2019 · 0 comments
Open

Infinite loop in nffs_gc() #19

yashi opened this issue Sep 10, 2019 · 0 comments

Comments

@yashi
Copy link

yashi commented Sep 10, 2019

This is a classic "Do not reorder while traversing a list" bug from the nffs_hash in nffs_gc().

In the while-loop to traverse nffs_hash list in nffs_gc(), we call nffs_gc_inode_blocks(). But nffs_gc_inode_blocks() reorders the given list when GC. If the reorder puts the current node back to previous, then call nffs_gc_inode_blocks() again, it will inf loop.

That is, say we have a list of A->B->C->D. while we are at C, we call nffs_gc_inode_blocks(). The function can reorder the list to A->C->B->D. Now we process B, and call nffs_gc_inode_blocks(). This time the function reorder the list back to to A->B->C->D. The next node is C again. C call the func, and get A->C->B->D. The next is B. Call the func. Get A->B->C->D. Then next is C. And B, and C, B, C, B, C, B, C.... Inf loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant