2023-09-13 12:24:07

by syzbot

[permalink] [raw]
Subject: [syzbot] [io-uring?] UBSAN: array-index-out-of-bounds in io_setup_async_msg

Hello,

syzbot found the following issue on:

HEAD commit: 0bb80ecc33a8 Linux 6.6-rc1
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=12d1eb78680000
kernel config: https://syzkaller.appspot.com/x/.config?x=f4894cf58531f
dashboard link: https://syzkaller.appspot.com/bug?extid=a4c6e5ef999b68b26ed1
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=16613002680000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13912e30680000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/eeb0cac260c7/disk-0bb80ecc.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/a3c360110254/vmlinux-0bb80ecc.xz
kernel image: https://storage.googleapis.com/syzbot-assets/22b81065ba5f/bzImage-0bb80ecc.xz

The issue was bisected to:

commit 2af89abda7d9c2aeb573677e2c498ddb09f8058a
Author: Pavel Begunkov <[email protected]>
Date: Thu Aug 24 22:53:32 2023 +0000

io_uring: add option to remove SQ indirection

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=15892e30680000
final oops: https://syzkaller.appspot.com/x/report.txt?x=17892e30680000
console output: https://syzkaller.appspot.com/x/log.txt?x=13892e30680000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]
Fixes: 2af89abda7d9 ("io_uring: add option to remove SQ indirection")

================================================================================
UBSAN: array-index-out-of-bounds in io_uring/net.c:189:55
index 3779567444058 is out of range for type 'iovec [8]'
CPU: 1 PID: 5039 Comm: syz-executor396 Not tainted 6.6.0-rc1-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/04/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x125/0x1b0 lib/dump_stack.c:106
ubsan_epilogue lib/ubsan.c:217 [inline]
__ubsan_handle_out_of_bounds+0x111/0x150 lib/ubsan.c:348
io_setup_async_msg+0x2a0/0x2b0 io_uring/net.c:189
io_recvmsg+0x169f/0x2170 io_uring/net.c:781
io_issue_sqe+0x54a/0xd80 io_uring/io_uring.c:1878
io_queue_sqe io_uring/io_uring.c:2063 [inline]
io_submit_sqe io_uring/io_uring.c:2323 [inline]
io_submit_sqes+0x96c/0x1ed0 io_uring/io_uring.c:2438
__do_sys_io_uring_enter+0x14ea/0x2650 io_uring/io_uring.c:3647
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f8af8d7c4e9
Code: 48 83 c4 28 c3 e8 37 17 00 00 0f 1f 80 00 00 00 00 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:00007fff24b82fa8 EFLAGS: 00000246 ORIG_RAX: 00000000000001aa
RAX: ffffffffffffffda RBX: 0000000000001592 RCX: 00007f8af8d7c4e9
RDX: 0000000000000000 RSI: 0000000000007689 RDI: 0000000000000003
RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00007fff24b83188 R14: 0000000000000001 R15: 0000000000000001
</TASK>
================================================================================


