[PATCH] exfat: check if cluster num is valid

3 views
Skip to first unread message

Tadeusz Struk

unread,
Apr 18, 2022, 1:42:29 PM4/18/22
to tadeus...@linaro.org, syzkaller-a...@googlegroups.com, syzbot+a4087e...@syzkaller.appspotmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

Cc: syzbot+a4087e...@syzkaller.appspotmail.com
==================================================
diff --git a/fs/exfat/balloc.c b/fs/exfat/balloc.c
index 03f142307174..4ed81f86f993 100644
--- a/fs/exfat/balloc.c
+++ b/fs/exfat/balloc.c
@@ -149,6 +149,9 @@ int exfat_set_bitmap(struct inode *inode, unsigned int clu, bool sync)
struct exfat_sb_info *sbi = EXFAT_SB(sb);

WARN_ON(clu < EXFAT_FIRST_CLUSTER);
+ if (clu > EXFAT_DATA_CLUSTER_COUNT(sbi))
+ return -EINVAL;
+
ent_idx = CLUSTER_TO_BITMAP_ENT(clu);
i = BITMAP_OFFSET_SECTOR_INDEX(sb, ent_idx);
b = BITMAP_OFFSET_BIT_IN_SECTOR(sb, ent_idx);
@@ -167,6 +170,9 @@ void exfat_clear_bitmap(struct inode *inode, unsigned int clu, bool sync)
struct exfat_mount_options *opts = &sbi->options;

WARN_ON(clu < EXFAT_FIRST_CLUSTER);
+ if (clu > EXFAT_DATA_CLUSTER_COUNT(sbi))
+ return;
+
ent_idx = CLUSTER_TO_BITMAP_ENT(clu);
i = BITMAP_OFFSET_SECTOR_INDEX(sb, ent_idx);
b = BITMAP_OFFSET_BIT_IN_SECTOR(sb, ent_idx);
--
2.35.1

Tadeusz Struk

unread,
Apr 18, 2022, 1:55:45 PM4/18/22
to tadeus...@linaro.org, syzkaller-a...@googlegroups.com, syzbot+a4087e...@syzkaller.appspotmail.com

syzbot

unread,
Apr 18, 2022, 2:00:15 PM4/18/22
to syzkaller-a...@googlegroups.com, tadeus...@linaro.org
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+a4087e...@syzkaller.appspotmail.com

Tested on:

commit: b2d229d4 Linux 5.18-rc3
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
kernel config: https://syzkaller.appspot.com/x/.config?x=4496d76eece5a74c
dashboard link: https://syzkaller.appspot.com/bug?extid=a4087e40b9c13aad7892
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=10fe12ecf00000

Note: testing is done by a robot and is best-effort only.

syzbot

unread,
Apr 18, 2022, 2:08:09 PM4/18/22
to syzkaller-a...@googlegroups.com, tadeus...@linaro.org
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+a4087e...@syzkaller.appspotmail.com

Tested on:

commit: 0dcfc2c0 ANDROID: GKI: Update symbols to symbol list
git tree: https://android.googlesource.com/kernel/common android12-5.10
kernel config: https://syzkaller.appspot.com/x/.config?x=97fcf0b9b4761f62
dashboard link: https://syzkaller.appspot.com/bug?extid=a4087e40b9c13aad7892
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=14814da4f00000
Reply all
Reply to author
Forward
0 new messages