syzbot


KASAN: use-after-free Read in xpad_presence_work

Status: auto-obsoleted due to no activity on 2023/02/13 20:32
Reported-by: syzbot+8edd9b98ff5c9c29100d@syzkaller.appspotmail.com
First crash: 752d, last: 752d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in dev_driver_string drivers/base/core.c:1969 [inline]
BUG: KASAN: use-after-free in __dev_printk+0x80/0x1b0 drivers/base/core.c:4464
Read of size 8 at addr ffff88816ae8c2c8 by task kworker/1:25/22306

CPU: 1 PID: 22306 Comm: kworker/1:25 Tainted: G        W         5.10.149-syzkaller-01350-g0118fb827bc7 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/11/2022
Workqueue: events xpad_presence_work
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x81/0x3c0 mm/kasan/report.c:233
 __kasan_report mm/kasan/report.c:419 [inline]
 kasan_report+0x1a4/0x1f0 mm/kasan/report.c:436
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:309
 dev_driver_string drivers/base/core.c:1969 [inline]
 __dev_printk+0x80/0x1b0 drivers/base/core.c:4464
 _dev_err+0x12f/0x176 drivers/base/core.c:4506
 xpad_presence_work+0x1ce/0x240 drivers/input/joystick/xpad.c:796
 process_one_work+0x726/0xc10 kernel/workqueue.c:2296
 worker_thread+0xb27/0x1550 kernel/workqueue.c:2442
 kthread+0x349/0x3d0 kernel/kthread.c:313
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:299

Allocated by task 22306:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:428 [inline]
 ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:507
 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:516
 kasan_kmalloc include/linux/kasan.h:269 [inline]
 kmem_cache_alloc_trace+0x1dd/0x330 mm/slub.c:2983
 kmalloc include/linux/slab.h:552 [inline]
 kzalloc include/linux/slab.h:664 [inline]
 input_allocate_device+0x50/0x220 drivers/input/input.c:1826
 xpad_init_input+0x1e/0x13a0 drivers/input/joystick/xpad.c:1658
 xpad_presence_work+0x59/0x240 drivers/input/joystick/xpad.c:793
 process_one_work+0x726/0xc10 kernel/workqueue.c:2296
 worker_thread+0xb27/0x1550 kernel/workqueue.c:2442
 kthread+0x349/0x3d0 kernel/kthread.c:313
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:299

Freed by task 22306:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4c/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:357
 ____kasan_slab_free+0x121/0x160 mm/kasan/common.c:360
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:368
 kasan_slab_free include/linux/kasan.h:235 [inline]
 slab_free_hook mm/slub.c:1604 [inline]
 slab_free_freelist_hook+0xcc/0x1a0 mm/slub.c:1630
 slab_free mm/slub.c:3212 [inline]
 kfree+0xc3/0x290 mm/slub.c:4200
 input_dev_release+0xaf/0xc0 drivers/input/input.c:1558
 device_release+0x9c/0x1d0 drivers/base/core.c:2115
 kobject_cleanup lib/kobject.c:705 [inline]
 kobject_release lib/kobject.c:736 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x163/0x240 lib/kobject.c:753
 put_device+0x1f/0x30 drivers/base/core.c:3347
 input_put_device include/linux/input.h:373 [inline]
 input_free_device+0xb9/0xf0 drivers/input/input.c:1934
 xpad_init_input+0xf9d/0x13a0 drivers/input/joystick/xpad.c:1748
 xpad_presence_work+0x59/0x240 drivers/input/joystick/xpad.c:793
 process_one_work+0x726/0xc10 kernel/workqueue.c:2296
 worker_thread+0xb27/0x1550 kernel/workqueue.c:2442
 kthread+0x349/0x3d0 kernel/kthread.c:313
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:299

Last potentially related work creation:
 kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xca/0xf0 mm/kasan/generic.c:345
 __call_rcu kernel/rcu/tree.c:2967 [inline]
 call_rcu+0x140/0x1300 kernel/rcu/tree.c:3041
 netlink_release+0x1334/0x1780 net/netlink/af_netlink.c:809
 __sock_release net/socket.c:597 [inline]
 sock_close+0xdb/0x250 net/socket.c:1267
 __fput+0x348/0x7c0 fs/file_table.c:281
 ____fput+0x15/0x20 fs/file_table.c:314
 task_work_run+0x147/0x1b0 kernel/task_work.c:154
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_user_mode_loop+0xc8/0xe0 kernel/entry/common.c:164
 exit_to_user_mode_prepare kernel/entry/common.c:191 [inline]
 syscall_exit_to_user_mode+0x77/0xa0 kernel/entry/common.c:266
 do_syscall_64+0x40/0x70 arch/x86/entry/common.c:56
 entry_SYSCALL_64_after_hwframe+0x61/0xc6

