2021-06-17 03:17:43

by syzbot

[permalink] [raw]
Subject: [syzbot] KASAN: stack-out-of-bounds Read in __show_regs

Hello,

syzbot found the following issue on:

HEAD commit: ad347abe Merge tag 'trace-v5.13-rc5-2' of git://git.kernel..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=11013e50300000
kernel config: https://syzkaller.appspot.com/x/.config?x=30f476588412c065
dashboard link: https://syzkaller.appspot.com/bug?extid=b17d3e853d5dce65f981
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=164b6a70300000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

irqentry_exit+0x31/0x80 kernel/entry/common.c:426
asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:647
RIP: 891806d5:0xffffed1002495388
RSP: 4299d728:ffffc9000b90fbf8 EFLAGS: fffffe00 ORIG_RAX: ffffffff88b60c00
==================================================================
BUG: KASAN: stack-out-of-bounds in __show_regs.cold+0x4e/0x508 arch/x86/kernel/process_64.c:80
Read of size 8 at addr ffffc9000b90fb20 by task systemd-journal/4846

CPU: 0 PID: 4846 Comm: systemd-journal Not tainted 5.13.0-rc5-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
<IRQ>
__dump_stack lib/dump_stack.c:79 [inline]
dump_stack+0x141/0x1d7 lib/dump_stack.c:120
print_address_description.constprop.0.cold+0x5/0x2f8 mm/kasan/report.c:233
__kasan_report mm/kasan/report.c:419 [inline]
kasan_report.cold+0x7c/0xd8 mm/kasan/report.c:436
__show_regs.cold+0x4e/0x508 arch/x86/kernel/process_64.c:80
show_trace_log_lvl+0x25b/0x2ba arch/x86/kernel/dumpstack.c:298
sched_show_task kernel/sched/core.c:7371 [inline]
sched_show_task+0x443/0x590 kernel/sched/core.c:7345
show_state_filter+0xf2/0x2d0 kernel/sched/core.c:7414
k_spec drivers/tty/vt/keyboard.c:660 [inline]
k_spec+0xe1/0x130 drivers/tty/vt/keyboard.c:649
kbd_keycode drivers/tty/vt/keyboard.c:1512 [inline]
kbd_event+0xc64/0x1750 drivers/tty/vt/keyboard.c:1531
input_to_handler+0x3b9/0x4c0 drivers/input/input.c:118
input_pass_values.part.0+0x284/0x700 drivers/input/input.c:145
input_pass_values drivers/input/input.c:415 [inline]
input_handle_event+0x67e/0x1440 drivers/input/input.c:415
input_event drivers/input/input.c:446 [inline]
input_event+0x8e/0xb0 drivers/input/input.c:438
hidinput_hid_event+0x59d/0x18b0 drivers/hid/hid-input.c:1420
hid_process_event+0x491/0x570 drivers/hid/hid-core.c:1522
hid_input_field drivers/hid/hid-core.c:1580 [inline]
hid_report_raw_event+0xe7f/0x11b0 drivers/hid/hid-core.c:1786
hid_input_report+0x360/0x4c0 drivers/hid/hid-core.c:1853
hid_irq_in+0x50e/0x690 drivers/hid/usbhid/hid-core.c:284
__usb_hcd_giveback_urb+0x2b0/0x5c0 drivers/usb/core/hcd.c:1656
usb_hcd_giveback_urb+0x367/0x410 drivers/usb/core/hcd.c:1726
dummy_timer+0x11f4/0x32a0 drivers/usb/gadget/udc/dummy_hcd.c:1978
call_timer_fn+0x1a5/0x6b0 kernel/time/timer.c:1431
expire_timers kernel/time/timer.c:1476 [inline]
__run_timers.part.0+0x67c/0xa50 kernel/time/timer.c:1745
__run_timers kernel/time/timer.c:1726 [inline]
run_timer_softirq+0xb3/0x1d0 kernel/time/timer.c:1758
__do_softirq+0x29b/0x9f6 kernel/softirq.c:559
invoke_softirq kernel/softirq.c:433 [inline]
__irq_exit_rcu+0x136/0x200 kernel/softirq.c:637
irq_exit_rcu+0x5/0x20 kernel/softirq.c:649
sysvec_apic_timer_interrupt+0x93/0xc0 arch/x86/kernel/apic/apic.c:1100
</IRQ>
asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:647
RIP: 0010:lock_is_held_type+0xfd/0x140 kernel/locking/lockdep.c:5560
Code: 00 00 b8 ff ff ff ff 65 0f c1 05 8e 7e eb 76 83 f8 01 75 29 9c 58 f6 c4 02 75 3d 48 f7 04 24 00 02 00 00 74 01 fb 48 83 c4 08 <44> 89 e8 5b 5d 41 5c 41 5d 41 5e 41 5f c3 45 31 ed eb b9 0f 0b 48
RSP: 0018:ffffc9000b62fd38 EFLAGS: 00000282
RAX: 0000000000000046 RBX: 0000000000000000 RCX: 0000000000000001
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffffff8bf79560 R08: 0000000000000000 R09: ffff888022132200
R10: ffffffff81a86a1f R11: 0000000000000000 R12: ffff88802c5754c0
R13: 0000000000000000 R14: 00000000ffffffff R15: ffffffff8dc99b08
lock_is_held include/linux/lockdep.h:283 [inline]
___might_sleep+0x23f/0x2c0 kernel/sched/core.c:8304
__might_fault+0x6e/0x180 mm/memory.c:5071
strncpy_from_user+0x2f/0x3e0 lib/strncpy_from_user.c:117
getname_flags.part.0+0x95/0x4f0 fs/namei.c:149
getname_flags fs/namei.c:2734 [inline]
user_path_at_empty+0xa1/0x100 fs/namei.c:2734
user_path_at include/linux/namei.h:60 [inline]
do_faccessat+0x127/0x850 fs/open.c:425
do_syscall_64+0x3a/0xb0 arch/x86/entry/common.c:47
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7efdbd9139c7
Code: 83 c4 08 48 3d 01 f0 ff ff 73 01 c3 48 8b 0d c8 d4 2b 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 b8 15 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d a1 d4 2b 00 f7 d8 64 89 01 48
RSP: 002b:00007fffaef68ff8 EFLAGS: 00000246 ORIG_RAX: 0000000000000015
RAX: ffffffffffffffda RBX: 00007fffaef6bf10 RCX: 00007efdbd9139c7
RDX: 00007efdbe384a00 RSI: 0000000000000000 RDI: 000055b1c4e5f9a3
RBP: 00007fffaef69030 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000069 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fffaef6bf10 R15: 00007fffaef69520


