syzbot


KASAN: use-after-free Read in __hrtimer_run_queues

Status: fixed on 2020/05/10 10:42
Subsystems: kernel
[Documentation on labels]
Reported-by: syzbot+62c155c276e580cfb606@syzkaller.appspotmail.com
Fix commit: 73d20564e0dc hrtimer: Don't dereference the hrtimer pointer after the callback
First crash: 1485d, last: 1477d
Cause bisection: introduced by (bisect log) :
commit 40db173965c05a1d803451240ed41707d5bd978d
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Sat Mar 21 11:26:02 2020 +0000

  lockdep: Add hrtimer context tracing bits

Crash: KASAN: use-after-free Read in __hrtimer_run_queues (log)
Repro: C syz .config
  
Discussions (2)
Title Replies (including bot) Last reply
[PATCH] lockdep: Don't access the hrtimer after the callback 2 (2) 2020/04/01 19:50
KASAN: use-after-free Read in __hrtimer_run_queues 0 (1) 2020/03/31 17:11

Sample crash report:
vxcan0: j1939_tp_rxtimer: 0x0000000019733e16: rx timeout, send abort
vxcan0: j1939_tp_rxtimer: 0x0000000019733e16: abort rx timeout. Force session deactivation
==================================================================
BUG: KASAN: use-after-free in __run_hrtimer kernel/time/hrtimer.c:1521 [inline]
BUG: KASAN: use-after-free in __hrtimer_run_queues+0xe18/0xf10 kernel/time/hrtimer.c:1583
Read of size 1 at addr ffff8880a8a94973 by task swapper/1/0

CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.6.0-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:77 [inline]
 dump_stack+0x188/0x20d lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd3/0x315 mm/kasan/report.c:374
 __kasan_report.cold+0x1a/0x32 mm/kasan/report.c:506
 kasan_report+0xe/0x20 mm/kasan/common.c:641
 __run_hrtimer kernel/time/hrtimer.c:1521 [inline]
 __hrtimer_run_queues+0xe18/0xf10 kernel/time/hrtimer.c:1583
 hrtimer_run_softirq+0x16d/0x250 kernel/time/hrtimer.c:1600
 __do_softirq+0x26c/0x9f7 kernel/softirq.c:292
 invoke_softirq kernel/softirq.c:373 [inline]
 irq_exit+0x192/0x1d0 kernel/softirq.c:413
 exiting_irq arch/x86/include/asm/apic.h:546 [inline]
 smp_apic_timer_interrupt+0x19e/0x600 arch/x86/kernel/apic/apic.c:1140
 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:829
 </IRQ>
RIP: 0010:native_safe_halt+0xe/0x10 arch/x86/include/asm/irqflags.h:61
Code: cc cc cc cc cc cc cc cc cc cc cc cc e9 07 00 00 00 0f 00 2d 94 59 4c 00 f4 c3 66 90 e9 07 00 00 00 0f 00 2d 84 59 4c 00 fb f4 <c3> cc 41 56 41 55 41 54 55 53 e8 63 8d a4 f9 e8 9e 9f d7 fb 0f 1f
RSP: 0018:ffffc90000d3fdb8 EFLAGS: 00000282 ORIG_RAX: ffffffffffffff13
RAX: 1ffffffff12e90e7 RBX: ffff8880a9646340 RCX: 0000000000000000
RDX: dffffc0000000000 RSI: 0000000000000006 RDI: ffff8880a9646bfc
RBP: dffffc0000000000 R08: ffff8880a9646340 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffffed10152c8c68
R13: 0000000000000001 R14: ffffffff8a673000 R15: 0000000000000000
 arch_safe_halt arch/x86/include/asm/paravirt.h:144 [inline]
 default_idle+0x49/0x350 arch/x86/kernel/process.c:695
 cpuidle_idle_call kernel/sched/idle.c:154 [inline]
 do_idle+0x393/0x690 kernel/sched/idle.c:269
 cpu_startup_entry+0x14/0x20 kernel/sched/idle.c:361
 start_secondary+0x2f3/0x400 arch/x86/kernel/smpboot.c:268
 secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:242

