Skip to content

Commit

Permalink
exfat: fix the infinite loop in exfat_find_last_cluster()
Browse files Browse the repository at this point in the history
In exfat_find_last_cluster(), the cluster chain is traversed until
the EOF cluster. If the cluster chain includes a loop due to file
system corruption, the EOF cluster cannot be traversed, resulting
in an infinite loop.

If the number of clusters indicated by the file size is inconsistent
with the cluster chain length, exfat_find_last_cluster() will return
an error, so if this inconsistency is found, the traversal can be
aborted without traversing to the EOF cluster.

Reported-by: syzbot+f7d147e6db52b1e09dba@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=f7d147e6db52b1e09dba
Tested-by: syzbot+f7d147e6db52b1e09dba@syzkaller.appspotmail.com
Fixes: 3102386 ("exfat: add fat entry operations")
Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
  • Loading branch information
Yuezhang Mo authored and Namjae Jeon committed Mar 27, 2025
1 parent 1bb7ff4 commit b052230
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/exfat/fatent.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ int exfat_find_last_cluster(struct super_block *sb, struct exfat_chain *p_chain,
clu = next;
if (exfat_ent_get(sb, clu, &next))
return -EIO;
} while (next != EXFAT_EOF_CLUSTER);
} while (next != EXFAT_EOF_CLUSTER && count <= p_chain->size);

if (p_chain->size != count) {
exfat_fs_error(sb,
Expand Down

0 comments on commit b052230

Please sign in to comment.