syzbot


KASAN: use-after-free Read in tcp_keepalive_timer (2)

Status: closed as invalid on 2021/12/14 20:02
Subsystems: net
[Documentation on labels]
First crash: 911d, last: 911d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in tcp_keepalive_timer net 1 1357d 1357d 0/26 auto-closed as invalid on 2020/11/17 07:09

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in tcp_fin_time include/net/tcp.h:1503 [inline]
BUG: KASAN: use-after-free in tcp_keepalive_timer+0x880/0xf20 net/ipv4/tcp_timer.c:696
Read of size 4 at addr ffff88802f623b18 by task syz-executor.0/31994

CPU: 1 PID: 31994 Comm: syz-executor.0 Not tainted 5.15.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:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0x6c/0x309 mm/kasan/report.c:256
 __kasan_report mm/kasan/report.c:442 [inline]
 kasan_report.cold+0x83/0xdf mm/kasan/report.c:459
 tcp_fin_time include/net/tcp.h:1503 [inline]
 tcp_keepalive_timer+0x880/0xf20 net/ipv4/tcp_timer.c:696
 call_timer_fn+0x1a5/0x6b0 kernel/time/timer.c:1421
 expire_timers kernel/time/timer.c:1466 [inline]
 __run_timers.part.0+0x675/0xa20 kernel/time/timer.c:1734
 __run_timers kernel/time/timer.c:1715 [inline]
 run_timer_softirq+0xb3/0x1d0 kernel/time/timer.c:1747
 __do_softirq+0x29b/0x9c2 kernel/softirq.c:558
 invoke_softirq kernel/softirq.c:432 [inline]
 __irq_exit_rcu+0x123/0x180 kernel/softirq.c:636
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:648
 sysvec_apic_timer_interrupt+0x93/0xc0 arch/x86/kernel/apic/apic.c:1097
 </IRQ>
 <TASK>
 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:638
RIP: 0010:kasan_mem_to_shadow include/linux/kasan.h:55 [inline]
RIP: 0010:memory_is_poisoned_n mm/kasan/generic.c:128 [inline]
RIP: 0010:memory_is_poisoned mm/kasan/generic.c:159 [inline]
RIP: 0010:check_region_inline mm/kasan/generic.c:180 [inline]
RIP: 0010:kasan_check_range+0x44/0x180 mm/kasan/generic.c:189
Code: 01 00 00 48 b8 ff ff ff ff ff 7f ff ff 48 39 c7 0f 86 05 01 00 00 49 83 e9 01 48 89 fd 48 b8 00 00 00 00 00 fc ff df 4d 89 ca <48> c1 ed 03 49 c1 ea 03 48 01 c5 49 01 c2 48 89 e8 49 8d 5a 01 48
RSP: 0018:ffffc90002bef990 EFLAGS: 00000282
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff875b4efe
RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffff88801c9dd700
RBP: ffff88801c9dd700 R08: 0000000000000000 R09: ffff88801c9dd707
R10: ffff88801c9dd707 R11: 0000000000000001 R12: ffffc90002befabc
R13: ffffc90002befa88 R14: ffff88801c9dd700 R15: ffffc90002befc40
 instrument_atomic_read include/linux/instrumented.h:71 [inline]
 test_bit include/asm-generic/bitops/instrumented-non-atomic.h:134 [inline]
 test_ti_thread_flag include/linux/thread_info.h:118 [inline]
 test_tsk_thread_flag include/linux/sched.h:1983 [inline]
 task_sigpending include/linux/sched/signal.h:356 [inline]
 signal_pending include/linux/sched/signal.h:368 [inline]
 bpf_test_timer_continue+0xce/0x420 net/bpf/test_run.c:68
 bpf_test_run+0x308/0x980 net/bpf/test_run.c:121
 bpf_prog_test_run_skb+0xb3b/0x1e80 net/bpf/test_run.c:666
 bpf_prog_test_run kernel/bpf/syscall.c:3335 [inline]
 __sys_bpf+0x2161/0x5f00 kernel/bpf/syscall.c:4636
 __do_sys_bpf kernel/bpf/syscall.c:4722 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:4720 [inline]
 __x64_sys_bpf+0x75/0xb0 kernel/bpf/syscall.c:4720
 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+0x44/0xae
RIP: 0033:0x7ffab3e06ae9
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 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffab137c188 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007ffab3f19f60 RCX: 00007ffab3e06ae9
RDX: 0000000000000048 RSI: 0000000020000240 RDI: 000000000000000a
RBP: 00007ffab3e60f25 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffe3624f74f R14: 00007ffab137c300 R15: 0000000000022000
 </TASK>

Allocated by task 4545:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 __kasan_slab_alloc+0x83/0xb0 mm/kasan/common.c:467
 kasan_slab_alloc include/linux/kasan.h:259 [inline]
 slab_post_alloc_hook mm/slab.h:519 [inline]
 slab_alloc_node mm/slub.c:3213 [inline]
 slab_alloc mm/slub.c:3221 [inline]
 kmem_cache_alloc+0x209/0x390 mm/slub.c:3226
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 net_alloc net/core/net_namespace.c:402 [inline]
 copy_net_ns+0x125/0x760 net/core/net_namespace.c:457
 create_new_namespaces+0x3f6/0xb20 kernel/nsproxy.c:110
 unshare_nsproxy_namespaces+0xc1/0x1f0 kernel/nsproxy.c:226
 ksys_unshare+0x445/0x920 kernel/fork.c:3076
 __do_sys_unshare kernel/fork.c:3150 [inline]
 __se_sys_unshare kernel/fork.c:3148 [inline]
 __x64_sys_unshare+0x2d/0x40 kernel/fork.c:3148
 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+0x44/0xae

