[syzbot] [exfat?] kernel BUG in iov_iter_revert

18 views
Skip to first unread message

syzbot

unread,
Jan 16, 2024, 11:19:19ā€ÆAMJan 16
to linki...@kernel.org, linux-...@vger.kernel.org, linux-...@vger.kernel.org, sj155...@samsung.com, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 052d534373b7 Merge tag 'exfat-for-6.8-rc1' of git://git.ke..
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=108ca8b3e80000
kernel config: https://syzkaller.appspot.com/x/.config?x=7c8840a4a09eab8
dashboard link: https://syzkaller.appspot.com/bug?extid=fd404f6b03a58e8bc403
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1558210be80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14d39debe80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/b1b0ffd73481/disk-052d5343.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/c25614b900ba/vmlinux-052d5343.xz
kernel image: https://storage.googleapis.com/syzbot-assets/7dd1842e2ad4/bzImage-052d5343.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/291ad1624ec1/mount_3.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+fd404f...@syzkaller.appspotmail.com

------------[ cut here ]------------
kernel BUG at lib/iov_iter.c:582!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 5043 Comm: syz-executor166 Not tainted 6.7.0-syzkaller-09928-g052d534373b7 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
RIP: 0010:iov_iter_revert lib/iov_iter.c:582 [inline]
RIP: 0010:iov_iter_revert+0x328/0x360 lib/iov_iter.c:567
Code: 8e 94 78 fd e9 8f fd ff ff e8 e4 94 78 fd e9 de fe ff ff e8 ba 94 78 fd eb a2 e8 d3 94 78 fd e9 12 fe ff ff e8 b9 8c 21 fd 90 <0f> 0b e8 c1 94 78 fd e9 23 fe ff ff e8 b7 94 78 fd e9 64 fe ff ff
RSP: 0018:ffffc9000337f9e0 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 00000000001bca00 RCX: ffffffff84656a77
RDX: ffff888019313b80 RSI: ffffffff84656c97 RDI: 0000000000000001
RBP: ffffc9000337fb30 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13: fffffffffffffdef R14: 0000000000000000 R15: ffff888047da8740
FS: 0000555555c9a380(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000056518e8170a8 CR3: 0000000048309000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
exfat_direct_IO+0x320/0x510 fs/exfat/inode.c:538
generic_file_read_iter+0x1dd/0x450 mm/filemap.c:2759
call_read_iter include/linux/fs.h:2079 [inline]
aio_read+0x318/0x4d0 fs/aio.c:1597
__io_submit_one fs/aio.c:1998 [inline]
io_submit_one+0x1480/0x1de0 fs/aio.c:2047
__do_sys_io_submit fs/aio.c:2106 [inline]
__se_sys_io_submit fs/aio.c:2076 [inline]
__x64_sys_io_submit+0x1c3/0x350 fs/aio.c:2076
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xd3/0x250 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7f6eb9491c79
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 61 17 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffdb9c8bf78 EFLAGS: 00000246 ORIG_RAX: 00000000000000d1
RAX: ffffffffffffffda RBX: 00007ffdb9c8bf80 RCX: 00007f6eb9491c79
RDX: 0000000020000540 RSI: 0000000000003f0a RDI: 00007f6eb944a000
RBP: 00007f6eb9506610 R08: 65732f636f72702f R09: 65732f636f72702f
R10: 65732f636f72702f R11: 0000000000000246 R12: 0000000000000001
R13: 00007ffdb9c8c1b8 R14: 0000000000000001 R15: 0000000000000001
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:iov_iter_revert lib/iov_iter.c:582 [inline]
RIP: 0010:iov_iter_revert+0x328/0x360 lib/iov_iter.c:567
Code: 8e 94 78 fd e9 8f fd ff ff e8 e4 94 78 fd e9 de fe ff ff e8 ba 94 78 fd eb a2 e8 d3 94 78 fd e9 12 fe ff ff e8 b9 8c 21 fd 90 <0f> 0b e8 c1 94 78 fd e9 23 fe ff ff e8 b7 94 78 fd e9 64 fe ff ff
RSP: 0018:ffffc9000337f9e0 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 00000000001bca00 RCX: ffffffff84656a77
RDX: ffff888019313b80 RSI: ffffffff84656c97 RDI: 0000000000000001
RBP: ffffc9000337fb30 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13: fffffffffffffdef R14: 0000000000000000 R15: ffff888047da8740
FS: 0000555555c9a380(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f6eb944a000 CR3: 0000000048309000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Jan 17, 2024, 1:14:05ā€ÆAMJan 17
to Yuezh...@sony.com, and...@sony.com, linki...@kernel.org, linux-...@vger.kernel.org, linux-...@vger.kernel.org, sj155...@samsung.com, syzkall...@googlegroups.com, wataru...@sony.com, yuezh...@sony.com
syzbot has bisected this issue to:

commit 11a347fb6cef62ce47e84b97c45f2b2497c7593b
Author: Yuezhang Mo <Yuezh...@sony.com>
Date: Mon Mar 13 04:38:53 2023 +0000

exfat: change to get file size from DataLength

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=12bd5ba3e80000
start commit: 052d534373b7 Merge tag 'exfat-for-6.8-rc1' of git://git.ke..
git tree: upstream
final oops: https://syzkaller.appspot.com/x/report.txt?x=11bd5ba3e80000
console output: https://syzkaller.appspot.com/x/log.txt?x=16bd5ba3e80000
Reported-by: syzbot+fd404f...@syzkaller.appspotmail.com
Fixes: 11a347fb6cef ("exfat: change to get file size from DataLength")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

Namjae Jeon

unread,
Jan 17, 2024, 9:15:24ā€ÆAMJan 17
to syzbot, linux-...@vger.kernel.org, linux-...@vger.kernel.org, sj155...@samsung.com, syzkall...@googlegroups.com, Yuezhang.Mo
2024-01-17 1:19 GMT+09:00, syzbot
<syzbot+fd404f...@syzkaller.appspotmail.com>:
> Hello,
Hi,
>
> syzbot found the following issue on:
>
> HEAD commit: 052d534373b7 Merge tag 'exfat-for-6.8-rc1' of
> git://git.ke..
> git tree: upstream
> console+strace: https://syzkaller.appspot.com/x/log.txt?x=108ca8b3e80000
> kernel config: https://syzkaller.appspot.com/x/.config?x=7c8840a4a09eab8
> dashboard link:
> https://syzkaller.appspot.com/bug?extid=fd404f6b03a58e8bc403
> compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for
> Debian) 2.40
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1558210be80000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14d39debe80000

Thanks for your report!
Can you test if this change fix this issue ?

diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c
index 522edcbb2ce4..65ac7b67c2da 100644
--- a/fs/exfat/inode.c
+++ b/fs/exfat/inode.c
@@ -501,7 +501,7 @@ static ssize_t exfat_direct_IO(struct kiocb *iocb,
struct iov_iter *iter)
struct inode *inode = mapping->host;
struct exfat_inode_info *ei = EXFAT_I(inode);
loff_t pos = iocb->ki_pos;
- loff_t size = iocb->ki_pos + iov_iter_count(iter);
+ loff_t size = pos + iov_iter_count(iter);
int rw = iov_iter_rw(iter);
ssize_t ret;

@@ -525,11 +525,9 @@ static ssize_t exfat_direct_IO(struct kiocb
*iocb, struct iov_iter *iter)
*/
ret = blockdev_direct_IO(iocb, inode, iter, exfat_get_block);
if (ret < 0) {
- if (rw == WRITE)
+ if (rw == WRITE && ret != -EIOCBQUEUED)
exfat_write_failed(mapping, size);
-
- if (ret != -EIOCBQUEUED)
- return ret;
+ return ret;
} else
size = pos + ret;

--
2.25.1

Edward Adam Davis

unread,
Jan 19, 2024, 12:51:47ā€ÆAMJan 19
to syzbot+fd404f...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
please test kernel BUG in iov_iter_revert

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 052d534373b7

diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c
index 522edcbb2ce4..af8870145f67 100644
--- a/fs/exfat/inode.c
+++ b/fs/exfat/inode.c
@@ -534,7 +534,8 @@ static ssize_t exfat_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
size = pos + ret;

/* zero the unwritten part in the partially written block */
- if (rw == READ && pos < ei->valid_size && ei->valid_size < size) {
+ if (ret == -EIOCBQUEUED && rw == READ && pos < ei->valid_size &&
+ ei->valid_size < size) {
iov_iter_revert(iter, size - ei->valid_size);
iov_iter_zero(size - ei->valid_size, iter);
}

syzbot

unread,
Jan 19, 2024, 6:04:04ā€ÆAMJan 19
to ead...@qq.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot tried to test the proposed patch but the build/boot failed:

failed to checkout kernel repo https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git on commit 052d534373b7: failed to run ["git" "fetch" "--force" "--tags" "4d52a57a3858a6eee0d0b25cc3a0c9533f747d8f" "052d534373b7"]: exit status 128
fatal: couldn't find remote ref 052d534373b7



Tested on:

commit: [unknown
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 052d534373b7
patch: https://syzkaller.appspot.com/x/patch.diff?x=147423afe80000

Namjae Jeon

unread,
Jan 19, 2024, 7:34:09ā€ÆAMJan 19
to syzbot, ead...@qq.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
2024-01-19 20:04 GMT+09:00, syzbot
<syzbot+fd404f...@syzkaller.appspotmail.com>:
> Hello,
>
> syzbot tried to test the proposed patch but the build/boot failed:
We already have a patch to fix this.

https://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/exfat.git/commit/?h=dev

Thanks.

Edward Adam Davis

unread,
Jan 19, 2024, 8:10:50ā€ÆAMJan 19
to syzbot+fd404f...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
please test kernel BUG in iov_iter_revert

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

syzbot

unread,
Jan 19, 2024, 8:52:05ā€ÆAMJan 19
to ead...@qq.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
kernel BUG in iov_iter_revert

------------[ cut here ]------------
kernel BUG at lib/iov_iter.c:582!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 5472 Comm: syz-executor.0 Not tainted 6.7.0-syzkaller-12377-g9d1694dc91ce-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
RIP: 0010:iov_iter_revert lib/iov_iter.c:582 [inline]
RIP: 0010:iov_iter_revert+0x328/0x360 lib/iov_iter.c:567
Code: ee 64 78 fd e9 8f fd ff ff e8 44 65 78 fd e9 de fe ff ff e8 1a 65 78 fd eb a2 e8 33 65 78 fd e9 12 fe ff ff e8 29 01 21 fd 90 <0f> 0b e8 21 65 78 fd e9 23 fe ff ff e8 17 65 78 fd e9 64 fe ff ff
RSP: 0018:ffffc9000383f9e8 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 00000000001bca00 RCX: ffffffff846606e7
RDX: ffff8880293ebb80 RSI: ffffffff84660907 RDI: 0000000000000001
RBP: ffffc9000383fb30 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13: fffffffffffffdef R14: 0000000000000000 R15: ffff8880696100b8
FS: 00007f2828b046c0(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055c48c0150f8 CR3: 000000001632c000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
exfat_direct_IO+0x310/0x4d0 fs/exfat/inode.c:539
generic_file_read_iter+0x1dd/0x450 mm/filemap.c:2759
call_read_iter include/linux/fs.h:2079 [inline]
aio_read+0x318/0x4d0 fs/aio.c:1597
__io_submit_one fs/aio.c:1998 [inline]
io_submit_one+0x1480/0x1de0 fs/aio.c:2047
__do_sys_io_submit fs/aio.c:2106 [inline]
__se_sys_io_submit fs/aio.c:2076 [inline]
__x64_sys_io_submit+0x1c3/0x350 fs/aio.c:2076
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xd3/0x250 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7f2827e7cda9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f2828b040c8 EFLAGS: 00000246 ORIG_RAX: 00000000000000d1
RAX: ffffffffffffffda RBX: 00007f2827fabf80 RCX: 00007f2827e7cda9
RDX: 0000000020000540 RSI: 0000000000003f0a RDI: 00007f2828ae3000
RBP: 00007f2827ec947a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f2827fabf80 R15: 00007ffe01c6a068
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:iov_iter_revert lib/iov_iter.c:582 [inline]
RIP: 0010:iov_iter_revert+0x328/0x360 lib/iov_iter.c:567
Code: ee 64 78 fd e9 8f fd ff ff e8 44 65 78 fd e9 de fe ff ff e8 1a 65 78 fd eb a2 e8 33 65 78 fd e9 12 fe ff ff e8 29 01 21 fd 90 <0f> 0b e8 21 65 78 fd e9 23 fe ff ff e8 17 65 78 fd e9 64 fe ff ff
RSP: 0018:ffffc9000383f9e8 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 00000000001bca00 RCX: ffffffff846606e7
RDX: ffff8880293ebb80 RSI: ffffffff84660907 RDI: 0000000000000001
RBP: ffffc9000383fb30 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13: fffffffffffffdef R14: 0000000000000000 R15: ffff8880696100b8
FS: 00007f2828b046c0(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ffc103cff58 CR3: 000000001632c000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


Tested on:

commit: 9d1694dc Merge tag 'for-6.8/block-2024-01-18' of git:/..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=11f6a1b3e80000
kernel config: https://syzkaller.appspot.com/x/.config?x=bf191e33072146e3
dashboard link: https://syzkaller.appspot.com/bug?extid=fd404f6b03a58e8bc403
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=12ffb3afe80000

Reply all
Reply to author
Forward
0 new messages