Second to last potentially related work creation:
 kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xca/0xf0 mm/kasan/generic.c:345
 __call_rcu kernel/rcu/tree.c:2967 [inline]
 call_rcu+0x140/0x1300 kernel/rcu/tree.c:3041
 netlink_release+0x1334/0x1780 net/netlink/af_netlink.c:809
 __sock_release net/socket.c:597 [inline]
 sock_close+0xdb/0x250 net/socket.c:1267
 __fput+0x348/0x7c0 fs/file_table.c:281
 ____fput+0x15/0x20 fs/file_table.c:314
 task_work_run+0x147/0x1b0 kernel/task_work.c:154
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_user_mode_loop+0xc8/0xe0 kernel/entry/common.c:164
 exit_to_user_mode_prepare kernel/entry/common.c:191 [inline]
 syscall_exit_to_user_mode+0x77/0xa0 kernel/entry/common.c:266
 do_syscall_64+0x40/0x70 arch/x86/entry/common.c:56
 entry_SYSCALL_64_after_hwframe+0x61/0xc6

The buggy address belongs to the object at ffff88816ae8c000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 712 bytes inside of
 2048-byte region [ffff88816ae8c000, ffff88816ae8c800)
The buggy address belongs to the page:
page:ffffea0005aba200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x16ae88
head:ffffea0005aba200 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x8000000000010200(slab|head)
raw: 8000000000010200 dead000000000100 dead000000000122 ffff888100042d80
raw: 0000000000000000 0000000080080008 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 0x1d2a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 32612, ts 2014283564373, free_ts 2014280588964
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2386 [inline]
 prep_new_page mm/page_alloc.c:2392 [inline]
 get_page_from_freelist+0x755/0x810 mm/page_alloc.c:4073
 __alloc_pages_nodemask+0x3b6/0x890 mm/page_alloc.c:5160
 alloc_slab_page mm/slub.c:1815 [inline]
 allocate_slab+0x78/0x540 mm/slub.c:1817
 new_slab mm/slub.c:1878 [inline]
 new_slab_objects mm/slub.c:2636 [inline]
 ___slab_alloc+0x131/0x2e0 mm/slub.c:2800
 __slab_alloc+0x63/0xa0 mm/slub.c:2840
 slab_alloc_node mm/slub.c:2922 [inline]
 slab_alloc mm/slub.c:2964 [inline]
 __kmalloc_track_caller+0x23e/0x350 mm/slub.c:4545
 __kmalloc_reserve net/core/skbuff.c:143 [inline]
 __alloc_skb+0xbe/0x580 net/core/skbuff.c:211
 alloc_skb include/linux/skbuff.h:1101 [inline]
 nlmsg_new include/net/netlink.h:953 [inline]
 inet6_ifinfo_notify+0x70/0x110 net/ipv6/addrconf.c:6010
 addrconf_notify+0xa4e/0xe90 net/ipv6/addrconf.c:3664
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0x9e/0x110 kernel/notifier.c:410
 __dev_notify_flags+0x2ef/0x5f0 net/core/dev.c:2054
 dev_change_flags+0xec/0x190 net/core/dev.c:8573
 do_setlink+0xc3e/0x3b50 net/core/rtnetlink.c:2709
 __rtnl_newlink net/core/rtnetlink.c:3379 [inline]
 rtnl_newlink+0x166a/0x1ff0 net/core/rtnetlink.c:3494
 rtnetlink_rcv_msg+0x95a/0xc60 net/core/rtnetlink.c:5571
 netlink_rcv_skb+0x1f0/0x460 net/netlink/af_netlink.c:2515
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1332 [inline]
 __free_pages_ok+0x7f8/0x830 mm/page_alloc.c:1612
 free_the_page mm/page_alloc.c:5221 [inline]
 __free_pages+0x383/0x570 mm/page_alloc.c:5228
 kfree+0x226/0x290 mm/slub.c:4197
 kvfree+0x35/0x40 mm/util.c:647
 ptr_ring_cleanup include/linux/ptr_ring.h:671 [inline]
 wg_packet_queue_free+0x52b/0x5c0 drivers/net/wireguard/queueing.c:46
 wg_destruct+0x211/0x300 drivers/net/wireguard/device.c:242
 netdev_run_todo+0xbcd/0xe10 net/core/dev.c:10305
 rtnl_unlock+0xe/0x10 net/core/rtnetlink.c:112
 default_device_exit_batch+0x440/0x4a0 net/core/dev.c:11252
 ops_exit_list net/core/net_namespace.c:192 [inline]
 cleanup_net+0x77c/0xd70 net/core/net_namespace.c:608
 process_one_work+0x726/0xc10 kernel/workqueue.c:2296
 worker_thread+0xb27/0x1550 kernel/workqueue.c:2442
 kthread+0x349/0x3d0 kernel/kthread.c:313
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:299

Memory state around the buggy address:
 ffff88816ae8c180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88816ae8c200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88816ae8c280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                              ^
 ffff88816ae8c300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88816ae8c380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
input input42: unable to init device: -12

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/10/31 09:07 android12-5.10-lts 0118fb827bc7 2a71366b .config console log report info ci2-android-5-10 KASAN: use-after-free Read in xpad_presence_work
* Struck through repros no longer work on HEAD.