syzbot


KASAN: use-after-free Read in consume_skb

Status: closed as invalid on 2022/10/12 18:37
Subsystems: bpf net
[Documentation on labels]
First crash: 922d, last: 643d
Cause bisection: introduced by (bisect log) :
commit c63829182c37c2d6d0608976d15fa61ebebe9e6b
Author: Cong Wang <cong.wang@bytedance.com>
Date: Sun Jul 4 19:02:47 2021 +0000

  af_unix: Implement ->psock_update_sk_prot()

Crash: KASAN: use-after-free Read in consume_skb (log)
Repro: C syz .config
  
Fix bisection the fix commit could be any of (bisect log):
  7fd2bf83d59a Merge branch 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
  3cc40a443a04 Merge tag 'nios2_fixes_v6.0' of git://git.kernel.org/pub/scm/linux/kernel/git/dinguyen/linux
  
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-5-15 KASAN: use-after-free Read in consume_skb origin:lts C 8 12h36m 212d 0/2 upstream: reported C repro on 2023/09/21 02:29
android-6-1 KASAN: use-after-free Read in consume_skb C error done 4 164d 223d 0/2 auto-obsoleted due to no activity on 2024/02/15 15:09
upstream KASAN: slab-use-after-free Read in consume_skb net bpf C error 6 226d 227d 0/26 closed as invalid on 2023/10/04 10:50
Fix bisection attempts (8)
Created Duration User Patch Repo Result
2022/08/17 10:06 28m bisect fix upstream job log (2)
2022/07/16 16:37 20m bisect fix upstream job log (0) log
2022/06/16 16:15 21m bisect fix upstream job log (0) log
2022/05/17 15:22 19m bisect fix upstream job log (0) log
2022/04/16 19:22 18m bisect fix upstream job log (0) log
2022/03/17 19:02 19m bisect fix upstream job log (0) log
2022/02/15 18:42 20m bisect fix upstream job log (0) log
2022/01/16 18:22 20m bisect fix upstream job log (0) log

Sample crash report:
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000007
R13: 431bde82d7b634db R14: 0000000000000000 R15: 0000000000000000
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read include/linux/instrumented.h:71 [inline]
BUG: KASAN: use-after-free in atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
BUG: KASAN: use-after-free in refcount_read include/linux/refcount.h:147 [inline]
BUG: KASAN: use-after-free in skb_unref include/linux/skbuff.h:1066 [inline]
BUG: KASAN: use-after-free in consume_skb+0x2e/0x160 net/core/skbuff.c:907
Read of size 4 at addr ffff88807e26cd5c by task syz-executor679/6534

CPU: 1 PID: 6534 Comm: syz-executor679 Not tainted 5.15.0-rc4-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0x6c/0x309 mm/kasan/report.c:256
 __kasan_report mm/kasan/report.c:442 [inline]
 kasan_report.cold+0x83/0xdf mm/kasan/report.c:459
 check_region_inline mm/kasan/generic.c:183 [inline]
 kasan_check_range+0x13d/0x180 mm/kasan/generic.c:189
 instrument_atomic_read include/linux/instrumented.h:71 [inline]
 atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
 refcount_read include/linux/refcount.h:147 [inline]
 skb_unref include/linux/skbuff.h:1066 [inline]
 consume_skb+0x2e/0x160 net/core/skbuff.c:907
 __sk_msg_free+0x26d/0x360 net/core/skmsg.c:196
 sk_msg_free net/core/skmsg.c:209 [inline]
 __sk_psock_purge_ingress_msg net/core/skmsg.c:724 [inline]
 __sk_psock_zap_ingress net/core/skmsg.c:742 [inline]
 sk_psock_stop+0x415/0x620 net/core/skmsg.c:760
 sock_map_close+0x34a/0x780 net/core/sock_map.c:1516
 unix_release+0x7a/0xe0 net/unix/af_unix.c:948
 __sock_release+0xcd/0x280 net/socket.c:649
 sock_close+0x18/0x20 net/socket.c:1314
 __fput+0x288/0x9f0 fs/file_table.c:280
 task_work_run+0xdd/0x1a0 kernel/task_work.c:164
 exit_task_work include/linux/task_work.h:32 [inline]
 do_exit+0xbae/0x2a30 kernel/exit.c:825
 do_group_exit+0x125/0x310 kernel/exit.c:922
 __do_sys_exit_group kernel/exit.c:933 [inline]
 __se_sys_exit_group kernel/exit.c:931 [inline]
 __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:931
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7fcdd1779049
Code: Unable to access opcode bytes at RIP 0x7fcdd177901f.
RSP: 002b:00007ffd06871cb8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007fcdd17ed410 RCX: 00007fcdd1779049
RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
RBP: 0000000000000000 R08: ffffffffffffffc0 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fcdd17ed410
R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000001

