Re: KASAN: use-after-free Read in tick_sched_handle (3)

2018-11-19 Thread Frederic Weisbecker
On Mon, Nov 19, 2018 at 01:39:02PM -0800, syzbot wrote:
> Hello,
> 
> syzbot found the following crash on:
> 
> HEAD commit:bae4e109837b mlxsw: spectrum: Expose discard counters via ..
> git tree:   net-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=11b5e77b40
> kernel config:  https://syzkaller.appspot.com/x/.config?x=d86f24333880b605
> dashboard link: https://syzkaller.appspot.com/bug?extid=999bca54de2ee169c021
> compiler:   gcc (GCC) 8.0.1 20180413 (experimental)
> syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=14b7d09340
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1487a22540
> 
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+999bca54de2ee169c...@syzkaller.appspotmail.com
> 
> IPv6: ADDRCONF(NETDEV_CHANGE): veth1: link becomes ready
> IPv6: ADDRCONF(NETDEV_CHANGE): veth0: link becomes ready
> 8021q: adding VLAN 0 to HW filter on device team0
> ==
> kasan: CONFIG_KASAN_INLINE enabled
> BUG: KASAN: use-after-free in tick_sched_handle+0x16c/0x180
> kernel/time/tick-sched.c:164

So tick_sched_timer() -> tick_sched_handle() is passed regs returned by
get_irq_regs() that seem to be junk.

Those regs should come from smp_apic_timer_interrupt().

Thoughts?


Re: KASAN: use-after-free Read in tick_sched_handle (3)

2018-11-19 Thread Frederic Weisbecker
On Mon, Nov 19, 2018 at 01:39:02PM -0800, syzbot wrote:
> Hello,
> 
> syzbot found the following crash on:
> 
> HEAD commit:bae4e109837b mlxsw: spectrum: Expose discard counters via ..
> git tree:   net-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=11b5e77b40
> kernel config:  https://syzkaller.appspot.com/x/.config?x=d86f24333880b605
> dashboard link: https://syzkaller.appspot.com/bug?extid=999bca54de2ee169c021
> compiler:   gcc (GCC) 8.0.1 20180413 (experimental)
> syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=14b7d09340
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1487a22540
> 
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+999bca54de2ee169c...@syzkaller.appspotmail.com
> 
> IPv6: ADDRCONF(NETDEV_CHANGE): veth1: link becomes ready
> IPv6: ADDRCONF(NETDEV_CHANGE): veth0: link becomes ready
> 8021q: adding VLAN 0 to HW filter on device team0
> ==
> kasan: CONFIG_KASAN_INLINE enabled
> BUG: KASAN: use-after-free in tick_sched_handle+0x16c/0x180
> kernel/time/tick-sched.c:164

So tick_sched_timer() -> tick_sched_handle() is passed regs returned by
get_irq_regs() that seem to be junk.

Those regs should come from smp_apic_timer_interrupt().

Thoughts?


KASAN: use-after-free Read in tick_sched_handle (3)

2018-11-19 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:bae4e109837b mlxsw: spectrum: Expose discard counters via ..
git tree:   net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=11b5e77b40
kernel config:  https://syzkaller.appspot.com/x/.config?x=d86f24333880b605
dashboard link: https://syzkaller.appspot.com/bug?extid=999bca54de2ee169c021
compiler:   gcc (GCC) 8.0.1 20180413 (experimental)
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=14b7d09340
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1487a22540

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

IPv6: ADDRCONF(NETDEV_CHANGE): veth1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth0: link becomes ready
8021q: adding VLAN 0 to HW filter on device team0
==
kasan: CONFIG_KASAN_INLINE enabled
BUG: KASAN: use-after-free in tick_sched_handle+0x16c/0x180  
kernel/time/tick-sched.c:164

Read of size 8 at addr 8881c0895a30 by task syz-executor949/6058
kasan: GPF could be caused by NULL-ptr deref or user memory access