Allocated by task 7190:
 save_stack+0x1b/0x80 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 __kasan_kmalloc mm/kasan/common.c:515 [inline]
 __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:488
 kmem_cache_alloc_trace+0x153/0x7d0 mm/slab.c:3551
 kmalloc include/linux/slab.h:555 [inline]
 kzalloc include/linux/slab.h:669 [inline]
 j1939_session_new+0x7c/0x3f0 net/can/j1939/transport.c:1418
 j1939_tp_send+0x22f/0x800 net/can/j1939/transport.c:1877
 j1939_sk_send_loop net/can/j1939/socket.c:1037 [inline]
 j1939_sk_sendmsg+0xabf/0x1360 net/can/j1939/socket.c:1160
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:672
 ____sys_sendmsg+0x6bf/0x7e0 net/socket.c:2362
 ___sys_sendmsg+0x100/0x170 net/socket.c:2416
 __sys_sendmsg+0xec/0x1b0 net/socket.c:2449
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 0:
 save_stack+0x1b/0x80 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 kasan_set_free_info mm/kasan/common.c:337 [inline]
 __kasan_slab_free+0xf7/0x140 mm/kasan/common.c:476
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x109/0x2b0 mm/slab.c:3757
 j1939_session_destroy net/can/j1939/transport.c:276 [inline]
 __j1939_session_release net/can/j1939/transport.c:284 [inline]
 kref_put include/linux/kref.h:65 [inline]
 j1939_session_put+0x25c/0x330 net/can/j1939/transport.c:289
 j1939_tp_rxtimer+0x2e9/0x2f4 net/can/j1939/transport.c:1194
 __run_hrtimer kernel/time/hrtimer.c:1519 [inline]
 __hrtimer_run_queues+0x3a2/0xf10 kernel/time/hrtimer.c:1583
 hrtimer_run_softirq+0x16d/0x250 kernel/time/hrtimer.c:1600
 __do_softirq+0x26c/0x9f7 kernel/softirq.c:292

The buggy address belongs to the object at ffff8880a8a94800
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 371 bytes inside of
 512-byte region [ffff8880a8a94800, ffff8880a8a94a00)
The buggy address belongs to the page:
page:ffffea0002a2a500 refcount:1 mapcount:0 mapping:ffff8880aa000a80 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea0002785688 ffffea00027905c8 ffff8880aa000a80
raw: 0000000000000000 ffff8880a8a94000 0000000100000004 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a8a94800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a8a94880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a8a94900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                             ^
 ffff8880a8a94980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a8a94a00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (299):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/03/31 06:11 upstream 673b41e04a03 c8d1cc20 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/03/31 04:31 upstream 673b41e04a03 c8d1cc20 .config console log report syz C ci-upstream-kasan-gce-386