The buggy address belongs to the object at ffff88802f623480
 which belongs to the cache net_namespace of size 6464
The buggy address is located 1688 bytes inside of
 6464-byte region [ffff88802f623480, ffff88802f624dc0)
The buggy address belongs to the page:
page:ffffea0000bd8800 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88802f623480 pfn:0x2f620
head:ffffea0000bd8800 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 0000000100000001 ffff888015397000
raw: ffff88802f623480 0000000080040001 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 24088, ts 1368722751377, free_ts 1368711013974
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0xa72/0x2f80 mm/page_alloc.c:4155
 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5381
 alloc_pages+0x1a7/0x300 mm/mempolicy.c:2191
 alloc_slab_page mm/slub.c:1770 [inline]
 allocate_slab mm/slub.c:1907 [inline]
 new_slab+0x319/0x490 mm/slub.c:1970
 ___slab_alloc+0x921/0xfe0 mm/slub.c:3001
 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3088
 slab_alloc_node mm/slub.c:3179 [inline]
 slab_alloc mm/slub.c:3221 [inline]
 kmem_cache_alloc+0x363/0x390 mm/slub.c:3226
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 net_alloc net/core/net_namespace.c:402 [inline]
 copy_net_ns+0x125/0x760 net/core/net_namespace.c:457
 create_new_namespaces+0x3f6/0xb20 kernel/nsproxy.c:110
 unshare_nsproxy_namespaces+0xc1/0x1f0 kernel/nsproxy.c:226
 ksys_unshare+0x445/0x920 kernel/fork.c:3076
 __do_sys_unshare kernel/fork.c:3150 [inline]
 __se_sys_unshare kernel/fork.c:3148 [inline]
 __x64_sys_unshare+0x2d/0x40 kernel/fork.c:3148
 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+0x44/0xae
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare+0x326/0x810 mm/page_alloc.c:1391
 free_unref_page_prepare mm/page_alloc.c:3317 [inline]
 free_unref_page+0x19/0x690 mm/page_alloc.c:3396
 __unfreeze_partials+0x340/0x360 mm/slub.c:2502
 qlink_free mm/kasan/quarantine.c:146 [inline]
 qlist_free_all+0x5a/0xc0 mm/kasan/quarantine.c:165
 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:272
 __kasan_slab_alloc+0x95/0xb0 mm/kasan/common.c:444
 kasan_slab_alloc include/linux/kasan.h:259 [inline]
 slab_post_alloc_hook mm/slab.h:519 [inline]
 slab_alloc_node mm/slub.c:3213 [inline]
 slab_alloc mm/slub.c:3221 [inline]
 kmem_cache_alloc+0x209/0x390 mm/slub.c:3226
 create_nsproxy kernel/nsproxy.c:56 [inline]
 create_new_namespaces+0x30/0xb20 kernel/nsproxy.c:74
 unshare_nsproxy_namespaces+0xc1/0x1f0 kernel/nsproxy.c:226
 ksys_unshare+0x445/0x920 kernel/fork.c:3076
 __do_sys_unshare kernel/fork.c:3150 [inline]
 __se_sys_unshare kernel/fork.c:3148 [inline]
 __x64_sys_unshare+0x2d/0x40 kernel/fork.c:3148
 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+0x44/0xae

Memory state around the buggy address:
 ffff88802f623a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88802f623a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88802f623b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff88802f623b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88802f623c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess), 1 bytes skipped:
   0:	00 00                	add    %al,(%rax)
   2:	48 b8 ff ff ff ff ff 	movabs $0xffff7fffffffffff,%rax
   9:	7f ff ff
   c:	48 39 c7             	cmp    %rax,%rdi
   f:	0f 86 05 01 00 00    	jbe    0x11a
  15:	49 83 e9 01          	sub    $0x1,%r9
  19:	48 89 fd             	mov    %rdi,%rbp
  1c:	48 b8 00 00 00 00 00 	movabs $0xdffffc0000000000,%rax
  23:	fc ff df
  26:	4d 89 ca             	mov    %r9,%r10
* 29:	48 c1 ed 03          	shr    $0x3,%rbp <-- trapping instruction
  2d:	49 c1 ea 03          	shr    $0x3,%r10
  31:	48 01 c5             	add    %rax,%rbp
  34:	49 01 c2             	add    %rax,%r10
  37:	48 89 e8             	mov    %rbp,%rax
  3a:	49 8d 5a 01          	lea    0x1(%r10),%rbx
  3e:	48                   	rex.W

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/11/07 15:43 bpf-next b8b5cb55f5d3 4c1be0be .config console log report info ci-upstream-bpf-next-kasan-gce KASAN: use-after-free Read in tcp_keepalive_timer
* Struck through repros no longer work on HEAD.