Memory state around the buggy address:
ffffc9000b90fa00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffffc9000b90fa80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffffc9000b90fb00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^
ffffc9000b90fb80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffffc9000b90fc00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================


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


2022-06-14 19:16:42

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] KASAN: stack-out-of-bounds Read in __show_regs

syzbot has found a reproducer for the following issue on:

HEAD commit: 2f3064574275 README.md: ORC is no more a problem
git tree: https://github.com/google/kmsan.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=169a2310080000
kernel config: https://syzkaller.appspot.com/x/.config?x=8e6293529531e9ca
dashboard link: https://syzkaller.appspot.com/bug?extid=b17d3e853d5dce65f981
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project.git 9ffb5944a699b6a0d69c169ceff97636395ee30f), GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14917c2ff00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1303752ff00000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:j1939_session_deactivate net/can/j1939/transport.c:1090 [inline]
RIP: 0010:j1939_session_deactivate_activate_next+0x271/0x480 net/can/j1939/transport.c:1100
Code: f4 e9 ed fd ff ff 8b 7d d4 e8 fb 31 13 f4 e9 24 fe ff ff 44 89 ff e8 ee 31 13 f4 41 83 fc 02 0f 83 68 fe ff ff e8 df 70 82 f3 <0f> 0b e9 61 fe ff ff 8b 7d d4 e8 d0 31 13 f4 e9 68 fe ff ff 44 89
RSP: 0018:ffff888102e3f5c8 EFLAGS: 00010246
=====================================================
BUG: KMSAN: uninit-value in __show_regs+0xe6/0x1040 arch/x86/kernel/process_64.c:76
__show_regs+0xe6/0x1040 arch/x86/kernel/process_64.c:76
show_regs+0xc0/0x160 arch/x86/kernel/dumpstack.c:463
__warn+0x3c2/0x730 kernel/panic.c:596
report_bug+0x8eb/0xae0 lib/bug.c:199
handle_bug+0x41/0x70 arch/x86/kernel/traps.c:315
exc_invalid_op+0x1b/0x50 arch/x86/kernel/traps.c:335
asm_exc_invalid_op+0x12/0x20
j1939_session_deactivate_activate_next+0x271/0x480 net/can/j1939/transport.c:1100
j1939_xtp_rx_abort_one+0x861/0x900 net/can/j1939/transport.c:1340
j1939_xtp_rx_abort net/can/j1939/transport.c:1351 [inline]
j1939_tp_cmd_recv net/can/j1939/transport.c:2100 [inline]
j1939_tp_recv+0x1534/0x1cd0 net/can/j1939/transport.c:2133
j1939_can_recv+0xed0/0x1070 net/can/j1939/main.c:108
deliver net/can/af_can.c:574 [inline]
can_rcv_filter+0x74b/0x1110 net/can/af_can.c:608
can_receive+0x4fb/0x6d0 net/can/af_can.c:665
can_rcv+0x1f0/0x490 net/can/af_can.c:696
__netif_receive_skb_one_core net/core/dev.c:5405 [inline]
__netif_receive_skb+0x1f1/0x640 net/core/dev.c:5519
process_backlog+0x4e7/0xb50 net/core/dev.c:5847
__napi_poll+0x14e/0xb80 net/core/dev.c:6413
napi_poll net/core/dev.c:6480 [inline]
net_rx_action+0x7e8/0x1830 net/core/dev.c:6567
__do_softirq+0x206/0x809 kernel/softirq.c:558
run_ksoftirqd+0x37/0x50 kernel/softirq.c:921
smpboot_thread_fn+0x626/0xbf0 kernel/smpboot.c:164
kthread+0x3c7/0x500 kernel/kthread.c:376
ret_from_fork+0x1f/0x30

