]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
exfat: fix the infinite loop in exfat_find_last_cluster()
authorYuezhang Mo <Yuezhang.Mo@sony.com>
Mon, 17 Mar 2025 02:53:10 +0000 (10:53 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:32:02 +0000 (14:32 +0200)
commit52a6316af117aa2e1e944de657ddb13009152d3b
tree522f8609584fde9c164a15cf4345034ed697877a
parent9b76b198cf209797abcb1314c18ddeb90fe0827b
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: syzbot+f7d147e6db52b1e09dba@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=f7d147e6db52b1e09dba
Tested-by: syzbot+f7d147e6db52b1e09dba@syzkaller.appspotmail.com
Fixes: 31023864e67a ("exfat: add fat entry operations")
Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/exfat/fatent.c