syzbot


KASAN: use-after-free Read in macvlan_broadcast

Status: fixed on 2020/02/09 09:28
Reported-by: syzbot+f0d66963aa2425f578ce@syzkaller.appspotmail.com
Fix commit: 4a953272f2d2 macvlan: do not assume mac_header is set in macvlan_broadcast()
First crash: 1572d, last: 1569d
Fix bisection: fixed by (bisect log) :
commit 4a953272f2d2db63bba97137b64b3f1770634e00
Author: Eric Dumazet <edumazet@google.com>
Date: Mon Jan 6 20:30:48 2020 +0000

  macvlan: do not assume mac_header is set in macvlan_broadcast()

  
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in macvlan_broadcast net C done 12 1570d 1572d 15/26 fixed on 2020/02/18 14:31
linux-4.19 KASAN: use-after-free Read in macvlan_broadcast C done 7 1569d 1572d 1/1 fixed on 2020/02/09 09:28

Sample crash report:
IPv6: ADDRCONF(NETDEV_UP): macvlan0: link is not ready
IPv6: ADDRCONF(NETDEV_UP): macvlan1: link is not ready
protocol 88fb is buggy, dev hsr_slave_0
protocol 88fb is buggy, dev hsr_slave_1
==================================================================
BUG: KASAN: use-after-free in __get_unaligned_cpu32 include/linux/unaligned/packed_struct.h:19 [inline]
BUG: KASAN: use-after-free in mc_hash drivers/net/macvlan.c:255 [inline]
BUG: KASAN: use-after-free in macvlan_broadcast+0x4b9/0x5c0 drivers/net/macvlan.c:281
Read of size 4 at addr ffff8880a49325c1 by task syz-executor822/7165

CPU: 0 PID: 7165 Comm: syz-executor822 Not tainted 4.14.162-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x142/0x197 lib/dump_stack.c:58
 print_address_description.cold+0x7c/0x1dc mm/kasan/report.c:252
 kasan_report_error mm/kasan/report.c:351 [inline]
 kasan_report mm/kasan/report.c:409 [inline]
 kasan_report.cold+0xa9/0x2af mm/kasan/report.c:393
 __asan_report_load_n_noabort+0xf/0x20 mm/kasan/report.c:440
 __get_unaligned_cpu32 include/linux/unaligned/packed_struct.h:19 [inline]
 mc_hash drivers/net/macvlan.c:255 [inline]
 macvlan_broadcast+0x4b9/0x5c0 drivers/net/macvlan.c:281
 macvlan_queue_xmit drivers/net/macvlan.c:522 [inline]
 macvlan_start_xmit+0x56b/0x72d drivers/net/macvlan.c:565
 __netdev_start_xmit include/linux/netdevice.h:4038 [inline]
 netdev_start_xmit include/linux/netdevice.h:4047 [inline]
 packet_direct_xmit+0x431/0x640 net/packet/af_packet.c:269
 packet_snd net/packet/af_packet.c:2994 [inline]
 packet_sendmsg+0x1dd4/0x5a60 net/packet/af_packet.c:3019
 sock_sendmsg_nosec net/socket.c:646 [inline]
 sock_sendmsg+0xce/0x110 net/socket.c:656
 SYSC_sendto+0x206/0x310 net/socket.c:1763
 SyS_sendto+0x40/0x50 net/socket.c:1731
 do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x442329
RSP: 002b:00007ffd458867d8 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000442329
RDX: 000000000000000e RSI: 0000000020000080 RDI: 0000000000000003
RBP: 00007ffd45886800 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00000000004038c0 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 6486:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x45/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc mm/kasan/kasan.c:551 [inline]
 kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:529
 kasan_slab_alloc+0xf/0x20 mm/kasan/kasan.c:489
 kmem_cache_alloc_node+0x144/0x780 mm/slab.c:3642
 alloc_task_struct_node kernel/fork.c:156 [inline]
 dup_task_struct kernel/fork.c:515 [inline]
 copy_process.part.0+0x17d5/0x6a70 kernel/fork.c:1611
 copy_process kernel/fork.c:1586 [inline]
 _do_fork+0x19e/0xce0 kernel/fork.c:2070
 SYSC_clone kernel/fork.c:2180 [inline]
 SyS_clone+0x37/0x50 kernel/fork.c:2174
 do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 6521:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x45/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0x75/0xc0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3496 [inline]
 kmem_cache_free+0x83/0x2b0 mm/slab.c:3758
 free_task_struct kernel/fork.c:161 [inline]
 free_task+0xb0/0xe0 kernel/fork.c:383
 __put_task_struct+0x1c8/0x480 kernel/fork.c:420
 put_task_struct include/linux/sched/task.h:98 [inline]
 delayed_put_task_struct+0x20b/0x2f0 kernel/exit.c:180
 __rcu_reclaim kernel/rcu/rcu.h:195 [inline]
 rcu_do_batch kernel/rcu/tree.c:2699 [inline]
 invoke_rcu_callbacks kernel/rcu/tree.c:2962 [inline]
 __rcu_process_callbacks kernel/rcu/tree.c:2929 [inline]
 rcu_process_callbacks+0x7b8/0x12b0 kernel/rcu/tree.c:2946
 __do_softirq+0x244/0x9a0 kernel/softirq.c:288

The buggy address belongs to the object at ffff8880a49322c0
 which belongs to the cache task_struct of size 6144
The buggy address is located 769 bytes inside of
 6144-byte region [ffff8880a49322c0, ffff8880a4933ac0)
The buggy address belongs to the page:
page:ffffea0002924c80 count:1 mapcount:0 mapping:ffff8880a49322c0 index:0x0 compound_mapcount: 0
flags: 0xfffe0000008100(slab|head)
raw: 00fffe0000008100 ffff8880a49322c0 0000000000000000 0000000100000001
raw: ffffea000299ae20 ffffea0001fc7aa0 ffff88821f8307c0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a4932480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a4932500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a4932580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                           ^
 ffff8880a4932600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a4932680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (8):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/01/07 19:28 linux-4.14.y 84f5ad468100 1bcd407e .config console log report syz C ci2-linux-4-14
2020/01/07 18:43 linux-4.14.y 84f5ad468100 1bcd407e .config console log report syz C ci2-linux-4-14
2020/01/07 18:14 linux-4.14.y 84f5ad468100 1bcd407e .config console log report syz C ci2-linux-4-14
2020/01/07 17:39 linux-4.14.y 84f5ad468100 1bcd407e .config console log report syz C ci2-linux-4-14
2020/01/09 13:40 linux-4.14.y b0cdffaa546e ddc3e859 .config console log report ci2-linux-4-14
2020/01/09 05:55 linux-4.14.y 84f5ad468100 ddc3e859 .config console log report ci2-linux-4-14
2020/01/07 07:46 linux-4.14.y 84f5ad468100 53430d97 .config console log report ci2-linux-4-14
2020/01/06 13:49 linux-4.14.y 84f5ad468100 438e1227 .config console log report ci2-linux-4-14
* Struck through repros no longer work on HEAD.