Local variable mic created at:
ieee80211_rx_h_michael_mic_verify+0x54/0x10f0 net/mac80211/wpa.c:100
ieee80211_rx_handlers+0x2d31/0xf170 net/mac80211/rx.c:3929

CPU: 0 PID: 13 Comm: ksoftirqd/0 Not tainted 5.18.0-syzkaller-16253-g2f3064574275 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
=====================================================

2022-06-14 20:09:39

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] KASAN: stack-out-of-bounds Read in __show_regs

Hello,

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

net/mac80211/wpa.c:162:49: error: invalid operands to binary expression ('void' and 'int')


Tested on:

commit: 2f306457 README.md: ORC is no more a problem
git tree: https://github.com/google/kmsan.git master
dashboard link: https://syzkaller.appspot.com/bug?extid=b17d3e853d5dce65f981
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project.git 9ffb5944a699b6a0d69c169ceff97636395ee30f), GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=10b2b5a0080000

2022-06-14 20:09:43

by Pavel Skripkin

[permalink] [raw]
Subject: Re: [syzbot] KASAN: stack-out-of-bounds Read in __show_regs

Hi Syzbot,

On 6/14/22 22:05, syzbot wrote:
> syzbot has found a reproducer for the following issue on:
>
> HEAD commit: 2f3064574275 README.md: ORC is no more a problem
> git tree: https://github.com/google/kmsan.git master
> console output: https://syzkaller.appspot.com/x/log.txt?x=169a2310080000
> kernel config: https://syzkaller.appspot.com/x/.config?x=8e6293529531e9ca
> dashboard link: https://syzkaller.appspot.com/bug?extid=b17d3e853d5dce65f981
> compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project.git 9ffb5944a699b6a0d69c169ceff97636395ee30f), GNU ld (GNU Binutils for Debian) 2.35.2
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14917c2ff00000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1303752ff00000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: [email protected]
>
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> RIP: 0010:j1939_session_deactivate net/can/j1939/transport.c:1090 [inline]
> RIP: 0010:j1939_session_deactivate_activate_next+0x271/0x480 net/can/j1939/transport.c:1100
> Code: f4 e9 ed fd ff ff 8b 7d d4 e8 fb 31 13 f4 e9 24 fe ff ff 44 89 ff e8 ee 31 13 f4 41 83 fc 02 0f 83 68 fe ff ff e8 df 70 82 f3 <0f> 0b e9 61 fe ff ff 8b 7d d4 e8 d0 31 13 f4 e9 68 fe ff ff 44 89
> RSP: 0018:ffff888102e3f5c8 EFLAGS: 00010246
> =====================================================
> BUG: KMSAN: uninit-value in __show_regs+0xe6/0x1040 arch/x86/kernel/process_64.c:76

