Skip to content

Commit af08926

Browse files
YuezhangMogregkh
authored andcommitted
exfat: fix the infinite loop in exfat_find_last_cluster()
[ Upstream commit b0522303f67255926b946aa66885a0104d1b2980 ] 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: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=f7d147e6db52b1e09dba Tested-by: [email protected] Fixes: 3102386 ("exfat: add fat entry operations") Signed-off-by: Yuezhang Mo <[email protected]> Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent c6b6b8d commit af08926

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/exfat/fatent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ int exfat_find_last_cluster(struct super_block *sb, struct exfat_chain *p_chain,
265265
clu = next;
266266
if (exfat_ent_get(sb, clu, &next))
267267
return -EIO;
268-
} while (next != EXFAT_EOF_CLUSTER);
268+
} while (next != EXFAT_EOF_CLUSTER && count <= p_chain->size);
269269

270270
if (p_chain->size != count) {
271271
exfat_fs_error(sb,

0 commit comments

Comments
 (0)