syzbot


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

Status: fixed on 2022/03/08 16:11
Subsystems: net
[Documentation on labels]
Reported-by: syzbot+e4df4e1389e28972e955@syzkaller.appspotmail.com
Fix commit: 563bcbae3ba2 net: vlan: fix a UAF in vlan_dev_real_dev()
First crash: 944d, last: 917d
Cause bisection: failed (error log, bisect log)
  
Discussions (11)
Title Replies (including bot) Last reply
[PATCH 5.10 000/575] 5.10.80-rc1 review 595 (595) 2022/07/31 10:51
[PATCH net-next 0/3] net: ipvlan: fix potential UAF problem for phy_dev 6 (6) 2022/03/15 02:21
[PATCH 4.19 000/323] 4.19.218-rc1 review 339 (339) 2021/12/04 10:30
[PATCH net v2] net: vlan: fix a UAF in vlan_dev_real_dev() 18 (18) 2021/11/26 01:48
[PATCH 4.14 000/251] 4.14.256-rc1 review 262 (262) 2021/11/25 13:07
[PATCH 5.15 000/917] 5.15.3-rc1 review 945 (945) 2021/11/24 18:04
[PATCH 5.4 000/355] 5.4.160-rc1 review 373 (373) 2021/11/16 16:50
[PATCH 5.14 000/849] 5.14.19-rc1 review 859 (859) 2021/11/16 14:04
[PATCH net] net: vlan: fix a UAF in vlan_dev_real_dev() 10 (10) 2021/10/30 04:09
[PATCH rdma-rc] IB/core: fix a UAF for netdev in netdevice_event process 7 (7) 2021/10/26 09:03
[syzbot] KASAN: use-after-free Read in vlan_dev_real_dev (2) 0 (1) 2021/10/11 17:38
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in vlan_dev_real_dev net 6 1097d 1213d 0/26 auto-closed as invalid on 2021/08/24 06:33
Last patch testing requests (1)
Created Duration User Patch Repo Result
2021/10/18 18:24 10m phind.uet@gmail.com linux-next report log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in is_vlan_dev include/linux/if_vlan.h:74 [inline]
BUG: KASAN: use-after-free in vlan_dev_real_dev+0xf9/0x120 net/8021q/vlan_core.c:106
Read of size 4 at addr ffff8880781120c4 by task kworker/u4:1/10

CPU: 1 PID: 10 Comm: kworker/u4:1 Not tainted 5.15.0-rc4-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: gid-cache-wq netdevice_event_work_handler
Call Trace:
 __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
 is_vlan_dev include/linux/if_vlan.h:74 [inline]
 vlan_dev_real_dev+0xf9/0x120 net/8021q/vlan_core.c:106
 rdma_vlan_dev_real_dev include/rdma/ib_addr.h:267 [inline]
 is_eth_port_of_netdev_filter.part.0+0xb1/0x2c0 drivers/infiniband/core/roce_gid_mgmt.c:157
 is_eth_port_of_netdev_filter+0x28/0x40 drivers/infiniband/core/roce_gid_mgmt.c:153
 ib_enum_roce_netdev+0x177/0x2f0 drivers/infiniband/core/device.c:2302
 ib_enum_all_roce_netdevs+0xbd/0x130 drivers/infiniband/core/device.c:2331
 netdevice_event_work_handler+0x9c/0x230 drivers/infiniband/core/roce_gid_mgmt.c:627
 process_one_work+0x9bf/0x16b0 kernel/workqueue.c:2297
 worker_thread+0x658/0x11f0 kernel/workqueue.c:2444
 kthread+0x3e5/0x4d0 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Allocated by task 6877:
 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_kmalloc mm/kasan/common.c:513 [inline]
 ____kasan_kmalloc mm/kasan/common.c:472 [inline]
 __kasan_kmalloc+0xa4/0xd0 mm/kasan/common.c:522
 kmalloc_node include/linux/slab.h:614 [inline]
 kvmalloc_node+0x61/0x120 mm/util.c:587
 kvmalloc include/linux/mm.h:805 [inline]
 kvzalloc include/linux/mm.h:813 [inline]
 alloc_netdev_mqs+0x98/0xe80 net/core/dev.c:10794
 rtnl_create_link+0x95a/0xb80 net/core/rtnetlink.c:3183
 __rtnl_newlink+0xf73/0x1750 net/core/rtnetlink.c:3448
 rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3506
 rtnetlink_rcv_msg+0x413/0xb80 net/core/rtnetlink.c:5572
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2510
 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
 netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1345
 netlink_sendmsg+0x86d/0xdb0 net/netlink/af_netlink.c:1935
 sock_sendmsg_nosec net/socket.c:704 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:724
 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2409
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2463
 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2492
 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