This bug looks unrelated to initial `stack-out-of-bounds Read in
__show_regs`

> __show_regs+0xe6/0x1040 arch/x86/kernel/process_64.c:76
> show_regs+0xc0/0x160 arch/x86/kernel/dumpstack.c:463
> __warn+0x3c2/0x730 kernel/panic.c:596
> report_bug+0x8eb/0xae0 lib/bug.c:199
> handle_bug+0x41/0x70 arch/x86/kernel/traps.c:315
> exc_invalid_op+0x1b/0x50 arch/x86/kernel/traps.c:335
> asm_exc_invalid_op+0x12/0x20
> j1939_session_deactivate_activate_next+0x271/0x480 net/can/j1939/transport.c:1100
> j1939_xtp_rx_abort_one+0x861/0x900 net/can/j1939/transport.c:1340
> j1939_xtp_rx_abort net/can/j1939/transport.c:1351 [inline]
> j1939_tp_cmd_recv net/can/j1939/transport.c:2100 [inline]
> j1939_tp_recv+0x1534/0x1cd0 net/can/j1939/transport.c:2133
> j1939_can_recv+0xed0/0x1070 net/can/j1939/main.c:108
> deliver net/can/af_can.c:574 [inline]
> can_rcv_filter+0x74b/0x1110 net/can/af_can.c:608
> can_receive+0x4fb/0x6d0 net/can/af_can.c:665
> can_rcv+0x1f0/0x490 net/can/af_can.c:696
> __netif_receive_skb_one_core net/core/dev.c:5405 [inline]
> __netif_receive_skb+0x1f1/0x640 net/core/dev.c:5519
> process_backlog+0x4e7/0xb50 net/core/dev.c:5847
> __napi_poll+0x14e/0xb80 net/core/dev.c:6413
> napi_poll net/core/dev.c:6480 [inline]
> net_rx_action+0x7e8/0x1830 net/core/dev.c:6567
> __do_softirq+0x206/0x809 kernel/softirq.c:558
> run_ksoftirqd+0x37/0x50 kernel/softirq.c:921
> smpboot_thread_fn+0x626/0xbf0 kernel/smpboot.c:164
> kthread+0x3c7/0x500 kernel/kthread.c:376
> ret_from_fork+0x1f/0x30
>
> Local variable mic created at:
> ieee80211_rx_h_michael_mic_verify+0x54/0x10f0 net/mac80211/wpa.c:100
> ieee80211_rx_handlers+0x2d31/0xf170 net/mac80211/rx.c:3929
>

Anyway, looks like missing error handling of michael_mic. `michael_mic`
may fail in a lot of cases and mic will be uninitialized in case of
michael_mic failure.


#syz test: https://github.com/google/kmsan.git master




With regards,
Pavel Skripkin


Attachments:
ph (569.00 B)
OpenPGP_signature (855.00 B)
OpenPGP digital signature
Download all attachments

2022-06-15 13:21:12

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] KASAN: stack-out-of-bounds Read in __show_regs

