syzbot


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

Status: upstream: reported on 2023/12/13 22:42
Reported-by: syzbot+15a94a0531011bda93cc@syzkaller.appspotmail.com
First crash: 143d, last: 30d
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
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-5.15 KASAN: use-after-free Read in siw_query_port 3 288d 315d 0/3 auto-obsoleted due to no activity on 2023/10/29 16:51
linux-6.1 KASAN: use-after-free Read in siw_query_port (2) 12 1d14h 85d 0/3 upstream: reported on 2024/02/09 22:01

Sample crash report:
macsec0 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 ffff8880758bc0d8 by task kworker/0:17/27964

CPU: 0 PID: 27964 Comm: kworker/0:17 Not tainted 5.15.153-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
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:2310
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
 kthread+0x3f6/0x4f0 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
 </TASK>

Allocated by task 22785:
 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:10843
 rtnl_create_link+0x2e9/0x9c0 net/core/rtnetlink.c:3206
 __rtnl_newlink net/core/rtnetlink.c:3491 [inline]
 rtnl_newlink+0x13d2/0x2070 net/core/rtnetlink.c:3549
 rtnetlink_rcv_msg+0x993/0xee0 net/core/rtnetlink.c:5629
 netlink_rcv_skb+0x1cf/0x410 net/netlink/af_netlink.c:2505
 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:1924
 sock_sendmsg_nosec net/socket.c:704 [inline]
 __sock_sendmsg net/socket.c:716 [inline]
 __sys_sendto+0x564/0x720 net/socket.c:2058
 __do_sys_sendto net/socket.c:2070 [inline]
 __se_sys_sendto net/socket.c:2066 [inline]
 __x64_sys_sendto+0xda/0xf0 net/socket.c:2066
 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 3604:
 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:10661
 default_device_exit_batch+0x395/0x3f0 net/core/dev.c:11627
 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:2310
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
 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 ffff8880758bc000
 which belongs to the cache kmalloc-cg-4k of size 4096
The buggy address is located 216 bytes inside of
 4096-byte region [ffff8880758bc000, ffff8880758bd000)
The buggy address belongs to the page:
page:ffffea0001d62e00 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880758be000 pfn:0x758b8
head:ffffea0001d62e00 order:3 compound_mapcount:0 compound_pincount:0
memcg:ffff8880611e5641
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0001305e08 ffffea0001565a08 ffff888011c4c280
raw: ffff8880758be000 0000000000040003 00000001ffffffff ffff8880611e5641
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 2963, ts 702796864090, free_ts 632239366564
 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:2142 [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
 free_pg_vec net/packet/af_packet.c:4275 [inline]
 packet_set_ring+0x19ea/0x2520 net/packet/af_packet.c:4494
 packet_release+0x770/0xc40 net/packet/af_packet.c:3115
 __sock_release net/socket.c:649 [inline]
 sock_close+0xcd/0x230 net/socket.c:1336
 __fput+0x3bf/0x890 fs/file_table.c:280
 task_work_run+0x129/0x1a0 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop+0x106/0x130 kernel/entry/common.c:175
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:208
 __syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline]
 syscall_exit_to_user_mode+0x5d/0x250 kernel/entry/common.c:301
 do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Memory state around the buggy address:
 ffff8880758bbf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880758bc000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880758bc080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff8880758bc100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880758bc180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (10):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/04/04 11:04 linux-5.15.y 9465fef4ae35 0ee3535e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in siw_query_port
2024/04/03 15:46 linux-5.15.y 9465fef4ae35 51c4dcff .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in siw_query_port
2024/04/03 03:32 linux-5.15.y 9465fef4ae35 7925100d .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in siw_query_port
2024/04/02 13:45 linux-5.15.y 9465fef4ae35 eb2966c4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in siw_query_port
2024/03/30 02:50 linux-5.15.y 9465fef4ae35 6baf5069 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in siw_query_port
2024/02/16 04:40 linux-5.15.y 6139f2a02fe0 578f7538 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in siw_query_port
2024/01/29 17:20 linux-5.15.y 6139f2a02fe0 991a98f4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in siw_query_port
2024/01/22 18:38 linux-5.15.y ddcaf4999061 9bd8dcda .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in siw_query_port
2024/01/12 21:02 linux-5.15.y 26c690eff0a5 551587c1 .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/12/13 22:41 linux-5.15.y d0fc081c6241 3222d10c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in siw_query_port
* Struck through repros no longer work on HEAD.