Freed by task 6874:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track+0x1c/0x30 mm/kasan/common.c:46
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:360
 ____kasan_slab_free mm/kasan/common.c:366 [inline]
 ____kasan_slab_free mm/kasan/common.c:328 [inline]
 __kasan_slab_free+0xff/0x130 mm/kasan/common.c:374
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1700 [inline]
 slab_free_freelist_hook+0x81/0x190 mm/slub.c:1725
 slab_free mm/slub.c:3483 [inline]
 kfree+0xe4/0x530 mm/slub.c:4543
 kvfree+0x42/0x50 mm/util.c:620
 device_release+0x9f/0x240 drivers/base/core.c:2231
 kobject_cleanup lib/kobject.c:705 [inline]
 kobject_release lib/kobject.c:736 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x1c8/0x540 lib/kobject.c:753
 put_device+0x1b/0x30 drivers/base/core.c:3502
 free_netdev+0x3e0/0x5b0 net/core/dev.c:10934
 ppp_destroy_interface+0x2ab/0x340 drivers/net/ppp/ppp_generic.c:3397
 ppp_release+0x1bf/0x240 drivers/net/ppp/ppp_generic.c:410
 __fput+0x288/0x9f0 fs/file_table.c:280
 task_work_run+0xdd/0x1a0 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:175 [inline]
 exit_to_user_mode_prepare+0x27e/0x290 kernel/entry/common.c:207
 __syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
 syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300
 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x44/0xae

The buggy address belongs to the object at ffff888078112000
 which belongs to the cache kmalloc-cg-4k of size 4096
The buggy address is located 196 bytes inside of
 4096-byte region [ffff888078112000, ffff888078113000)
The buggy address belongs to the page:
page:ffffea0001e04400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x78110
head:ffffea0001e04400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888010c4c280
raw: 0000000000000000 0000000000040004 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 6880, ts 73160788272, free_ts 73155121785
 prep_new_page mm/page_alloc.c:2424 [inline]
 get_page_from_freelist+0xa72/0x2f80 mm/page_alloc.c:4153
 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5375
 alloc_pages+0x1a7/0x300 mm/mempolicy.c:2197
 alloc_slab_page mm/slub.c:1763 [inline]
 allocate_slab mm/slub.c:1900 [inline]
 new_slab+0x319/0x490 mm/slub.c:1963
 ___slab_alloc+0x921/0xfe0 mm/slub.c:2994
 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3081
 slab_alloc_node mm/slub.c:3172 [inline]
 __kmalloc_node+0x2d2/0x370 mm/slub.c:4435
 kmalloc_node include/linux/slab.h:614 [inline]
 kvmalloc_node+0x61/0x120 mm/util.c:587
 kvmalloc include/linux/mm.h:805 [inline]
 seq_buf_alloc fs/seq_file.c:38 [inline]
 seq_read_iter+0x7e7/0x1240 fs/seq_file.c:210
 kernfs_fop_read_iter+0x44f/0x5f0 fs/kernfs/file.c:241
 call_read_iter include/linux/fs.h:2157 [inline]
 new_sync_read+0x421/0x6e0 fs/read_write.c:404
 vfs_read+0x35c/0x600 fs/read_write.c:485
 ksys_read+0x12d/0x250 fs/read_write.c:623
 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:1338 [inline]
 free_pcp_prepare+0x2c5/0x780 mm/page_alloc.c:1389
 free_unref_page_prepare mm/page_alloc.c:3315 [inline]
 free_unref_page+0x19/0x690 mm/page_alloc.c:3394
 __unfreeze_partials+0x340/0x360 mm/slub.c:2495
 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:254 [inline]
 slab_post_alloc_hook mm/slab.h:519 [inline]
 slab_alloc_node mm/slub.c:3206 [inline]
 slab_alloc mm/slub.c:3214 [inline]
 kmem_cache_alloc+0x142/0x390 mm/slub.c:3219
 anon_vma_alloc mm/rmap.c:90 [inline]
 anon_vma_fork+0xed/0x630 mm/rmap.c:355
 dup_mmap kernel/fork.c:569 [inline]
 dup_mm+0xa07/0x13e0 kernel/fork.c:1453
 copy_mm kernel/fork.c:1505 [inline]
 copy_process+0x6fcf/0x7580 kernel/fork.c:2194
 kernel_clone+0xe7/0xac0 kernel/fork.c:2584
 __do_sys_clone+0xc8/0x110 kernel/fork.c:2701
 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:
 ffff888078111f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888078112000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888078112080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                           ^
 ffff888078112100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888078112180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (7):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/10/11 17:38 net-old 732b74d64704 838e7e2c .config console log report syz C ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in vlan_dev_real_dev
2021/10/11 21:34 net-next-old ce8bd03c47fc 838e7e2c .config console log report syz C ci-upstream-net-kasan-gce KASAN: use-after-free Read in vlan_dev_real_dev
2021/10/11 14:35 net-old 732b74d64704 838e7e2c .config console log report info ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in vlan_dev_real_dev
2021/09/26 08:33 net-old 7fe7f3182a0d 8cac236e .config console log report info ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in vlan_dev_real_dev
2021/09/26 03:25 net-old 7fe7f3182a0d 8cac236e .config console log report info ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in vlan_dev_real_dev
2021/10/23 01:45 net-next-old 016c89460d34 282f03fb .config console log report info ci-upstream-net-kasan-gce KASAN: use-after-free Read in vlan_dev_real_dev
2021/10/17 20:53 net-next-old 4e6e167bc049 0c5d9412 .config console log report info ci-upstream-net-kasan-gce KASAN: use-after-free Read in vlan_dev_real_dev
* Struck through repros no longer work on HEAD.