diff options
| author | Yuezhang Mo <Yuezhang.Mo@sony.com> | 2024-12-13 13:08:37 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-01-17 13:40:35 +0100 |
| commit | d9ea94f5cd117d56e573696d0045ab3044185a15 (patch) | |
| tree | 3afee0a01f00b435203b1a50288fe53c3f88b92c /fs/exfat | |
| parent | 6f153055ba050db2ae3dd932ec51f15adf7a648b (diff) | |
| download | linux-d9ea94f5cd117d56e573696d0045ab3044185a15.tar.gz linux-d9ea94f5cd117d56e573696d0045ab3044185a15.tar.bz2 linux-d9ea94f5cd117d56e573696d0045ab3044185a15.zip | |
exfat: fix the infinite loop in exfat_readdir()
[ Upstream commit fee873761bd978d077d8c55334b4966ac4cb7b59 ]
If the file system is corrupted so that a cluster is linked to
itself in the cluster chain, and there is an unused directory
entry in the cluster, 'dentry' will not be incremented, causing
condition 'dentry < max_dentries' unable to prevent an infinite
loop.
This infinite loop causes s_lock not to be released, and other
tasks will hang, such as exfat_sync_fs().
This commit stops traversing the cluster chain when there is unused
directory entry in the cluster to avoid this infinite loop.
Reported-by: syzbot+205c2644abdff9d3f9fc@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=205c2644abdff9d3f9fc
Tested-by: syzbot+205c2644abdff9d3f9fc@syzkaller.appspotmail.com
Fixes: ca06197382bd ("exfat: add directory operations")
Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/exfat')
| -rw-r--r-- | fs/exfat/dir.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 7446bf09a04a..9d8848872fe8 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -125,7 +125,7 @@ static int exfat_readdir(struct inode *inode, loff_t *cpos, struct exfat_dir_ent type = exfat_get_entry_type(ep); if (type == TYPE_UNUSED) { brelse(bh); - break; + goto out; } if (type != TYPE_FILE && type != TYPE_DIR) { @@ -189,6 +189,7 @@ static int exfat_readdir(struct inode *inode, loff_t *cpos, struct exfat_dir_ent } } +out: dir_entry->namebuf.lfn[0] = '\0'; *cpos = EXFAT_DEN_TO_B(dentry); return 0; |