Allocated by task 6534:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 __kasan_slab_alloc+0x83/0xb0 mm/kasan/common.c:467
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook mm/slab.h:519 [inline]
 slab_alloc_node mm/slub.c:3206 [inline]
 slab_alloc mm/slub.c:3214 [inline]
 kmem_cache_alloc+0x209/0x390 mm/slub.c:3219
 skb_clone+0x170/0x3c0 net/core/skbuff.c:1520
 sk_psock_verdict_recv+0x72/0x7e0 net/core/skmsg.c:1120
 unix_read_sock+0xd7/0x250 net/unix/af_unix.c:2420
 sk_psock_verdict_data_ready+0x11a/0x180 net/core/skmsg.c:1163
 unix_dgram_sendmsg+0xfa7/0x1950 net/unix/af_unix.c:1941
 sock_sendmsg_nosec net/socket.c:704 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:724
 ____sys_sendmsg+0x331/0x810 net/socket.c:2409
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2463
 __sys_sendmmsg+0x195/0x470 net/socket.c:2549
 __do_sys_sendmmsg net/socket.c:2578 [inline]
 __se_sys_sendmmsg net/socket.c:2575 [inline]
 __x64_sys_sendmmsg+0x99/0x100 net/socket.c:2575
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 1053:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38
 kasan_set_track+0x1c/0x30 mm/kasan/common.c:46
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:360
 ____kasan_slab_free mm/kasan/common.c:366 [inline]
 ____kasan_slab_free mm/kasan/common.c:328 [inline]
 __kasan_slab_free+0xff/0x130 mm/kasan/common.c:374
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1700 [inline]
 slab_free_freelist_hook+0x81/0x190 mm/slub.c:1725
 slab_free mm/slub.c:3483 [inline]
 kmem_cache_free+0x8a/0x5b0 mm/slub.c:3499
 kfree_skbmem+0xef/0x1b0 net/core/skbuff.c:699
 __kfree_skb net/core/skbuff.c:756 [inline]
 kfree_skb net/core/skbuff.c:773 [inline]
 kfree_skb+0x140/0x3f0 net/core/skbuff.c:767
 sock_drop include/linux/skmsg.h:309 [inline]
 sk_psock_backlog+0x93b/0xda0 net/core/skmsg.c:644
 process_one_work+0x9bf/0x16b0 kernel/workqueue.c:2297
 worker_thread+0x658/0x11f0 kernel/workqueue.c:2444
 kthread+0x3e5/0x4d0 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

The buggy address belongs to the object at ffff88807e26cc80
 which belongs to the cache skbuff_head_cache of size 232
The buggy address is located 220 bytes inside of
 232-byte region [ffff88807e26cc80, ffff88807e26cd68)
The buggy address belongs to the page:
page:ffffea0001f89b00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7e26c
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 dead000000000122 ffff8881445f7000
raw: 0000000000000000 00000000000c000c 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 0x12a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY), pid 6532, ts 57118420627, free_ts 57103748921
 create_dummy_stack mm/page_owner.c:59 [inline]
 register_dummy_stack+0x66/0xb0 mm/page_owner.c:65
 init_page_owner mm/page_owner.c:83 [inline]
 init_page_owner+0x44/0x890 mm/page_owner.c:78
 invoke_init_callbacks mm/page_ext.c:108 [inline]
 page_ext_init+0x4c6/0x4d9 mm/page_ext.c:417
 kernel_init_freeable+0x48b/0x73a init/main.c:1612
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1338 [inline]
 free_pcp_prepare+0x2c5/0x780 mm/page_alloc.c:1389
 free_unref_page_prepare mm/page_alloc.c:3315 [inline]
 free_unref_page+0x19/0x690 mm/page_alloc.c:3394
 kasan_depopulate_vmalloc_pte+0x5c/0x70 mm/kasan/shadow.c:375
 apply_to_pte_range mm/memory.c:2532 [inline]
 apply_to_pmd_range mm/memory.c:2576 [inline]
 apply_to_pud_range mm/memory.c:2612 [inline]
 apply_to_p4d_range mm/memory.c:2648 [inline]
 __apply_to_page_range+0x694/0x1080 mm/memory.c:2682
 kasan_release_vmalloc+0xa7/0xc0 mm/kasan/shadow.c:485
 __purge_vmap_area_lazy+0x8f9/0x1c50 mm/vmalloc.c:1704
 _vm_unmap_aliases.part.0+0x3f0/0x500 mm/vmalloc.c:2107
 _vm_unmap_aliases mm/vmalloc.c:2081 [inline]
 vm_unmap_aliases+0x47/0x50 mm/vmalloc.c:2130
 change_page_attr_set_clr+0x241/0x500 arch/x86/mm/pat/set_memory.c:1740
 change_page_attr_clear arch/x86/mm/pat/set_memory.c:1797 [inline]
 set_memory_ro+0x78/0xa0 arch/x86/mm/pat/set_memory.c:1943
 bpf_jit_binary_lock_ro include/linux/filter.h:890 [inline]
 bpf_int_jit_compile+0xe36/0x11e0 arch/x86/net/bpf_jit_comp.c:2368
 bpf_prog_select_runtime+0x464/0x6a0 kernel/bpf/core.c:1914
 bpf_migrate_filter+0x2dc/0x380 net/core/filter.c:1295
 bpf_prepare_filter net/core/filter.c:1343 [inline]
 bpf_prog_create_from_user+0x51b/0x660 net/core/filter.c:1437
 seccomp_prepare_filter kernel/seccomp.c:666 [inline]
 seccomp_prepare_user_filter kernel/seccomp.c:703 [inline]
 seccomp_set_mode_filter kernel/seccomp.c:1824 [inline]
 do_seccomp+0x388/0x2890 kernel/seccomp.c:1944
 prctl_set_seccomp+0x4a/0x70 kernel/seccomp.c:1997

Memory state around the buggy address:
 ffff88807e26cc00: fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc
 ffff88807e26cc80: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807e26cd00: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc
                                                    ^
 ffff88807e26cd80: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
 ffff88807e26ce00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (33):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/10/10 14:24 upstream 7fd2bf83d59a 838e7e2c .config console log report syz C ci-upstream-kasan-gce-root KASAN: use-after-free Read in consume_skb
