[syzbot] KASAN: vmalloc-out-of-bounds Read in blocking_notifier_chain_unregister

10 views
Skip to first unread message

syzbot

unread,
Aug 16, 2022, 5:06:29 AM8/16/22
to big...@linutronix.de, b...@suse.de, dmitry....@collabora.com, linux-...@vger.kernel.org, mirq-...@rere.qmqm.pl, rafael.j...@intel.com, syzkall...@googlegroups.com, vsch...@redhat.com
Hello,

syzbot found the following issue on:

HEAD commit: 7ebfc85e2cd7 Merge tag 'net-6.0-rc1' of git://git.kernel.o..
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=160d0915080000
kernel config: https://syzkaller.appspot.com/x/.config?x=924833c12349a8c0
dashboard link: https://syzkaller.appspot.com/bug?extid=2fd9312f3ff65d22d06f
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=11f5b2f3080000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=121c0067080000

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

==================================================================
BUG: KASAN: vmalloc-out-of-bounds in notifier_chain_unregister kernel/notifier.c:51 [inline]
BUG: KASAN: vmalloc-out-of-bounds in blocking_notifier_chain_unregister+0x230/0x290 kernel/notifier.c:329
Read of size 8 at addr ffffc900038ebbe8 by task syz-executor342/3606

CPU: 1 PID: 3606 Comm: syz-executor342 Not tainted 5.19.0-syzkaller-13930-g7ebfc85e2cd7 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/22/2022
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:317 [inline]
print_report.cold+0x59/0x719 mm/kasan/report.c:433
kasan_report+0xb1/0x1e0 mm/kasan/report.c:495
notifier_chain_unregister kernel/notifier.c:51 [inline]
blocking_notifier_chain_unregister+0x230/0x290 kernel/notifier.c:329
hci_unregister_suspend_notifier+0x73/0x90 net/bluetooth/hci_core.c:2760
hci_unregister_dev+0x16f/0x4e0 net/bluetooth/hci_core.c:2678
vhci_release+0x7c/0xf0 drivers/bluetooth/hci_vhci.c:568
__fput+0x277/0x9d0 fs/file_table.c:320
task_work_run+0xdd/0x1a0 kernel/task_work.c:177
exit_task_work include/linux/task_work.h:38 [inline]
do_exit+0xad5/0x29b0 kernel/exit.c:795
do_group_exit+0xd2/0x2f0 kernel/exit.c:925
__do_sys_exit_group kernel/exit.c:936 [inline]
__se_sys_exit_group kernel/exit.c:934 [inline]
__x64_sys_exit_group+0x3a/0x50 kernel/exit.c:934
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f278bd0d3c9
Code: Unable to access opcode bytes at RIP 0x7f278bd0d39f.
RSP: 002b:00007ffe2fd53298 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007f278bd91450 RCX: 00007f278bd0d3c9
RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
RBP: 0000000000000000 R08: ffffffffffffffb8 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f278bd91450
R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000001
</TASK>

Memory state around the buggy address:
ffffc900038eba80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
ffffc900038ebb00: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
>ffffc900038ebb80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
^
ffffc900038ebc00: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
ffffc900038ebc80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
==================================================================


---
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.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

Hillf Danton

unread,
Aug 17, 2022, 7:15:12 AM8/17/22
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Tue, 16 Aug 2022 02:06:28 -0700
> syzbot found the following issue on:
>
> HEAD commit: 7ebfc85e2cd7 Merge tag 'net-6.0-rc1' of git://git.kernel.o..
> git tree: upstream
> console+strace: https://syzkaller.appspot.com/x/log.txt?x=160d0915080000
> kernel config: https://syzkaller.appspot.com/x/.config?x=924833c12349a8c0
> dashboard link: https://syzkaller.appspot.com/bug?extid=2fd9312f3ff65d22d06f
> 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=11f5b2f3080000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=121c0067080000

Remove un/registering of notifier on the sock side to cut the race between
hci sock and core.

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

--- a/net/bluetooth/hci_sock.c
+++ h/net/bluetooth/hci_sock.c
@@ -887,7 +887,6 @@ static int hci_sock_release(struct socke
*/
hci_dev_do_close(hdev);
hci_dev_clear_flag(hdev, HCI_USER_CHANNEL);
- hci_register_suspend_notifier(hdev);
mgmt_index_added(hdev);
}

@@ -1216,7 +1215,6 @@ static int hci_sock_bind(struct socket *
}

mgmt_index_removed(hdev);
- hci_unregister_suspend_notifier(hdev);