---
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 [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection

If the bug is already fixed, 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 bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

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

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


2023-09-13 15:35:31

by Pavel Begunkov

[permalink] [raw]
Subject: Re: [syzbot] [io-uring?] UBSAN: array-index-out-of-bounds in io_setup_async_msg

On 9/13/23 13:11, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 0bb80ecc33a8 Linux 6.6-rc1
> git tree: upstream
> console+strace: https://syzkaller.appspot.com/x/log.txt?x=12d1eb78680000
> kernel config: https://syzkaller.appspot.com/x/.config?x=f4894cf58531f
> dashboard link: https://syzkaller.appspot.com/bug?extid=a4c6e5ef999b68b26ed1
> 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=16613002680000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13912e30680000
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/eeb0cac260c7/disk-0bb80ecc.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/a3c360110254/vmlinux-0bb80ecc.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/22b81065ba5f/bzImage-0bb80ecc.xz
>
> The issue was bisected to:
>
> commit 2af89abda7d9c2aeb573677e2c498ddb09f8058a
> Author: Pavel Begunkov <[email protected]>
> Date: Thu Aug 24 22:53:32 2023 +0000
>
> io_uring: add option to remove SQ indirection
>
> bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=15892e30680000
> final oops: https://syzkaller.appspot.com/x/report.txt?x=17892e30680000
> console output: https://syzkaller.appspot.com/x/log.txt?x=13892e30680000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: [email protected]
> Fixes: 2af89abda7d9 ("io_uring: add option to remove SQ indirection")
>
> ================================================================================
> UBSAN: array-index-out-of-bounds in io_uring/net.c:189:55
> index 3779567444058 is out of range for type 'iovec [8]'
> CPU: 1 PID: 5039 Comm: syz-executor396 Not tainted 6.6.0-rc1-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/04/2023
> Call Trace:
> <TASK>
> __dump_stack lib/dump_stack.c:88 [inline]
> dump_stack_lvl+0x125/0x1b0 lib/dump_stack.c:106
> ubsan_epilogue lib/ubsan.c:217 [inline]
> __ubsan_handle_out_of_bounds+0x111/0x150 lib/ubsan.c:348
> io_setup_async_msg+0x2a0/0x2b0 io_uring/net.c:189

Which is

/* if were using fast_iov, set it to the new one */
if (iter_is_iovec(&kmsg->msg.msg_iter) && !kmsg->free_iov) {
size_t fast_idx = iter_iov(&kmsg->msg.msg_iter) - kmsg->fast_iov;
async_msg->msg.msg_iter.__iov = &async_msg->fast_iov[fast_idx];
}

The bisection doesn't immediately make sense, I'll try
it out

--
Pavel Begunkov

2023-09-14 14:58:16

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] [io-uring?] UBSAN: array-index-out-of-bounds in io_setup_async_msg

Hello,

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

failed to checkout kernel repo https://github.com/isilence/linux.git/netmsg-init-base: failed to run ["git" "fetch" "--force" "2335d1373be159a02254ea7a962dfc5bc7a540d3" "netmsg-init-base"]: exit status 128
fatal: couldn't find remote ref netmsg-init-base



Tested on:

commit: [unknown
git tree: https://github.com/isilence/linux.git netmsg-init-base
kernel config: https://syzkaller.appspot.com/x/.config?x=f4894cf58531f
dashboard link: https://syzkaller.appspot.com/bug?extid=a4c6e5ef999b68b26ed1
compiler:

Note: no patches were applied.

2023-09-14 15:07:05

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] [io-uring?] UBSAN: array-index-out-of-bounds in io_setup_async_msg

Hello,

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

failed to checkout kernel repo https://github.com/isilence/linux.git/netmsg-init: failed to run ["git" "fetch" "--force" "2335d1373be159a02254ea7a962dfc5bc7a540d3" "netmsg-init"]: exit status 128
fatal: couldn't find remote ref netmsg-init



Tested on:

