syzbot


KASAN: slab-use-after-free Read in handle_tx (2)

Status: upstream: reported on 2024/02/21 10:58
Subsystems: net
[Documentation on labels]
Reported-by: syzbot+827272712bd6d12c79a4@syzkaller.appspotmail.com
First crash: 59d, last: 3d18h
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [net?] KASAN: slab-use-after-free Read in handle_tx (2) 1 (2) 2024/02/21 11:05
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-use-after-free Read in handle_tx net 1 262d 258d 0/26 auto-obsoleted due to no activity on 2023/10/27 13:43
upstream KASAN: use-after-free Read in handle_tx net 15 795d 908d 0/26 auto-closed as invalid on 2022/05/12 13:20
upstream KASAN: use-after-free Read in handle_tx (2) net 1 431d 427d 0/26 auto-obsoleted due to no activity on 2023/05/11 18:22

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in handle_tx+0x1fa/0x640 drivers/net/caif/caif_serial.c:236
Read of size 8 at addr ffff888066822020 by task aoe_tx0/1242

CPU: 0 PID: 1242 Comm: aoe_tx0 Not tainted 6.8.0-syzkaller-08951-gfe46a7dd189e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/29/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report+0x143/0x180 mm/kasan/report.c:601
 handle_tx+0x1fa/0x640 drivers/net/caif/caif_serial.c:236
 __netdev_start_xmit include/linux/netdevice.h:4903 [inline]
 netdev_start_xmit include/linux/netdevice.h:4917 [inline]
 xmit_one net/core/dev.c:3531 [inline]
 dev_hard_start_xmit+0x26a/0x790 net/core/dev.c:3547
 __dev_queue_xmit+0x19f4/0x3b10 net/core/dev.c:4335
 dev_queue_xmit include/linux/netdevice.h:3091 [inline]
 tx+0x6b/0x180 drivers/block/aoe/aoenet.c:62
 kthread+0x23a/0x450 drivers/block/aoe/aoecmd.c:1229
 kthread+0x2f0/0x390 kernel/kthread.c:388
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:243
 </TASK>

Allocated by task 12031:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:370 [inline]
 __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:387
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 kmalloc_trace+0x1db/0x360 mm/slub.c:3997
 kmalloc include/linux/slab.h:628 [inline]
 kzalloc include/linux/slab.h:749 [inline]
 alloc_tty_struct+0xa9/0x7d0 drivers/tty/tty_io.c:3116
 tty_init_dev+0x5b/0x4c0 drivers/tty/tty_io.c:1415
 tty_open_by_driver drivers/tty/tty_io.c:2088 [inline]
 tty_open+0x9e5/0xdf0 drivers/tty/tty_io.c:2135
 chrdev_open+0x5b0/0x630 fs/char_dev.c:414
 do_dentry_open+0x907/0x15a0 fs/open.c:955
 do_open fs/namei.c:3642 [inline]
 path_openat+0x2860/0x3240 fs/namei.c:3799
 do_filp_open+0x235/0x490 fs/namei.c:3826
 do_sys_openat2+0x13e/0x1d0 fs/open.c:1406
 do_sys_open fs/open.c:1421 [inline]
 __do_sys_openat fs/open.c:1437 [inline]
 __se_sys_openat fs/open.c:1432 [inline]
 __x64_sys_openat+0x247/0x2a0 fs/open.c:1432
 do_syscall_64+0xfb/0x240
 entry_SYSCALL_64_after_hwframe+0x6d/0x75

Freed by task 9257:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579
 poison_slab_object+0xa6/0xe0 mm/kasan/common.c:240
 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2106 [inline]
 slab_free mm/slub.c:4280 [inline]
 kfree+0x14a/0x380 mm/slub.c:4390
 process_one_work kernel/workqueue.c:3254 [inline]
 process_scheduled_works+0xa00/0x1770 kernel/workqueue.c:3335
 worker_thread+0x86d/0xd70 kernel/workqueue.c:3416
 kthread+0x2f0/0x390 kernel/kthread.c:388
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:243

Last potentially related work creation:
 kasan_save_stack+0x3f/0x60 mm/kasan/common.c:47
 __kasan_record_aux_stack+0xac/0xc0 mm/kasan/generic.c:541
 insert_work+0x3e/0x330 kernel/workqueue.c:2248
 __queue_work+0xc14/0xec0 kernel/workqueue.c:2400
 queue_work_on+0x14f/0x250 kernel/workqueue.c:2435
 tty_release_struct+0xbc/0xe0 drivers/tty/tty_io.c:1707
 tty_release+0xd0c/0x12c0 drivers/tty/tty_io.c:1867
 __fput+0x429/0x8a0 fs/file_table.c:422
 task_work_run+0x24f/0x310 kernel/task_work.c:180
 exit_task_work include/linux/task_work.h:38 [inline]
 do_exit+0xa1b/0x27e0 kernel/exit.c:878
 do_group_exit+0x207/0x2c0 kernel/exit.c:1027
 get_signal+0x176e/0x1850 kernel/signal.c:2907
 arch_do_signal_or_restart+0x96/0x860 arch/x86/kernel/signal.c:310
 exit_to_user_mode_loop kernel/entry/common.c:105 [inline]
 exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:201 [inline]
 syscall_exit_to_user_mode+0xc9/0x360 kernel/entry/common.c:212
 do_syscall_64+0x10a/0x240 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x6d/0x75

The buggy address belongs to the object at ffff888066822000
 which belongs to the cache kmalloc-cg-2k of size 2048
The buggy address is located 32 bytes inside of
 freed 2048-byte region [ffff888066822000, ffff888066822800)