2021/10/18 06:31 net-old fac3cb82a54a 0c5d9412 .config console log report syz C ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in consume_skb
2021/10/10 15:04 net-old 732b74d64704 838e7e2c .config console log report syz C ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in consume_skb
2021/10/10 13:42 net-old 732b74d64704 838e7e2c .config console log report syz C ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in consume_skb
2021/10/20 12:07 net-next-old 816219a86d21 418a00eb .config console log report syz C ci-upstream-net-kasan-gce KASAN: use-after-free Read in consume_skb
2021/10/10 16:01 net-next-old 0182d0788cd6 838e7e2c .config console log report syz C ci-upstream-net-kasan-gce KASAN: use-after-free Read in consume_skb
2021/10/10 15:27 net-next-old 0182d0788cd6 838e7e2c .config console log report syz C ci-upstream-net-kasan-gce KASAN: use-after-free Read in consume_skb
2021/12/02 16:52 upstream 58e1100fdc59 61f86278 .config console log report info ci-upstream-kasan-gce-root KASAN: use-after-free Read in consume_skb
2021/11/27 14:14 upstream c5c17547b778 63eeac02 .config console log report info ci-qemu-upstream KASAN: use-after-free Read in consume_skb
2021/11/27 08:43 upstream c5c17547b778 63eeac02 .config console log report info ci-qemu-upstream KASAN: use-after-free Read in consume_skb
2021/11/26 21:37 upstream a4849f6000e2 63eeac02 .config console log report info ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in consume_skb
2021/11/18 19:11 upstream 42eb8fdac2fc 31a30fc0 .config console log report info ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in consume_skb
2021/11/17 16:37 upstream 8ab774587903 cafff8b6 .config console log report info ci-upstream-kasan-gce-root KASAN: use-after-free Read in consume_skb
2021/11/15 14:18 upstream fa55b7dcdc43 83f5c9b5 .config console log report info ci-upstream-kasan-gce-root KASAN: use-after-free Read in consume_skb
2021/11/12 14:29 upstream 5833291ab6de 75b04091 .config console log report info ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in consume_skb
2021/11/12 10:58 upstream 5833291ab6de 75b04091 .config console log report info ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in consume_skb
2021/10/31 08:24 upstream 119c85055d86 098b5d53 .config console log report info ci-upstream-kasan-gce-root KASAN: use-after-free Read in consume_skb
2021/10/25 11:47 upstream 87066fdd2e30 4f0000ee .config console log report info ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in consume_skb
2021/10/10 12:43 upstream 7fd2bf83d59a 838e7e2c .config console log report info ci-upstream-kasan-gce-root KASAN: use-after-free Read in consume_skb
2021/12/12 15:11 net-old ee60e626d536 49ca1f59 .config console log report info ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in consume_skb
2021/10/23 19:08 net-old 1f83b835a3ea 282f03fb .config console log report info ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in consume_skb
2021/10/10 09:30 net-old 732b74d64704 838e7e2c .config console log report info ci-upstream-net-this-kasan-gce KASAN: use-after-free Read in consume_skb
2021/12/15 10:28 net-next-old 6cf7a1ac0fed f752fb53 .config console log report info ci-upstream-net-kasan-gce KASAN: use-after-free Read in consume_skb
2021/12/07 03:55 net-next-old 4c375272fb0b 0230ba3e .config console log report info ci-upstream-net-kasan-gce KASAN: use-after-free Read in consume_skb
2021/12/01 04:17 net-next-old 196073f9c44b 80270552 .config console log report info ci-upstream-net-kasan-gce KASAN: use-after-free Read in consume_skb
2021/12/17 18:22 linux-next fbf252e09678 44068e19 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in consume_skb
2021/12/11 15:36 linux-next ea922272cbe5 49ca1f59 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in consume_skb
2021/12/04 20:12 linux-next f81e94e91878 a617004c .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in consume_skb
2021/12/04 15:24 linux-next f81e94e91878 a617004c .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in consume_skb
2021/11/17 21:22 linux-next fd96a4057bd0 cafff8b6 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in consume_skb
2021/11/16 01:25 linux-next 09bd48c4acfa 83f5c9b5 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in consume_skb
2021/11/13 07:18 linux-next f2e19fd15bd7 83f5c9b5 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in consume_skb
2021/11/02 12:49 linux-next 9150de4aac1e 098b5d53 .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in consume_skb
* Struck through repros no longer work on HEAD.