2020/03/31 04:46 upstream 673b41e04a03 c8d1cc20 .config console log report syz ci-upstream-kasan-gce-smack-root
2020/04/03 19:47 upstream bef7b2a7be28 5ed396e6 .config console log report ci-upstream-kasan-gce-root
2020/04/03 15:41 upstream bef7b2a7be28 5ed396e6 .config console log report ci-upstream-kasan-gce-root
2020/04/03 13:04 upstream bef7b2a7be28 5ed396e6 .config console log report ci-upstream-kasan-gce-selinux-root
2020/04/03 11:48 upstream bef7b2a7be28 5ed396e6 .config console log report ci-upstream-kasan-gce-selinux-root
2020/04/03 05:58 upstream 7be97138e727 a34e2c33 .config console log report ci-upstream-kasan-gce
2020/04/03 02:42 upstream 7be97138e727 a34e2c33 .config console log report ci-upstream-kasan-gce-selinux-root
2020/04/02 23:31 upstream 7be97138e727 a34e2c33 .config console log report ci-upstream-kasan-gce-selinux-root
2020/04/02 21:05 upstream 7be97138e727 a34e2c33 .config console log report ci-upstream-kasan-gce
2020/04/02 15:13 upstream 919dce24701f a34e2c33 .config console log report ci-upstream-kasan-gce-root
2020/04/02 06:23 upstream 919dce24701f a34e2c33 .config console log report ci-upstream-kasan-gce-root
2020/04/02 05:20 upstream 919dce24701f a34e2c33 .config console log report ci-upstream-kasan-gce-smack-root
2020/04/02 05:09 upstream 919dce24701f a34e2c33 .config console log report ci-upstream-kasan-gce
2020/04/02 00:05 upstream 1a323ea5356e a34e2c33 .config console log report ci-upstream-kasan-gce-selinux-root
2020/03/31 10:35 upstream 673b41e04a03 c8d1cc20 .config console log report ci-upstream-kasan-gce-386
2020/03/31 01:56 upstream 673b41e04a03 c8d1cc20 .config console log report ci-upstream-kasan-gce-386
2020/04/07 21:30 net-old aa81700cf232 db9bcd4b .config console log report ci-upstream-net-this-kasan-gce
2020/04/07 18:18 net-old aa81700cf232 99a96044 .config console log report ci-upstream-net-this-kasan-gce
2020/04/06 19:15 net-old aa81700cf232 99a96044 .config console log report ci-upstream-net-this-kasan-gce
2020/04/03 10:03 net-old 21f64e72e707 a34e2c33 .config console log report ci-upstream-net-this-kasan-gce
2020/04/02 10:28 net-old d61f4d61ff7f a34e2c33 .config console log report ci-upstream-net-this-kasan-gce
2020/04/02 09:17 net-old 304e024216a8 a34e2c33 .config console log report ci-upstream-net-this-kasan-gce
2020/04/02 08:02 net-old 304e024216a8 a34e2c33 .config console log report ci-upstream-net-this-kasan-gce
2020/04/02 04:07 net-old 304e024216a8 a34e2c33 .config console log report ci-upstream-net-this-kasan-gce
2020/04/07 19:21 net-next-old 1a323ea5356e db9bcd4b .config console log report ci-upstream-net-kasan-gce
2020/04/07 17:00 net-next-old 1a323ea5356e 99a96044 .config console log report ci-upstream-net-kasan-gce
2020/04/07 16:32 net-next-old 1a323ea5356e 99a96044 .config console log report ci-upstream-net-kasan-gce
2020/04/07 12:28 net-next-old 1a323ea5356e 99a96044 .config console log report ci-upstream-net-kasan-gce
2020/04/07 10:59 net-next-old 1a323ea5356e 99a96044 .config console log report ci-upstream-net-kasan-gce
2020/04/07 09:47 net-next-old 1a323ea5356e 99a96044 .config console log report ci-upstream-net-kasan-gce
2020/04/07 08:02 net-next-old 1a323ea5356e 99a96044 .config console log report ci-upstream-net-kasan-gce
2020/04/07 04:46 net-next-old 1a323ea5356e 99a96044 .config console log report ci-upstream-net-kasan-gce
2020/04/07 03:12 net-next-old 1a323ea5356e 99a96044 .config console log report ci-upstream-net-kasan-gce
2020/04/07 02:03 net-next-old 1a323ea5356e 99a96044 .config console log report ci-upstream-net-kasan-gce
2020/04/06 23:43 net-next-old 1a323ea5356e 99a96044 .config console log report ci-upstream-net-kasan-gce
2020/04/06 20:14 net-next-old 1a323ea5356e 99a96044 .config console log report ci-upstream-net-kasan-gce
2020/04/03 23:50 net-next-old 1a323ea5356e 5ed396e6 .config console log report ci-upstream-net-kasan-gce
2020/04/03 22:17 net-next-old 1a323ea5356e 5ed396e6 .config console log report ci-upstream-net-kasan-gce
2020/04/03 21:03 net-next-old 1a323ea5356e 5ed396e6 .config console log report ci-upstream-net-kasan-gce
2020/04/03 17:45 net-next-old 1a323ea5356e 5ed396e6 .config console log report ci-upstream-net-kasan-gce
2020/04/03 11:03 net-next-old 1a323ea5356e 5ed396e6 .config console log report ci-upstream-net-kasan-gce
2020/04/03 08:33 net-next-old 1a323ea5356e a34e2c33 .config console log report ci-upstream-net-kasan-gce
2020/04/03 05:51 net-next-old 1a323ea5356e a34e2c33 .config console log report ci-upstream-net-kasan-gce
2020/04/03 04:50 net-next-old 1a323ea5356e a34e2c33 .config console log report ci-upstream-net-kasan-gce
2020/04/03 01:39 net-next-old 1a323ea5356e a34e2c33 .config console log report ci-upstream-net-kasan-gce
2020/04/02 23:20 net-next-old 1a323ea5356e a34e2c33 .config console log report ci-upstream-net-kasan-gce
2020/04/02 22:16 net-next-old 1a323ea5356e a34e2c33 .config console log report ci-upstream-net-kasan-gce
2020/04/02 18:39 net-next-old 1a323ea5356e a34e2c33 .config console log report ci-upstream-net-kasan-gce
2020/04/02 17:16 net-next-old 1a323ea5356e a34e2c33 .config console log report ci-upstream-net-kasan-gce
2020/04/02 14:13 net-next-old 1a323ea5356e a34e2c33 .config console log report ci-upstream-net-kasan-gce
2020/04/02 11:57 net-next-old 1a323ea5356e a34e2c33 .config console log report ci-upstream-net-kasan-gce
2020/04/02 01:48 net-next-old 1a323ea5356e a34e2c33 .config console log report ci-upstream-net-kasan-gce
* Struck through repros no longer work on HEAD.