commit: [unknown
git tree: https://github.com/isilence/linux.git netmsg-init
kernel config: https://syzkaller.appspot.com/x/.config?x=f4894cf58531f
dashboard link: https://syzkaller.appspot.com/bug?extid=a4c6e5ef999b68b26ed1
compiler:

Note: no patches were applied.

2023-09-14 15:34:23

by Pavel Begunkov

[permalink] [raw]
Subject: Re: [syzbot] [io-uring?] UBSAN: array-index-out-of-bounds in io_setup_async_msg

On 9/13/23 14:10, Pavel Begunkov wrote:
> On 9/13/23 13:11, syzbot wrote:
>> Hello,
>>
>> syzbot found the following issue on:
>>
>> HEAD commit:    0bb80ecc33a8 Linux 6.6-rc1
>> git tree:       upstream
>> console+strace: https://syzkaller.appspot.com/x/log.txt?x=12d1eb78680000
>> kernel config:  https://syzkaller.appspot.com/x/.config?x=f4894cf58531f
>> dashboard link: https://syzkaller.appspot.com/bug?extid=a4c6e5ef999b68b26ed1
>> 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=16613002680000
>> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=13912e30680000
>>
>> Downloadable assets:
>> disk image: https://storage.googleapis.com/syzbot-assets/eeb0cac260c7/disk-0bb80ecc.raw.xz
>> vmlinux: https://storage.googleapis.com/syzbot-assets/a3c360110254/vmlinux-0bb80ecc.xz
>> kernel image: https://storage.googleapis.com/syzbot-assets/22b81065ba5f/bzImage-0bb80ecc.xz
>>
>> The issue was bisected to:
>>
>> commit 2af89abda7d9c2aeb573677e2c498ddb09f8058a
>> Author: Pavel Begunkov <[email protected]>
>> Date:   Thu Aug 24 22:53:32 2023 +0000
>>
>>      io_uring: add option to remove SQ indirection
>>
>> bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=15892e30680000
>> final oops:     https://syzkaller.appspot.com/x/report.txt?x=17892e30680000
>> console output: https://syzkaller.appspot.com/x/log.txt?x=13892e30680000
>>
>> IMPORTANT: if you fix the issue, please add the following tag to the commit:
>> Reported-by: [email protected]
>> Fixes: 2af89abda7d9 ("io_uring: add option to remove SQ indirection")
>>
>> ================================================================================
>> UBSAN: array-index-out-of-bounds in io_uring/net.c:189:55
>> index 3779567444058 is out of range for type 'iovec [8]'
>> CPU: 1 PID: 5039 Comm: syz-executor396 Not tainted 6.6.0-rc1-syzkaller #0
>> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/04/2023
>> Call Trace:
>>   <TASK>
>>   __dump_stack lib/dump_stack.c:88 [inline]
>>   dump_stack_lvl+0x125/0x1b0 lib/dump_stack.c:106
>>   ubsan_epilogue lib/ubsan.c:217 [inline]
>>   __ubsan_handle_out_of_bounds+0x111/0x150 lib/ubsan.c:348
>>   io_setup_async_msg+0x2a0/0x2b0 io_uring/net.c:189
>
> Which is
>
> /* if were using fast_iov, set it to the new one */
> if (iter_is_iovec(&kmsg->msg.msg_iter) && !kmsg->free_iov) {
>     size_t fast_idx = iter_iov(&kmsg->msg.msg_iter) - kmsg->fast_iov;
>     async_msg->msg.msg_iter.__iov = &async_msg->fast_iov[fast_idx];
> }
>
> The bisection doesn't immediately make sense, I'll try
> it out

#syz test: https://github.com/isilence/linux.git netmsg-init-base

First just test upstream because I'm curious about reproducibility


--
Pavel Begunkov

2023-09-14 15:49:57

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] [io-uring?] UBSAN: array-index-out-of-bounds in io_setup_async_msg

Hello,

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

Reported-and-tested-by: [email protected]

Tested on:

commit: ff035989 select buf net iter init
git tree: https://github.com/isilence/linux.git syz-test/netmsg-init
console output: https://syzkaller.appspot.com/x/log.txt?x=13421bbfa80000
kernel config: https://syzkaller.appspot.com/x/.config?x=f4894cf58531f
dashboard link: https://syzkaller.appspot.com/bug?extid=a4c6e5ef999b68b26ed1
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40

Note: no patches were applied.
Note: testing is done by a robot and is best-effort only.

2023-09-14 16:08:20

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] [io-uring?] UBSAN: array-index-out-of-bounds in io_setup_async_msg

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
UBSAN: array-index-out-of-bounds in io_setup_async_msg

================================================================================
UBSAN: array-index-out-of-bounds in io_uring/net.c:189:55
index 3779565697114 is out of range for type 'iovec [8]'
CPU: 1 PID: 5467 Comm: syz-executor.0 Not tainted 6.6.0-rc1-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/04/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x125/0x1b0 lib/dump_stack.c:106
ubsan_epilogue lib/ubsan.c:217 [inline]
__ubsan_handle_out_of_bounds+0x111/0x150 lib/ubsan.c:348
io_setup_async_msg+0x2a0/0x2b0 io_uring/net.c:189
io_recvmsg+0x169f/0x2170 io_uring/net.c:781
io_issue_sqe+0x54a/0xd80 io_uring/io_uring.c:1878
io_queue_sqe io_uring/io_uring.c:2063 [inline]
io_submit_sqe io_uring/io_uring.c:2323 [inline]
io_submit_sqes+0x96c/0x1ed0 io_uring/io_uring.c:2438
__do_sys_io_uring_enter+0x14ea/0x2650 io_uring/io_uring.c:3647
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f9a8a27cae9
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:00007f9a8af210c8 EFLAGS: 00000246 ORIG_RAX: 00000000000001aa
RAX: ffffffffffffffda RBX: 00007f9a8a39bf80 RCX: 00007f9a8a27cae9
RDX: 0000000000000000 RSI: 0000000000007689 RDI: 0000000000000003
RBP: 00007f9a8a2c847a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f9a8a39bf80 R15: 00007ffd083c1e58
</TASK>
================================================================================


Tested on:

commit: 0bb80ecc Linux 6.6-rc1
git tree: https://github.com/isilence/linux.git syz-test/netmsg-init-base
console output: https://syzkaller.appspot.com/x/log.txt?x=15ccbf30680000
kernel config: https://syzkaller.appspot.com/x/.config?x=f4894cf58531f
dashboard link: https://syzkaller.appspot.com/bug?extid=a4c6e5ef999b68b26ed1
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40

Note: no patches were applied.

2023-09-14 16:17:57

by Pavel Begunkov

[permalink] [raw]
Subject: Re: [syzbot] [io-uring?] UBSAN: array-index-out-of-bounds in io_setup_async_msg

On 9/14/23 15:06, Pavel Begunkov wrote:
> On 9/13/23 14:10, Pavel Begunkov wrote:
>> On 9/13/23 13:11, syzbot wrote:
>>> Hello,
>>>
>>> syzbot found the following issue on:
>>>
>>> HEAD commit:    0bb80ecc33a8 Linux 6.6-rc1
>>> git tree:       upstream
>>> console+strace: https://syzkaller.appspot.com/x/log.txt?x=12d1eb78680000
>>> kernel config:  https://syzkaller.appspot.com/x/.config?x=f4894cf58531f
>>> dashboard link: https://syzkaller.appspot.com/bug?extid=a4c6e5ef999b68b26ed1
>>> 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=16613002680000
>>> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=13912e30680000
>>>
>>> Downloadable assets:
>>> disk image: https://storage.googleapis.com/syzbot-assets/eeb0cac260c7/disk-0bb80ecc.raw.xz
>>> vmlinux: https://storage.googleapis.com/syzbot-assets/a3c360110254/vmlinux-0bb80ecc.xz
>>> kernel image: https://storage.googleapis.com/syzbot-assets/22b81065ba5f/bzImage-0bb80ecc.xz
>>>
>>> The issue was bisected to:
>>>
>>> commit 2af89abda7d9c2aeb573677e2c498ddb09f8058a
>>> Author: Pavel Begunkov <[email protected]>
>>> Date:   Thu Aug 24 22:53:32 2023 +0000
>>>
>>>      io_uring: add option to remove SQ indirection
>>>
>>> bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=15892e30680000
>>> final oops:     https://syzkaller.appspot.com/x/report.txt?x=17892e30680000
>>> console output: https://syzkaller.appspot.com/x/log.txt?x=13892e30680000
>>>
>>> IMPORTANT: if you fix the issue, please add the following tag to the commit:
>>> Reported-by: [email protected]
>>> Fixes: 2af89abda7d9 ("io_uring: add option to remove SQ indirection")
>>>
>>> ================================================================================
>>> UBSAN: array-index-out-of-bounds in io_uring/net.c:189:55
>>> index 3779567444058 is out of range for type 'iovec [8]'
>>> CPU: 1 PID: 5039 Comm: syz-executor396 Not tainted 6.6.0-rc1-syzkaller #0
>>> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/04/2023
>>> Call Trace:
>>>   <TASK>
>>>   __dump_stack lib/dump_stack.c:88 [inline]
>>>   dump_stack_lvl+0x125/0x1b0 lib/dump_stack.c:106
>>>   ubsan_epilogue lib/ubsan.c:217 [inline]
>>>   __ubsan_handle_out_of_bounds+0x111/0x150 lib/ubsan.c:348
>>>   io_setup_async_msg+0x2a0/0x2b0 io_uring/net.c:189
>>
>> Which is
>>
>> /* if were using fast_iov, set it to the new one */
>> if (iter_is_iovec(&kmsg->msg.msg_iter) && !kmsg->free_iov) {
>>      size_t fast_idx = iter_iov(&kmsg->msg.msg_iter) - kmsg->fast_iov;
>>      async_msg->msg.msg_iter.__iov = &async_msg->fast_iov[fast_idx];
>> }
>>
>> The bisection doesn't immediately make sense, I'll try
>> it out
>
> #syz test: https://github.com/isilence/linux.git netmsg-init-base
>
> First just test upstream because I'm curious about reproducibility

Couldn't repro myself, I think this is the fix

#syz test: https://github.com/isilence/linux.git netmsg-init

--
Pavel Begunkov

2023-09-14 21:06:53

by Pavel Begunkov

[permalink] [raw]
Subject: Re: [syzbot] [io-uring?] UBSAN: array-index-out-of-bounds in io_setup_async_msg

On 9/14/23 15:08, Pavel Begunkov wrote:
> On 9/14/23 15:06, Pavel Begunkov wrote:
>> On 9/13/23 14:10, Pavel Begunkov wrote:
>>> On 9/13/23 13:11, syzbot wrote:
>>>> Hello,
>>>>
>>>> syzbot found the following issue on:
>>>>
>>>> HEAD commit:    0bb80ecc33a8 Linux 6.6-rc1
>>>> git tree:       upstream
>>>> console+strace: https://syzkaller.appspot.com/x/log.txt?x=12d1eb78680000
>>>> kernel config:  https://syzkaller.appspot.com/x/.config?x=f4894cf58531f
>>>> dashboard link: https://syzkaller.appspot.com/bug?extid=a4c6e5ef999b68b26ed1
>>>> 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=16613002680000
>>>> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=13912e30680000
>>>>
>>>> Downloadable assets:
>>>> disk image: https://storage.googleapis.com/syzbot-assets/eeb0cac260c7/disk-0bb80ecc.raw.xz
>>>> vmlinux: https://storage.googleapis.com/syzbot-assets/a3c360110254/vmlinux-0bb80ecc.xz
>>>> kernel image: https://storage.googleapis.com/syzbot-assets/22b81065ba5f/bzImage-0bb80ecc.xz
>>>>
>>>> The issue was bisected to:
>>>>
>>>> commit 2af89abda7d9c2aeb573677e2c498ddb09f8058a
>>>> Author: Pavel Begunkov <[email protected]>
>>>> Date:   Thu Aug 24 22:53:32 2023 +0000
>>>>
>>>>      io_uring: add option to remove SQ indirection
>>>>
>>>> bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=15892e30680000
>>>> final oops:     https://syzkaller.appspot.com/x/report.txt?x=17892e30680000
>>>> console output: https://syzkaller.appspot.com/x/log.txt?x=13892e30680000
>>>>
>>>> IMPORTANT: if you fix the issue, please add the following tag to the commit:
>>>> Reported-by: [email protected]
>>>> Fixes: 2af89abda7d9 ("io_uring: add option to remove SQ indirection")
>>>>
>>>> ================================================================================
>>>> UBSAN: array-index-out-of-bounds in io_uring/net.c:189:55
>>>> index 3779567444058 is out of range for type 'iovec [8]'
>>>> CPU: 1 PID: 5039 Comm: syz-executor396 Not tainted 6.6.0-rc1-syzkaller #0
>>>> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/04/2023
>>>> Call Trace:
>>>>   <TASK>
>>>>   __dump_stack lib/dump_stack.c:88 [inline]
>>>>   dump_stack_lvl+0x125/0x1b0 lib/dump_stack.c:106
>>>>   ubsan_epilogue lib/ubsan.c:217 [inline]
>>>>   __ubsan_handle_out_of_bounds+0x111/0x150 lib/ubsan.c:348
>>>>   io_setup_async_msg+0x2a0/0x2b0 io_uring/net.c:189
>>>
>>> Which is
>>>
>>> /* if were using fast_iov, set it to the new one */
>>> if (iter_is_iovec(&kmsg->msg.msg_iter) && !kmsg->free_iov) {
>>>      size_t fast_idx = iter_iov(&kmsg->msg.msg_iter) - kmsg->fast_iov;
>>>      async_msg->msg.msg_iter.__iov = &async_msg->fast_iov[fast_idx];
>>> }
>>>
>>> The bisection doesn't immediately make sense, I'll try
>>> it out
>>
>> #syz test: https://github.com/isilence/linux.git netmsg-init-base
>>
>> First just test upstream because I'm curious about reproducibility
>
> Couldn't repro myself, I think this is the fix