err = hci_dev_open(hdev->id);
if (err) {
@@ -1231,7 +1229,6 @@ static int hci_sock_bind(struct socket *
err = 0;
} else {
hci_dev_clear_flag(hdev, HCI_USER_CHANNEL);
- hci_register_suspend_notifier(hdev);
mgmt_index_added(hdev);
hci_dev_put(hdev);
goto done;
--

syzbot

unread,
Aug 17, 2022, 7:52:09 AM8/17/22
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
BUG: unable to handle kernel paging request in kvm_arch_hardware_enable

BUG: unable to handle page fault for address: ffffc9000484a330
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 11800067
P4D 11800067
PUD 119c9067
PMD 1e9bb067
PTE 0
Oops: 0000 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 4090 Comm: syz-executor.0 Not tainted 5.19.0-syzkaller-13930-g7ebfc85e2cd7-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/22/2022
RIP: 0010:arch_atomic_read arch/x86/include/asm/atomic.h:29 [inline]
RIP: 0010:atomic_read include/linux/atomic/atomic-instrumented.h:28 [inline]
RIP: 0010:kvm_arch_hardware_enable+0x2ab/0x840 arch/x86/kvm/x86.c:11847
Code: 48 89 e8 48 b9 00 00 00 00 00 fc ff df 48 c1 e8 03 0f b6 14 08 48 89 e8 83 e0 07 83 c0 03 38 d0 7c 08 84 d2 0f 85 ed 04 00 00 <41> 8b 95 30 13 00 00 4d 8d b5 40 12 00 00 b9 08 00 00 00 4c 89 fe
RSP: 0018:ffffc9000507fb48 EFLAGS: 00010082

RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff81120fe0
RDX: 0000000000000000 RSI: 0000000000000004 RDI: ffffc9000484a330
RBP: ffffc9000484a330 R08: 0000000000000000 R09: 0000000000000003
R10: fffff52000909466 R11: 0000000000000000 R12: 0000000000000000
R13: ffffc90004849000 R14: 0023001000000000 R15: ffffc9000507fba0
FS: 00007f45b38a9700(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffc9000484a330 CR3: 000000007a237000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
hardware_enable_nolock+0xa7/0x140 arch/x86/kvm/../../../virt/kvm/kvm_main.c:5007
smp_call_function_many_cond+0x10e2/0x1430 kernel/smp.c:979
on_each_cpu_cond_mask+0x56/0xa0 kernel/smp.c:1154
on_each_cpu include/linux/smp.h:71 [inline]
hardware_enable_all arch/x86/kvm/../../../virt/kvm/kvm_main.c:5069 [inline]
kvm_create_vm arch/x86/kvm/../../../virt/kvm/kvm_main.c:1202 [inline]
kvm_dev_ioctl_create_vm arch/x86/kvm/../../../virt/kvm/kvm_main.c:4910 [inline]
kvm_dev_ioctl+0x131b/0x1ce0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:4957
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl fs/ioctl.c:856 [inline]
__x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f45b2689279
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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:00007f45b38a9168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f45b279bf80 RCX: 00007f45b2689279
RDX: 0000000000000000 RSI: 000000000000ae01 RDI: 0000000000000003
RBP: 00007f45b38a91d0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000002
R13: 00007fff8cb22fbf R14: 00007f45b38a9300 R15: 0000000000022000
</TASK>
Modules linked in:
CR2: ffffc9000484a330
---[ end trace 0000000000000000 ]---
RIP: 0010:arch_atomic_read arch/x86/include/asm/atomic.h:29 [inline]
RIP: 0010:atomic_read include/linux/atomic/atomic-instrumented.h:28 [inline]
RIP: 0010:kvm_arch_hardware_enable+0x2ab/0x840 arch/x86/kvm/x86.c:11847
Code: 48 89 e8 48 b9 00 00 00 00 00 fc ff df 48 c1 e8 03 0f b6 14 08 48 89 e8 83 e0 07 83 c0 03 38 d0 7c 08 84 d2 0f 85 ed 04 00 00 <41> 8b 95 30 13 00 00 4d 8d b5 40 12 00 00 b9 08 00 00 00 4c 89 fe
RSP: 0018:ffffc9000507fb48 EFLAGS: 00010082
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff81120fe0
RDX: 0000000000000000 RSI: 0000000000000004 RDI: ffffc9000484a330
RBP: ffffc9000484a330 R08: 0000000000000000 R09: 0000000000000003
R10: fffff52000909466 R11: 0000000000000000 R12: 0000000000000000
R13: ffffc90004849000 R14: 0023001000000000 R15: ffffc9000507fba0
FS: 00007f45b38a9700(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffc9000484a330 CR3: 000000007a237000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 48 89 e8 mov %rbp,%rax
3: 48 b9 00 00 00 00 00 movabs $0xdffffc0000000000,%rcx
a: fc ff df
d: 48 c1 e8 03 shr $0x3,%rax
11: 0f b6 14 08 movzbl (%rax,%rcx,1),%edx
15: 48 89 e8 mov %rbp,%rax
18: 83 e0 07 and $0x7,%eax
1b: 83 c0 03 add $0x3,%eax
1e: 38 d0 cmp %dl,%al
20: 7c 08 jl 0x2a
22: 84 d2 test %dl,%dl
24: 0f 85 ed 04 00 00 jne 0x517
* 2a: 41 8b 95 30 13 00 00 mov 0x1330(%r13),%edx <-- trapping instruction
31: 4d 8d b5 40 12 00 00 lea 0x1240(%r13),%r14
38: b9 08 00 00 00 mov $0x8,%ecx
3d: 4c 89 fe mov %r15,%rsi


Tested on:

commit: 7ebfc85e Merge tag 'net-6.0-rc1' of git://git.kernel.o..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=16cb627b080000
kernel config: https://syzkaller.appspot.com/x/.config?x=924833c12349a8c0
dashboard link: https://syzkaller.appspot.com/bug?extid=2fd9312f3ff65d22d06f
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=13f8bd97080000

Hillf Danton

unread,
Aug 23, 2022, 6:52:29 AM8/23/22
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Wed, 17 Aug 2022 04:52:08 -0700
> Hello,
>
> syzbot has tested the proposed patch but the reproducer is still triggering an issue:
> BUG: unable to handle kernel paging request in kvm_arch_hardware_enable

v1, cut notifier on hci sock side.
v2, clean up rollback on kvm side.
diff -pur m/net/bluetooth/hci_sock.c n/net/bluetooth/hci_sock.c
--- m/net/bluetooth/hci_sock.c 2022-08-23 18:36:25.279545700 +0800
+++ n/net/bluetooth/hci_sock.c 2022-08-23 18:40:14.540884400 +0800
@@ -887,7 +887,6 @@ static int hci_sock_release(struct socke
*/
hci_dev_do_close(hdev);
hci_dev_clear_flag(hdev, HCI_USER_CHANNEL);
- hci_register_suspend_notifier(hdev);
mgmt_index_added(hdev);
}

@@ -1216,7 +1215,6 @@ static int hci_sock_bind(struct socket *
}

mgmt_index_removed(hdev);
- hci_unregister_suspend_notifier(hdev);

err = hci_dev_open(hdev->id);
if (err) {
@@ -1231,7 +1229,6 @@ static int hci_sock_bind(struct socket *
err = 0;
} else {
hci_dev_clear_flag(hdev, HCI_USER_CHANNEL);
- hci_register_suspend_notifier(hdev);
mgmt_index_added(hdev);
hci_dev_put(hdev);
goto done;
diff -pur m/virt/kvm/kvm_main.c n/virt/kvm/kvm_main.c
--- m/virt/kvm/kvm_main.c 2022-08-23 18:37:50.109091400 +0800
+++ n/virt/kvm/kvm_main.c 2022-08-23 18:42:49.746773700 +0800
@@ -1229,7 +1229,7 @@ static struct kvm *kvm_create_vm(unsigne
*/
if (!try_module_get(kvm_chardev_ops.owner)) {
r = -ENODEV;
- goto out_err_mmu_notifier;
+ goto out_err_pm_notifier;
}

r = kvm_create_vm_debugfs(kvm, fdname);
@@ -1240,6 +1240,11 @@ static struct kvm *kvm_create_vm(unsigne

out_err:
module_put(kvm_chardev_ops.owner);
+out_err_pm_notifier:
+ kvm_destroy_pm_notifier(kvm);
+ mutex_lock(&kvm_lock);
+ list_del(&kvm->vm_list);
+ mutex_unlock(&kvm_lock);
out_err_mmu_notifier:
#if defined(CONFIG_MMU_NOTIFIER) && defined(KVM_ARCH_WANT_MMU_NOTIFIER)
if (kvm->mmu_notifier.ops)
--

syzbot

unread,
Aug 23, 2022, 7:09:14 AM8/23/22
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

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

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

Tested on:

commit: 7ebfc85e Merge tag 'net-6.0-rc1' of git://git.kernel.o..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=11aafb47080000
kernel config: https://syzkaller.appspot.com/x/.config?x=924833c12349a8c0
dashboard link: https://syzkaller.appspot.com/bug?extid=2fd9312f3ff65d22d06f
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=10e11a3d080000

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

syzbot

unread,
May 17, 2023, 3:00:36 PM5/17/23
to syzkall...@googlegroups.com
Auto-closing this bug as obsolete.
No recent activity, existing reproducers are no longer triggering the issue.
Reply all
Reply to author
Forward
0 new messages