syzbot


KASAN: use-after-free Read in siw_query_port

Status: auto-obsoleted due to no activity on 2023/10/29 16:51
Reported-by: syzbot+dbd8f2df369218fa09da@syzkaller.appspotmail.com
First crash: 315d, last: 288d
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 KASAN: use-after-free Read in siw_query_port (2) 10 30d 143d 0/3 upstream: reported on 2023/12/13 22:42
upstream KASAN: slab-use-after-free Read in siw_query_port rdma 50 243d 358d 0/26 auto-obsoleted due to no activity on 2023/11/13 22:18
linux-6.1 KASAN: use-after-free Read in siw_query_port 5 198d 275d 0/3 auto-obsoleted due to no activity on 2024/01/27 18:37
linux-6.1 KASAN: use-after-free Read in siw_query_port (2) 12 1d13h 85d 0/3 upstream: reported on 2024/02/09 22:01

Sample crash report:
hsr0 speed is unknown, defaulting to 1000
==================================================================
BUG: KASAN: use-after-free in siw_query_port+0x342/0x430 drivers/infiniband/sw/siw/siw_verbs.c:175
Read of size 4 at addr ffff88807d6980d8 by task kworker/1:28/22885

CPU: 1 PID: 22885 Comm: kworker/1:28 Not tainted 5.15.120-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2023
Workqueue: infiniband ib_cache_event_task
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description+0x63/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
 siw_query_port+0x342/0x430 drivers/infiniband/sw/siw/siw_verbs.c:175
 ib_cache_update+0x1a8/0xaf0 drivers/infiniband/core/cache.c:1481
 ib_cache_event_task+0xef/0x1e0 drivers/infiniband/core/cache.c:1555
 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2307
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2454
 kthread+0x3f6/0x4f0 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
 </TASK>

Allocated by task 4644:
 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:434 [inline]
 ____kasan_kmalloc+0xba/0xf0 mm/kasan/common.c:513
 kasan_kmalloc include/linux/kasan.h:264 [inline]
 __kmalloc_node+0x199/0x390 mm/slub.c:4455
 kmalloc_node include/linux/slab.h:614 [inline]
 kvmalloc_node+0x80/0x140 mm/util.c:619
 kvmalloc include/linux/mm.h:805 [inline]
 kvzalloc include/linux/mm.h:813 [inline]
 alloc_netdev_mqs+0x85/0xc10 net/core/dev.c:10817
 rtnl_create_link+0x2e9/0x9c0 net/core/rtnetlink.c:3186
 __rtnl_newlink net/core/rtnetlink.c:3458 [inline]
 rtnl_newlink+0x13a4/0x2060 net/core/rtnetlink.c:3516
 rtnetlink_rcv_msg+0x993/0xee0 net/core/rtnetlink.c:5593
 netlink_rcv_skb+0x1cf/0x410 net/netlink/af_netlink.c:2504
 netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
 netlink_unicast+0x7b6/0x980 net/netlink/af_netlink.c:1356
 netlink_sendmsg+0xa30/0xd60 net/netlink/af_netlink.c:1923
 sock_sendmsg_nosec net/socket.c:704 [inline]
 sock_sendmsg net/socket.c:724 [inline]
 __sys_sendto+0x564/0x720 net/socket.c:2039
 __do_sys_sendto net/socket.c:2051 [inline]
 __se_sys_sendto net/socket.c:2047 [inline]
 __x64_sys_sendto+0xda/0xf0 net/socket.c:2047
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Freed by task 144:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kfree+0xf1/0x270 mm/slub.c:4559
 device_release+0x91/0x1c0
 kobject_cleanup lib/kobject.c:713 [inline]
 kobject_release lib/kobject.c:744 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x224/0x460 lib/kobject.c:761
 netdev_run_todo+0xaaf/0xc40 net/core/dev.c:10635
 default_device_exit_batch+0x395/0x3f0 net/core/dev.c:11597
 ops_exit_list net/core/net_namespace.c:174 [inline]
 cleanup_net+0x763/0xb60 net/core/net_namespace.c:596
 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2307
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2454
 kthread+0x3f6/0x4f0 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

The buggy address belongs to the object at ffff88807d698000
 which belongs to the cache kmalloc-cg-4k of size 4096
The buggy address is located 216 bytes inside of
 4096-byte region [ffff88807d698000, ffff88807d699000)
The buggy address belongs to the page:
page:ffffea0001f5a600 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88807d69a000 pfn:0x7d698
head:ffffea0001f5a600 order:3 compound_mapcount:0 compound_pincount:0
memcg:ffff88801f93e481
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0001ec7c08 ffffea0000909a08 ffff888011c4c280
raw: ffff88807d69a000 0000000000040003 00000001ffffffff ffff88801f93e481
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 4251, ts 130583014195, free_ts 130573190681
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x322a/0x33c0 mm/page_alloc.c:4159
 __alloc_pages+0x272/0x700 mm/page_alloc.c:5421
 alloc_slab_page mm/slub.c:1775 [inline]
 allocate_slab mm/slub.c:1912 [inline]
 new_slab+0xbb/0x4b0 mm/slub.c:1975
 ___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
 __slab_alloc mm/slub.c:3095 [inline]
 slab_alloc_node mm/slub.c:3186 [inline]
 __kmalloc_node+0x1fa/0x390 mm/slub.c:4451
 kmalloc_node include/linux/slab.h:614 [inline]
 kvmalloc_node+0x80/0x140 mm/util.c:619
 kvmalloc include/linux/mm.h:805 [inline]
 seq_buf_alloc fs/seq_file.c:38 [inline]
 seq_read_iter+0x1fe/0xd10 fs/seq_file.c:210
 call_read_iter include/linux/fs.h:2097 [inline]
 new_sync_read fs/read_write.c:404 [inline]
 vfs_read+0xa9f/0xe10 fs/read_write.c:485
 ksys_read+0x1a2/0x2c0 fs/read_write.c:623
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
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 mm/page_alloc.c:1391 [inline]
 free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
 free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
 do_slab_free mm/slub.c:3487 [inline]
 ___cache_free+0xe3/0x100 mm/slub.c:3506
 qlist_free_all+0x36/0x90 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xc0 mm/kasan/common.c:444
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 __kmalloc+0x120/0x300 mm/slub.c:4403
 kmalloc include/linux/slab.h:596 [inline]
 tomoyo_realpath_from_path+0xd8/0x5e0 security/tomoyo/realpath.c:254
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_check_open_permission+0x22c/0x490 security/tomoyo/file.c:771
 security_file_open+0x5f/0xa0 security/security.c:1650
 do_dentry_open+0x315/0xfb0 fs/open.c:813
 do_open fs/namei.c:3538 [inline]
 path_openat+0x2702/0x2f20 fs/namei.c:3672
 do_filp_open+0x21c/0x460 fs/namei.c:3699
 do_sys_openat2+0x13b/0x500 fs/open.c:1211
 do_sys_open fs/open.c:1227 [inline]
 __do_sys_openat fs/open.c:1243 [inline]
 __se_sys_openat fs/open.c:1238 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1238

Memory state around the buggy address:
 ffff88807d697f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88807d698000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807d698080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff88807d698100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807d698180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/07/21 16:50 linux-5.15.y d54cfc420586 abdf9bae .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in siw_query_port
2023/06/25 02:47 linux-5.15.y f67653019430 79782afc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in siw_query_port
2023/07/12 00:02 linux-5.15.y d54cfc420586 2f19aa4f .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in siw_query_port
* Struck through repros no longer work on HEAD.