#syz test: https://github.com/isilence/linux.git syz-test/netmsg-init

--
Pavel Begunkov

2023-09-14 22:07:17

by Pavel Begunkov

[permalink] [raw]
Subject: Re: [syzbot] [io-uring?] UBSAN: array-index-out-of-bounds in io_setup_async_msg

On 9/14/23 15:06, Pavel Begunkov wrote:
> On 9/13/23 14:10, Pavel Begunkov wrote:
>> On 9/13/23 13:11, syzbot wrote:
>>> Hello,
>>>
>>> syzbot found the following issue on:
>>>
>>> HEAD commit:    0bb80ecc33a8 Linux 6.6-rc1
>>> git tree:       upstream
>>> console+strace: https://syzkaller.appspot.com/x/log.txt?x=12d1eb78680000
>>> kernel config:  https://syzkaller.appspot.com/x/.config?x=f4894cf58531f
>>> dashboard link: https://syzkaller.appspot.com/bug?extid=a4c6e5ef999b68b26ed1
>>> 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=16613002680000
>>> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=13912e30680000
>>>
>>> Downloadable assets:
>>> disk image: https://storage.googleapis.com/syzbot-assets/eeb0cac260c7/disk-0bb80ecc.raw.xz
>>> vmlinux: https://storage.googleapis.com/syzbot-assets/a3c360110254/vmlinux-0bb80ecc.xz
>>> kernel image: https://storage.googleapis.com/syzbot-assets/22b81065ba5f/bzImage-0bb80ecc.xz
>>>
>>> The issue was bisected to:
>>>
>>> commit 2af89abda7d9c2aeb573677e2c498ddb09f8058a
>>> Author: Pavel Begunkov <[email protected]>
>>> Date:   Thu Aug 24 22:53:32 2023 +0000
>>>
>>>      io_uring: add option to remove SQ indirection
>>>
>>> bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=15892e30680000
>>> final oops:     https://syzkaller.appspot.com/x/report.txt?x=17892e30680000
>>> console output: https://syzkaller.appspot.com/x/log.txt?x=13892e30680000
>>>
>>> IMPORTANT: if you fix the issue, please add the following tag to the commit:
>>> Reported-by: [email protected]
>>> Fixes: 2af89abda7d9 ("io_uring: add option to remove SQ indirection")
>>>
>>> ================================================================================
>>> UBSAN: array-index-out-of-bounds in io_uring/net.c:189:55
>>> index 3779567444058 is out of range for type 'iovec [8]'
>>> CPU: 1 PID: 5039 Comm: syz-executor396 Not tainted 6.6.0-rc1-syzkaller #0
>>> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/04/2023
>>> Call Trace:
>>>   <TASK>
>>>   __dump_stack lib/dump_stack.c:88 [inline]
>>>   dump_stack_lvl+0x125/0x1b0 lib/dump_stack.c:106
>>>   ubsan_epilogue lib/ubsan.c:217 [inline]
>>>   __ubsan_handle_out_of_bounds+0x111/0x150 lib/ubsan.c:348
>>>   io_setup_async_msg+0x2a0/0x2b0 io_uring/net.c:189
>>
>> Which is
>>
>> /* if were using fast_iov, set it to the new one */
>> if (iter_is_iovec(&kmsg->msg.msg_iter) && !kmsg->free_iov) {
>>      size_t fast_idx = iter_iov(&kmsg->msg.msg_iter) - kmsg->fast_iov;
>>      async_msg->msg.msg_iter.__iov = &async_msg->fast_iov[fast_idx];
>> }
>>
>> The bisection doesn't immediately make sense, I'll try
>> it out
>
> #syz test: https://github.com/isilence/linux.git netmsg-init-base
>
> First just test upstream because I'm curious about reproducibility

#syz test: https://github.com/isilence/linux.git syz-test/netmsg-init-base

--
Pavel Begunkov