syzbot


KASAN: use-after-free Read in __cgroup_bpf_attach (3)

Status: auto-obsoleted due to no activity on 2022/11/06 11:00
Reported-by: syzbot+d20b8f3be3f0bf8f5d3f@syzkaller.appspotmail.com
First crash: 617d, last: 617d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-5-10 KASAN: use-after-free Read in __cgroup_bpf_attach 2 876d 878d 0/2 auto-closed as invalid on 2022/02/20 17:36
android-5-10 KASAN: use-after-free Read in __cgroup_bpf_attach (2) 1 724d 724d 0/2 auto-closed as invalid on 2022/07/21 22:36

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in prog_list_prog kernel/bpf/cgroup.c:174 [inline]
BUG: KASAN: use-after-free in prog_list_length kernel/bpf/cgroup.c:187 [inline]
BUG: KASAN: use-after-free in __cgroup_bpf_attach+0x5c1/0xd20 kernel/bpf/cgroup.c:467
Read of size 8 at addr ffff88810cab9f18 by task syz-executor.1/8480

CPU: 0 PID: 8480 Comm: syz-executor.1 Tainted: G        W         5.10.134-syzkaller-01772-gf6ce9a9115d5 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/22/2022
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
 prog_list_prog kernel/bpf/cgroup.c:174 [inline]
 prog_list_length kernel/bpf/cgroup.c:187 [inline]
 __cgroup_bpf_attach+0x5c1/0xd20 kernel/bpf/cgroup.c:467
 cgroup_bpf_attach+0x4a/0x70 kernel/cgroup/cgroup.c:6635
 cgroup_bpf_link_attach+0x239/0x4a0 kernel/bpf/cgroup.c:934
 link_create+0x540/0x6e0 kernel/bpf/syscall.c:4092
 __do_sys_bpf+0x528/0x6c0 kernel/bpf/syscall.c:4497
 __se_sys_bpf kernel/bpf/syscall.c:4383 [inline]
 __x64_sys_bpf+0x7a/0x90 kernel/bpf/syscall.c:4383
 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x61/0xc6
RIP: 0033:0x7fac83661279
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fac827d7168 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007fac83773f80 RCX: 00007fac83661279
RDX: 0000000000000010 RSI: 0000000020000340 RDI: 000000000000001c
RBP: 00007fac836bb189 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffe135ab11f R14: 00007fac827d7300 R15: 0000000000022000

Allocated by task 8402:
 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]
 cgroup_bpf_link_attach+0x12e/0x4a0 kernel/bpf/cgroup.c:918
 link_create+0x540/0x6e0 kernel/bpf/syscall.c:4092
 __do_sys_bpf+0x528/0x6c0 kernel/bpf/syscall.c:4497
 __se_sys_bpf kernel/bpf/syscall.c:4383 [inline]
 __x64_sys_bpf+0x7a/0x90 kernel/bpf/syscall.c:4383
 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x61/0xc6

Freed by task 8402:
 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
 bpf_cgroup_link_dealloc+0x15/0x20 kernel/bpf/cgroup.c:849
 bpf_link_free kernel/bpf/syscall.c:2354 [inline]
 bpf_link_put+0x243/0x270 kernel/bpf/syscall.c:2376
 bpf_link_release+0x3b/0x40 kernel/bpf/syscall.c:2384
 __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 ffff88810cab9f00
 which belongs to the cache kmalloc-96 of size 96
The buggy address is located 24 bytes inside of
 96-byte region [ffff88810cab9f00, ffff88810cab9f60)
The buggy address belongs to the page:
page:ffffea000432ae40 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10cab9
flags: 0x8000000000000200(slab)
raw: 8000000000000200 dead000000000100 dead000000000122 ffff888100043680
raw: 0000000000000000 0000000000200020 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 392, ts 106836146880, free_ts 106836072830
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2385 [inline]
 prep_new_page mm/page_alloc.c:2391 [inline]
 get_page_from_freelist+0x745/0x760 mm/page_alloc.c:4067
 __alloc_pages_nodemask+0x3b6/0x890 mm/page_alloc.c:5117
 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]
 kmem_cache_alloc_trace+0x20e/0x330 mm/slub.c:2981
 kmem_cache_alloc_node_trace include/linux/slab.h:440 [inline]
 kmalloc_node include/linux/slab.h:570 [inline]
 kzalloc_node include/linux/slab.h:675 [inline]
 __get_vm_area_node+0x134/0x200 mm/vmalloc.c:2077
 __vmalloc_node_range+0xd5/0x6d0 mm/vmalloc.c:2560
 __vmalloc_node mm/vmalloc.c:2608 [inline]
 vzalloc+0x78/0x90 mm/vmalloc.c:2661
 alloc_counters+0x68/0x550 net/ipv6/netfilter/ip6_tables.c:817
 copy_entries_to_user net/ipv6/netfilter/ip6_tables.c:839 [inline]
 get_entries net/ipv6/netfilter/ip6_tables.c:1041 [inline]
 do_ip6t_get_ctl+0xe9c/0x18b0 net/ipv6/netfilter/ip6_tables.c:1672
 nf_getsockopt+0x27a/0x2a0 net/netfilter/nf_sockopt.c:116
 ipv6_getsockopt+0x1dd7/0x30c0 net/ipv6/ipv6_sockglue.c:1486
 tcp_getsockopt+0x1d4/0x2bf0 net/ipv4/tcp.c:3975
 sock_common_getsockopt+0x99/0xb0 net/core/sock.c:3238
 __sys_getsockopt+0x2ac/0x470 net/socket.c:2163
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1331 [inline]
 free_pcp_prepare+0x18c/0x1c0 mm/page_alloc.c:1405
 free_unref_page_prepare mm/page_alloc.c:3291 [inline]
 free_unref_page mm/page_alloc.c:3345 [inline]
 free_the_page mm/page_alloc.c:5176 [inline]
 __free_pages+0x390/0x570 mm/page_alloc.c:5185
 __vunmap+0x846/0x980 mm/vmalloc.c:2275
 __vfree mm/vmalloc.c:2323 [inline]
 vfree+0x5c/0x80 mm/vmalloc.c:2354
 copy_entries_to_user net/ipv4/netfilter/ip_tables.c:867 [inline]
 get_entries net/ipv4/netfilter/ip_tables.c:1023 [inline]
 do_ipt_get_ctl+0x11f3/0x18a0 net/ipv4/netfilter/ip_tables.c:1662
 nf_getsockopt+0x27a/0x2a0 net/netfilter/nf_sockopt.c:116
 ip_getsockopt+0x13df/0x1d70 net/ipv4/ip_sockglue.c:1777
 tcp_getsockopt+0x1d4/0x2bf0 net/ipv4/tcp.c:3975
 sock_common_getsockopt+0x99/0xb0 net/core/sock.c:3238
 __sys_getsockopt+0x2ac/0x470 net/socket.c:2163
 __do_sys_getsockopt net/socket.c:2178 [inline]
 __se_sys_getsockopt net/socket.c:2175 [inline]
 __x64_sys_getsockopt+0xbf/0xd0 net/socket.c:2175
 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x61/0xc6

Memory state around the buggy address:
 ffff88810cab9e00: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
 ffff88810cab9e80: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
>ffff88810cab9f00: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
                            ^
 ffff88810cab9f80: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
 ffff88810caba000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/08/08 10:52 android12-5.10-lts f6ce9a9115d5 88e3a122 .config console log report info ci2-android-5-10 KASAN: use-after-free Read in __cgroup_bpf_attach
* Struck through repros no longer work on HEAD.