Re: [syzbot] KASAN: out-of-bounds Write in end_buffer_read_sync

From: syzbot
Date: Sat May 07 2022 - 09:27:28 EST


syzbot has found a reproducer for the following issue on:

HEAD commit: 4b97bac0756a Merge tag 'for-5.18-rc5-tag' of git://git.ker..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16ba2e16f00000
kernel config: https://syzkaller.appspot.com/x/.config?x=f179a672dc8535fc
dashboard link: https://syzkaller.appspot.com/bug?extid=3f7f291a3d327486073c
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14a34afef00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=177360b2f00000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+3f7f291a3d327486073c@xxxxxxxxxxxxxxxxxxxxxxxxx

==================================================================
BUG: KASAN: out-of-bounds in instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
BUG: KASAN: out-of-bounds in atomic_dec include/linux/atomic/atomic-instrumented.h:257 [inline]
BUG: KASAN: out-of-bounds in put_bh include/linux/buffer_head.h:284 [inline]
BUG: KASAN: out-of-bounds in end_buffer_read_sync+0x24/0x30 fs/buffer.c:160
Write of size 4 at addr ffffc900035879d8 by task ksoftirqd/3/33

CPU: 3 PID: 33 Comm: ksoftirqd/3 Not tainted 5.18.0-rc5-syzkaller-00163-g4b97bac0756a #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
print_address_description.constprop.0.cold+0xf/0x467 mm/kasan/report.c:313
print_report mm/kasan/report.c:429 [inline]
kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491
check_region_inline mm/kasan/generic.c:183 [inline]
kasan_check_range+0x13d/0x180 mm/kasan/generic.c:189
instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
atomic_dec include/linux/atomic/atomic-instrumented.h:257 [inline]
put_bh include/linux/buffer_head.h:284 [inline]
end_buffer_read_sync+0x24/0x30 fs/buffer.c:160
end_bio_bh_io_sync+0xda/0x130 fs/buffer.c:2999
bio_endio+0x5fe/0x780 block/bio.c:1541
req_bio_endio block/blk-mq.c:686 [inline]
blk_update_request+0x401/0x1310 block/blk-mq.c:815
blk_mq_end_request+0x4b/0x80 block/blk-mq.c:941
lo_complete_rq+0x1c2/0x280 drivers/block/loop.c:369
blk_complete_reqs+0xad/0xe0 block/blk-mq.c:1012
__do_softirq+0x29b/0x9c2 kernel/softirq.c:558
run_ksoftirqd kernel/softirq.c:921 [inline]
run_ksoftirqd+0x2d/0x60 kernel/softirq.c:913
smpboot_thread_fn+0x645/0x9c0 kernel/smpboot.c:164
kthread+0x2e9/0x3a0 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
</TASK>

The buggy address belongs to the virtual mapping at
[ffffc90003580000, ffffc90003589000) created by:
kernel_clone+0xe7/0xab0 kernel/fork.c:2639

------------[ cut here ]------------
kernel BUG at mm/vmalloc.c:660!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 3 PID: 33 Comm: ksoftirqd/3 Not tainted 5.18.0-rc5-syzkaller-00163-g4b97bac0756a #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
RIP: 0010:vmalloc_to_page+0x46e/0x4f0 mm/vmalloc.c:660
Code: c1 ff 4d 31 fc 4d 21 f4 49 c1 ec 0c 4c 01 e3 49 bc 00 00 00 00 00 ea ff ff 48 c1 e3 06 49 01 dc e9 35 ff ff ff e8 d2 d5 c1 ff <0f> 0b e8 cb d5 c1 ff 0f 0b 45 31 e4 e9 1f ff ff ff e8 bc d5 c1 ff
RSP: 0018:ffffc900007cfbe8 EFLAGS: 00010046
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000100
RDX: ffff888011b80200 RSI: ffffffff81b69dfe RDI: 0000000000000003
RBP: ffffffff8ba8e000 R08: 00001ffffffffffe R09: 0000000000000000
R10: ffffffff81b69a16 R11: 0000000000000000 R12: 0000370000000000
R13: 0000000000000000 R14: ffff888011b80200 R15: ffff8880231b6188
FS: 0000000000000000(0000) GS:ffff88802cd00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000562fada51cf8 CR3: 000000001d3dd000 CR4: 0000000000150ee0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
print_address_description.constprop.0.cold+0x2ce/0x467 mm/kasan/report.c:350
print_report mm/kasan/report.c:429 [inline]
kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491
check_region_inline mm/kasan/generic.c:183 [inline]
kasan_check_range+0x13d/0x180 mm/kasan/generic.c:189
instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
atomic_dec include/linux/atomic/atomic-instrumented.h:257 [inline]
put_bh include/linux/buffer_head.h:284 [inline]
end_buffer_read_sync+0x24/0x30 fs/buffer.c:160
end_bio_bh_io_sync+0xda/0x130 fs/buffer.c:2999
bio_endio+0x5fe/0x780 block/bio.c:1541
req_bio_endio block/blk-mq.c:686 [inline]
blk_update_request+0x401/0x1310 block/blk-mq.c:815
blk_mq_end_request+0x4b/0x80 block/blk-mq.c:941
lo_complete_rq+0x1c2/0x280 drivers/block/loop.c:369
blk_complete_reqs+0xad/0xe0 block/blk-mq.c:1012
__do_softirq+0x29b/0x9c2 kernel/softirq.c:558
run_ksoftirqd kernel/softirq.c:921 [inline]
run_ksoftirqd+0x2d/0x60 kernel/softirq.c:913
smpboot_thread_fn+0x645/0x9c0 kernel/smpboot.c:164
kthread+0x2e9/0x3a0 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:vmalloc_to_page+0x46e/0x4f0 mm/vmalloc.c:660
Code: c1 ff 4d 31 fc 4d 21 f4 49 c1 ec 0c 4c 01 e3 49 bc 00 00 00 00 00 ea ff ff 48 c1 e3 06 49 01 dc e9 35 ff ff ff e8 d2 d5 c1 ff <0f> 0b e8 cb d5 c1 ff 0f 0b 45 31 e4 e9 1f ff ff ff e8 bc d5 c1 ff
RSP: 0018:ffffc900007cfbe8 EFLAGS: 00010046
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000100
RDX: ffff888011b80200 RSI: ffffffff81b69dfe RDI: 0000000000000003
RBP: ffffffff8ba8e000 R08: 00001ffffffffffe R09: 0000000000000000
R10: ffffffff81b69a16 R11: 0000000000000000 R12: 0000370000000000
R13: 0000000000000000 R14: ffff888011b80200 R15: ffff8880231b6188
FS: 0000000000000000(0000) GS:ffff88802cd00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000562fada51cf8 CR3: 000000001d3dd000 CR4: 0000000000150ee0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400