> On Tue, 14 Jun 2022 12:05:35 -0700
>> syzbot has found a reproducer for the following issue on:
>>
>> HEAD commit: 2f3064574275 README.md: ORC is no more a problem
>> git tree: https://github.com/google/kmsan.git master
>> console output: https://syzkaller.appspot.com/x/log.txt?x=169a2310080000
>> kernel config: https://syzkaller.appspot.com/x/.config?x=8e6293529531e9ca
>> dashboard link: https://syzkaller.appspot.com/bug?extid=b17d3e853d5dce65f981
>> compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project.git 9ffb5944a699b6a0d69c169ceff97636395ee30f), GNU ld (GNU Binutils for Debian) 2.35.2
>> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14917c2ff00000
>> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1303752ff00000
>>
>> IMPORTANT: if you fix the issue, please add the following tag to the commit:
>> Reported-by: [email protected]
>>
>> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
>> RIP: 0010:j1939_session_deactivate net/can/j1939/transport.c:1090 [inline]
>> RIP: 0010:j1939_session_deactivate_activate_next+0x271/0x480 net/can/j1939/transport.c:1100
>> Code: f4 e9 ed fd ff ff 8b 7d d4 e8 fb 31 13 f4 e9 24 fe ff ff 44 89 ff e8 ee 31 13 f4 41 83 fc 02 0f 83 68 fe ff ff e8 df 70 82 f3 <0f> 0b e9 61 fe ff ff 8b 7d d4 e8 d0 31 13 f4 e9 68 fe ff ff 44 89
>> RSP: 0018:ffff888102e3f5c8 EFLAGS: 00010246
>> =====================================================
>> BUG: KMSAN: uninit-value in __show_regs+0xe6/0x1040 arch/x86/kernel/process_64.c:76
>> __show_regs+0xe6/0x1040 arch/x86/kernel/process_64.c:76
>> show_regs+0xc0/0x160 arch/x86/kernel/dumpstack.c:463
>> __warn+0x3c2/0x730 kernel/panic.c:596
>> report_bug+0x8eb/0xae0 lib/bug.c:199
>> handle_bug+0x41/0x70 arch/x86/kernel/traps.c:315
>> exc_invalid_op+0x1b/0x50 arch/x86/kernel/traps.c:335
>> asm_exc_invalid_op+0x12/0x20
>> j1939_session_deactivate_activate_next+0x271/0x480 net/can/j1939/transport.c:1100
>> j1939_xtp_rx_abort_one+0x861/0x900 net/can/j1939/transport.c:1340
>> j1939_xtp_rx_abort net/can/j1939/transport.c:1351 [inline]
>> j1939_tp_cmd_recv net/can/j1939/transport.c:2100 [inline]
>> j1939_tp_recv+0x1534/0x1cd0 net/can/j1939/transport.c:2133
>> j1939_can_recv+0xed0/0x1070 net/can/j1939/main.c:108
>> deliver net/can/af_can.c:574 [inline]
>> can_rcv_filter+0x74b/0x1110 net/can/af_can.c:608
>> can_receive+0x4fb/0x6d0 net/can/af_can.c:665
>> can_rcv+0x1f0/0x490 net/can/af_can.c:696
>> __netif_receive_skb_one_core net/core/dev.c:5405 [inline]
>> __netif_receive_skb+0x1f1/0x640 net/core/dev.c:5519
>> process_backlog+0x4e7/0xb50 net/core/dev.c:5847
>> __napi_poll+0x14e/0xb80 net/core/dev.c:6413
>> napi_poll net/core/dev.c:6480 [inline]
>> net_rx_action+0x7e8/0x1830 net/core/dev.c:6567
>> __do_softirq+0x206/0x809 kernel/softirq.c:558
>> run_ksoftirqd+0x37/0x50 kernel/softirq.c:921
>> smpboot_thread_fn+0x626/0xbf0 kernel/smpboot.c:164
>> kthread+0x3c7/0x500 kernel/kthread.c:376
>> ret_from_fork+0x1f/0x30
>>
>> Local variable mic created at:
>> ieee80211_rx_h_michael_mic_verify+0x54/0x10f0 net/mac80211/wpa.c:100
>> ieee80211_rx_handlers+0x2d31/0xf170 net/mac80211/rx.c:3929
>>
>> CPU: 0 PID: 13 Comm: ksoftirqd/0 Not tainted 5.18.0-syzkaller-16253-g2f3064574275 #0
>> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
>> =====================================================
>
> See if session is already deactivated.
>
> #syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 24625f7d

KMSAN bugs can only be tested on https://github.com/google/kmsan.git tree
because KMSAN tool is not upstreamed yet.
See https://goo.gl/tpsmEJ#kmsan-bugs for details.

>
> diff -pur a/net/can/j1939/transport.c b/net/can/j1939/transport.c
> --- a/net/can/j1939/transport.c 2022-06-15 18:48:27.235848700 +0800
> +++ b/net/can/j1939/transport.c 2022-06-15 20:51:11.711001100 +0800
> @@ -1085,9 +1085,9 @@ static bool j1939_session_deactivate(str
>
> j1939_session_list_lock(priv);
> /* This function should be called with a session ref-count of at
> - * least 2.
> + * least 2 if the session is not deactivated yet.
> */
> - WARN_ON_ONCE(kref_read(&session->kref) < 2);
> + WARN_ON_ONCE(session->err != ESHUTDOWN && kref_read(&session->kref) < 2);
> active = j1939_session_deactivate_locked(session);
> j1939_session_list_unlock(priv);
>
> --