The buggy address belongs to the physical page:
page:ffffea00019a0800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x66820
head:ffffea00019a0800 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
memcg:ffff888054362a81
flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000840 ffff888014c4f3c0 ffffea0001fb3a00 dead000000000002
raw: 0000000000000000 0000000000080008 00000001ffffffff ffff888054362a81
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 6929, tgid 6929 (syz-executor.4), ts 305012222640, free_ts 304917818221
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x1ea/0x210 mm/page_alloc.c:1533
 prep_new_page mm/page_alloc.c:1540 [inline]
 get_page_from_freelist+0x33ea/0x3580 mm/page_alloc.c:3311
 __alloc_pages+0x256/0x680 mm/page_alloc.c:4569
 __alloc_pages_node include/linux/gfp.h:238 [inline]
 alloc_pages_node include/linux/gfp.h:261 [inline]
 alloc_slab_page+0x5f/0x160 mm/slub.c:2175
 allocate_slab mm/slub.c:2338 [inline]
 new_slab+0x84/0x2f0 mm/slub.c:2391
 ___slab_alloc+0xc73/0x1260 mm/slub.c:3525
 __slab_alloc mm/slub.c:3610 [inline]
 __slab_alloc_node mm/slub.c:3663 [inline]
 slab_alloc_node mm/slub.c:3835 [inline]
 __do_kmalloc_node mm/slub.c:3965 [inline]
 __kmalloc_node+0x2db/0x4e0 mm/slub.c:3973
 kmalloc_node include/linux/slab.h:648 [inline]
 kvmalloc_node+0x72/0x190 mm/util.c:634
 kvmalloc include/linux/slab.h:766 [inline]
 xt_alloc_table_info+0x3d/0xa0 net/netfilter/x_tables.c:1193
 do_replace net/ipv6/netfilter/ip6_tables.c:1139 [inline]
 do_ip6t_set_ctl+0xb03/0x3f90 net/ipv6/netfilter/ip6_tables.c:1636
 nf_setsockopt+0x295/0x2c0 net/netfilter/nf_sockopt.c:101
 do_sock_setsockopt+0x3af/0x720 net/socket.c:2311
 __sys_setsockopt+0x1ae/0x250 net/socket.c:2334
 __do_sys_setsockopt net/socket.c:2343 [inline]
 __se_sys_setsockopt net/socket.c:2340 [inline]
 __x64_sys_setsockopt+0xb5/0xd0 net/socket.c:2340
 do_syscall_64+0xfb/0x240
 entry_SYSCALL_64_after_hwframe+0x6d/0x75
page last free pid 5265 tgid 5265 stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1140 [inline]
 free_unref_page_prepare+0x95d/0xa80 mm/page_alloc.c:2346
 free_unref_page+0x37/0x3f0 mm/page_alloc.c:2486
 __slab_free+0x31b/0x3d0 mm/slub.c:4192
 qlink_free mm/kasan/quarantine.c:163 [inline]
 qlist_free_all+0x5e/0xc0 mm/kasan/quarantine.c:179
 kasan_quarantine_reduce+0x14f/0x170 mm/kasan/quarantine.c:286
 __kasan_slab_alloc+0x23/0x80 mm/kasan/common.c:322
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slub.c:3798 [inline]
 slab_alloc_node mm/slub.c:3845 [inline]
 kmalloc_node_trace+0x195/0x3a0 mm/slub.c:4005
 kmalloc_node include/linux/slab.h:644 [inline]
 kzalloc_node include/linux/slab.h:760 [inline]
 __get_vm_area_node+0x125/0x370 mm/vmalloc.c:2660
 __vmalloc_node_range+0x3df/0x14a0 mm/vmalloc.c:3352
 __vmalloc_node mm/vmalloc.c:3457 [inline]
 vzalloc+0x79/0x90 mm/vmalloc.c:3530
 alloc_counters+0xd7/0x760 net/ipv4/netfilter/ip_tables.c:799
 copy_entries_to_user net/ipv4/netfilter/ip_tables.c:821 [inline]
 get_entries net/ipv4/netfilter/ip_tables.c:1022 [inline]
 do_ipt_get_ctl+0xecc/0x1810 net/ipv4/netfilter/ip_tables.c:1660
 nf_getsockopt+0x299/0x2c0 net/netfilter/nf_sockopt.c:116
 ip_getsockopt+0x222/0x2e0 net/ipv4/ip_sockglue.c:1777
 tcp_getsockopt+0x163/0x1c0 net/ipv4/tcp.c:4373
 do_sock_getsockopt+0x373/0x850 net/socket.c:2373

Memory state around the buggy address:
 ffff888066821f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888066821f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888066822000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff888066822080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888066822100: 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
2024/03/27 18:43 upstream fe46a7dd189e 454571b6 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-use-after-free Read in handle_tx
2024/03/20 07:19 upstream fe46a7dd189e a485f239 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in handle_tx
2024/03/31 00:24 upstream 486291a0e624 6baf5069 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: slab-use-after-free Read in handle_tx
2024/02/17 12:06 upstream c1ca10ceffbb 578f7538 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: slab-use-after-free Read in handle_tx
2024/04/13 02:28 upstream 8f2c057754b2 c8349e48 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: slab-use-after-free Read in handle_tx
2024/04/13 02:27 upstream 8f2c057754b2 c8349e48 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: slab-use-after-free Read in handle_tx
2024/02/17 07:09 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 905b00721763 578f7538 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: slab-use-after-free Read in handle_tx
* Struck through repros no longer work on HEAD.