CPU: 0 PID: 6058 Comm: syz-executor949 Not tainted 4.20.0-rc2+ #303
general protection fault:  [#1] PREEMPT SMP KASAN
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

CPU: 1 PID: 2938 Comm: kworker/1:2 Not tainted 4.20.0-rc2+ #303
Call Trace:
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

 
Workqueue: ipv6_addrconf addrconf_dad_work
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x244/0x39d lib/dump_stack.c:113
RIP: 0010:sk_fullsock include/net/sock.h:2402 [inline]
RIP: 0010:skb_set_owner_w+0xb4/0x320 net/core/sock.c:1842
Code: ff df 48 c1 ea 03 80 3c 02 00 0f 85 30 02 00 00 49 8d 7c 24 12 4c 89  
63 18 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 48  
89 fa 83 e2 07 38 d0 7f 08 84 c0 0f 85 cd 01 00 00

RSP: 0018:8881cb9274a8 EFLAGS: 00010203
RAX: dc00 RBX: 8881c2cf4bc0 RCX: 86273988
 print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
RDX: 000e RSI: 8625bddf RDI: 0074
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
RBP: 8881cb9274d0 R08: 8881cb98e280 R09: ed103701800c
R10: ed103701800c R11: 8881b80c0063 R12: 0062
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
R13: 8881c2cf4bd8 R14: 8881c2cf4c20 R15: 0020
 tick_sched_handle+0x16c/0x180 kernel/time/tick-sched.c:164
FS:  () GS:8881daf0() knlGS:
 tick_sched_timer+0x45/0x130 kernel/time/tick-sched.c:1274
CS:  0010 DS:  ES:  CR0: 80050033
 __run_hrtimer kernel/time/hrtimer.c:1398 [inline]
 __hrtimer_run_queues+0x41c/0x10d0 kernel/time/hrtimer.c:1460
CR2: 7fff57a32ff8 CR3: 0001cb905000 CR4: 001406e0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 ndisc_alloc_skb+0x284/0x340 net/ipv6/ndisc.c:419
 ndisc_send_ns+0x194/0x8e0 net/ipv6/ndisc.c:609
 hrtimer_interrupt+0x313/0x780 kernel/time/hrtimer.c:1518
 local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1034 [inline]
 smp_apic_timer_interrupt+0x1a1/0x760 arch/x86/kernel/apic/apic.c:1059
 addrconf_dad_work+0xbf2/0x1310 net/ipv6/addrconf.c:4077
 process_one_work+0xc90/0x1c40 kernel/workqueue.c:2153
 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:804
 

Allocated by task 3230256160:
 worker_thread+0x17f/0x1390 kernel/workqueue.c:2296
 kthread+0x35a/0x440 kernel/kthread.c:246
 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352
Modules linked in:
BUG: unable to handle kernel paging request at 8caa3e08
---[ end trace 6c1017c956f17b9c ]---
PGD 946d067 P4D 946d067 PUD 946e063 PMD 0
Thread overran stack, or stack corrupted
Oops:  [#2] PREEMPT SMP KASAN
RIP: 0010:sk_fullsock include/net/sock.h:2402 [inline]
RIP: 0010:skb_set_owner_w+0xb4/0x320 net/core/sock.c:1842
CPU: 0 PID: 6058 Comm: syz-executor949 Tainted: G  D
4.20.0-rc2+ #303
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

RIP: 0010:depot_fetch_stack+0x10/0x30 lib/stackdepot.c:201
Code: 89 e8 44 96 1c fe e9 87 fd ff ff e8 8a b0 a2 fd 90 90 90 90 90 90 90  
90 90 90 89 f8 c1 ef 11 25 ff ff 1f 00 81 e7 f0 3f 00 00 <48> 03 3c c5 00  
fa ad 8b 8b 47 0c 48 83 c7 18 c7 46 10 00 00 00 00
Code: ff df 48 c1 ea 03 80 3c 02 00 0f 85 30 02 00 00 49 8d 7c 24 12 4c 89  
63 18 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 48  
89 fa 83 e2 07 38 d0 7f 08 84 c0 0f 85 cd 01 00 00

RSP: 0018:8881dae07a38 EFLAGS: 00010006
RAX: 001f8881 RBX: 8881c089cb84 RCX: 
RDX: 

KASAN: use-after-free Read in tick_sched_handle (3)

2018-11-19 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:bae4e109837b mlxsw: spectrum: Expose discard counters via ..
git tree:   net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=11b5e77b40
kernel config:  https://syzkaller.appspot.com/x/.config?x=d86f24333880b605
dashboard link: https://syzkaller.appspot.com/bug?extid=999bca54de2ee169c021
compiler:   gcc (GCC) 8.0.1 20180413 (experimental)
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=14b7d09340
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1487a22540

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

IPv6: ADDRCONF(NETDEV_CHANGE): veth1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth0: link becomes ready
8021q: adding VLAN 0 to HW filter on device team0
==
kasan: CONFIG_KASAN_INLINE enabled
BUG: KASAN: use-after-free in tick_sched_handle+0x16c/0x180  
kernel/time/tick-sched.c:164

Read of size 8 at addr 8881c0895a30 by task syz-executor949/6058
kasan: GPF could be caused by NULL-ptr deref or user memory access

CPU: 0 PID: 6058 Comm: syz-executor949 Not tainted 4.20.0-rc2+ #303
general protection fault:  [#1] PREEMPT SMP KASAN
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

CPU: 1 PID: 2938 Comm: kworker/1:2 Not tainted 4.20.0-rc2+ #303
Call Trace:
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

 
Workqueue: ipv6_addrconf addrconf_dad_work
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x244/0x39d lib/dump_stack.c:113
RIP: 0010:sk_fullsock include/net/sock.h:2402 [inline]
RIP: 0010:skb_set_owner_w+0xb4/0x320 net/core/sock.c:1842
Code: ff df 48 c1 ea 03 80 3c 02 00 0f 85 30 02 00 00 49 8d 7c 24 12 4c 89  
63 18 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 48  
89 fa 83 e2 07 38 d0 7f 08 84 c0 0f 85 cd 01 00 00

RSP: 0018:8881cb9274a8 EFLAGS: 00010203
RAX: dc00 RBX: 8881c2cf4bc0 RCX: 86273988
 print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
RDX: 000e RSI: 8625bddf RDI: 0074
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
RBP: 8881cb9274d0 R08: 8881cb98e280 R09: ed103701800c
R10: ed103701800c R11: 8881b80c0063 R12: 0062
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
R13: 8881c2cf4bd8 R14: 8881c2cf4c20 R15: 0020
 tick_sched_handle+0x16c/0x180 kernel/time/tick-sched.c:164
FS:  () GS:8881daf0() knlGS:
 tick_sched_timer+0x45/0x130 kernel/time/tick-sched.c:1274
CS:  0010 DS:  ES:  CR0: 80050033
 __run_hrtimer kernel/time/hrtimer.c:1398 [inline]
 __hrtimer_run_queues+0x41c/0x10d0 kernel/time/hrtimer.c:1460
CR2: 7fff57a32ff8 CR3: 0001cb905000 CR4: 001406e0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 ndisc_alloc_skb+0x284/0x340 net/ipv6/ndisc.c:419
 ndisc_send_ns+0x194/0x8e0 net/ipv6/ndisc.c:609
 hrtimer_interrupt+0x313/0x780 kernel/time/hrtimer.c:1518
 local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1034 [inline]
 smp_apic_timer_interrupt+0x1a1/0x760 arch/x86/kernel/apic/apic.c:1059
 addrconf_dad_work+0xbf2/0x1310 net/ipv6/addrconf.c:4077
 process_one_work+0xc90/0x1c40 kernel/workqueue.c:2153
 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:804
 

Allocated by task 3230256160:
 worker_thread+0x17f/0x1390 kernel/workqueue.c:2296
 kthread+0x35a/0x440 kernel/kthread.c:246
 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352
Modules linked in:
BUG: unable to handle kernel paging request at 8caa3e08
---[ end trace 6c1017c956f17b9c ]---
PGD 946d067 P4D 946d067 PUD 946e063 PMD 0
Thread overran stack, or stack corrupted
Oops:  [#2] PREEMPT SMP KASAN
RIP: 0010:sk_fullsock include/net/sock.h:2402 [inline]
RIP: 0010:skb_set_owner_w+0xb4/0x320 net/core/sock.c:1842
CPU: 0 PID: 6058 Comm: syz-executor949 Tainted: G  D
4.20.0-rc2+ #303
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

RIP: 0010:depot_fetch_stack+0x10/0x30 lib/stackdepot.c:201
Code: 89 e8 44 96 1c fe e9 87 fd ff ff e8 8a b0 a2 fd 90 90 90 90 90 90 90  
90 90 90 89 f8 c1 ef 11 25 ff ff 1f 00 81 e7 f0 3f 00 00 <48> 03 3c c5 00  
fa ad 8b 8b 47 0c 48 83 c7 18 c7 46 10 00 00 00 00
Code: ff df 48 c1 ea 03 80 3c 02 00 0f 85 30 02 00 00 49 8d 7c 24 12 4c 89  
63 18 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 48  
89 fa 83 e2 07 38 d0 7f 08 84 c0 0f 85 cd 01 00 00

RSP: 0018:8881dae07a38 EFLAGS: 00010006
RAX: 001f8881 RBX: 8881c089cb84 RCX: 
RDX: