syzbot


KASAN: use-after-free Read in macvlan_broadcast

Status: fixed on 2020/02/09 09:28
Reported-by: syzbot+b95be9194cee45eb2a01@syzkaller.appspotmail.com
Fix commit: 5f3274c53ae7 macvlan: do not assume mac_header is set in macvlan_broadcast()
First crash: 1564d, last: 1561d
Fix bisection: fixed by (bisect log) :
commit 5f3274c53ae7049755b29ec0c351f145cb68270c
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 1562d 1564d 15/26 fixed on 2020/02/18 14:31
linux-4.14 KASAN: use-after-free Read in macvlan_broadcast C done 8 1561d 1564d 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+0x57c/0x660 drivers/net/macvlan.c:281
Read of size 4 at addr ffff88809b55fa41 by task syz-executor603/7889

CPU: 1 PID: 7889 Comm: syz-executor603 Not tainted 4.19.93-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x197/0x210 lib/dump_stack.c:118
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report mm/kasan/report.c:412 [inline]
 kasan_report.cold+0x8c/0x2ba mm/kasan/report.c:396
 __asan_report_load_n_noabort+0xf/0x20 mm/kasan/report.c:443
 __get_unaligned_cpu32 include/linux/unaligned/packed_struct.h:19 [inline]
 mc_hash drivers/net/macvlan.c:255 [inline]
 macvlan_broadcast+0x57c/0x660 drivers/net/macvlan.c:281
 macvlan_queue_xmit drivers/net/macvlan.c:524 [inline]
 macvlan_start_xmit+0x408/0x785 drivers/net/macvlan.c:563
 __netdev_start_xmit include/linux/netdevice.h:4308 [inline]
 netdev_start_xmit include/linux/netdevice.h:4317 [inline]
 dev_direct_xmit+0x34d/0x650 net/core/dev.c:3909
 packet_direct_xmit+0xf9/0x170 net/packet/af_packet.c:246
 packet_snd net/packet/af_packet.c:2958 [inline]
 packet_sendmsg+0x3bb2/0x6440 net/packet/af_packet.c:2983
 sock_sendmsg_nosec net/socket.c:622 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:632
IPv6: ADDRCONF(NETDEV_CHANGE): macvlan0: link becomes ready
 __sys_sendto+0x262/0x380 net/socket.c:1787
IPv6: ADDRCONF(NETDEV_CHANGE): macvlan1: link becomes ready
 __do_sys_sendto net/socket.c:1799 [inline]
 __se_sys_sendto net/socket.c:1795 [inline]
 __x64_sys_sendto+0xe1/0x1a0 net/socket.c:1795
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x442529
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 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 0f 83 5b 10 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffd492895f8 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000442529
RDX: 000000000000000e RSI: 0000000020000080 RDI: 0000000000000003
RBP: 0000000000000004 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000403aa0 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 7703:
 save_stack+0x45/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc mm/kasan/kasan.c:553 [inline]
 kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:531
 kasan_slab_alloc+0xf/0x20 mm/kasan/kasan.c:490
 kmem_cache_alloc+0x12e/0x700 mm/slab.c:3559
 anon_vma_chain_alloc mm/rmap.c:129 [inline]
 anon_vma_clone+0xde/0x480 mm/rmap.c:269
 anon_vma_fork+0x8f/0x4a0 mm/rmap.c:332
 dup_mmap kernel/fork.c:494 [inline]
 dup_mm kernel/fork.c:1278 [inline]
 copy_mm kernel/fork.c:1334 [inline]
 copy_process.part.0+0x34e5/0x7a30 kernel/fork.c:1887
 copy_process kernel/fork.c:1684 [inline]
 _do_fork+0x257/0xfd0 kernel/fork.c:2197
 __do_sys_clone kernel/fork.c:2304 [inline]
 __se_sys_clone kernel/fork.c:2298 [inline]
 __x64_sys_clone+0xbf/0x150 kernel/fork.c:2298
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 7704:
 save_stack+0x45/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3503 [inline]
 kmem_cache_free+0x86/0x260 mm/slab.c:3765
 anon_vma_chain_free mm/rmap.c:134 [inline]
 unlink_anon_vmas+0x2ba/0x860 mm/rmap.c:401
 free_pgtables+0x1af/0x2f0 mm/memory.c:640
 exit_mmap+0x2d1/0x530 mm/mmap.c:3098
 __mmput kernel/fork.c:1005 [inline]
 mmput+0x15f/0x4c0 kernel/fork.c:1026
 exec_mmap fs/exec.c:1043 [inline]
 flush_old_exec+0x8d9/0x1c20 fs/exec.c:1276
 load_elf_binary+0x9c0/0x53a0 fs/binfmt_elf.c:869
 search_binary_handler fs/exec.c:1653 [inline]
 search_binary_handler+0x179/0x570 fs/exec.c:1631
 load_script+0x671/0x8d0 fs/binfmt_script.c:148
 search_binary_handler fs/exec.c:1653 [inline]
 search_binary_handler+0x179/0x570 fs/exec.c:1631
 exec_binprm fs/exec.c:1695 [inline]
 __do_execve_file.isra.0+0x1227/0x2150 fs/exec.c:1819
 do_execveat_common fs/exec.c:1866 [inline]
 do_execve fs/exec.c:1883 [inline]
 __do_sys_execve fs/exec.c:1964 [inline]
 __se_sys_execve fs/exec.c:1959 [inline]
 __x64_sys_execve+0x8f/0xc0 fs/exec.c:1959
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88809b55fa10
 which belongs to the cache anon_vma_chain of size 80
The buggy address is located 49 bytes inside of
 80-byte region [ffff88809b55fa10, ffff88809b55fa60)
The buggy address belongs to the page:
page:ffffea00026d57c0 count:1 mapcount:0 mapping:ffff88821bc334c0 index:0xffff88809b55f380
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffffea0002118f08 ffffea0002835f08 ffff88821bc334c0
raw: ffff88809b55f380 ffff88809b55f000 000000010000001b 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809b55f900: fb fb fc fc fc fc fb fb fb fb fb fb fb fb fb fb
 ffff88809b55f980: fc fc fc fc fb fb fb fb fb fb fb fb fb fb fc fc
>ffff88809b55fa00: fc fc fb fb fb fb fb fb fb fb fb fb fc fc fc fc
                                           ^
 ffff88809b55fa80: fb fb fb fb fb fb fb fb fb fb fc fc fc fc fb fb
 ffff88809b55fb00: fb fb fb fb fb fb fb fb fc fc fc fc fb fb fb fb
==================================================================

Crashes (7):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/01/07 08:54 linux-4.19.y 3d40d7117e35 53430d97 .config console log report syz C ci2-linux-4-19
2020/01/06 15:20 linux-4.19.y 3d40d7117e35 438e1227 .config console log report syz C ci2-linux-4-19
2020/01/06 14:19 linux-4.19.y 3d40d7117e35 438e1227 .config console log report syz C ci2-linux-4-19
2020/01/09 13:36 linux-4.19.y cb1f9a169a0e ddc3e859 .config console log report ci2-linux-4-19
2020/01/07 08:28 linux-4.19.y 3d40d7117e35 53430d97 .config console log report ci2-linux-4-19
2020/01/07 07:39 linux-4.19.y 3d40d7117e35 53430d97 .config console log report ci2-linux-4-19
2020/01/06 13:52 linux-4.19.y 3d40d7117e35 438e1227 .config console log report ci2-linux-4-19
* Struck through repros no longer work on HEAD.