[v5.15] KASAN: use-after-free Read in consume_skb

2 views
Skip to first unread message

syzbot

unread,
Aug 9, 2024, 4:33:22 AMAug 9
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 7e89efd3ae1c Linux 5.15.164
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=14ce98ed980000
kernel config: https://syzkaller.appspot.com/x/.config?x=ef3d6716c47442fa
dashboard link: https://syzkaller.appspot.com/bug?extid=0a1590c9227146cfa13f
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/8949eb798dd1/disk-7e89efd3.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/36cb290bbce6/vmlinux-7e89efd3.xz
kernel image: https://storage.googleapis.com/syzbot-assets/1baafc742606/bzImage-7e89efd3.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+0a1590...@syzkaller.appspotmail.com

==================================================================
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:1107 [inline]
BUG: KASAN: use-after-free in consume_skb+0x35/0x140 net/core/skbuff.c:910
Read of size 4 at addr ffff888019e1435c by task kworker/0:10/3709

CPU: 0 PID: 3709 Comm: kworker/0:10 Not tainted 5.15.164-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
Workqueue: events sk_psock_destroy
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2d0 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
kasan_check_range+0x27e/0x290 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:1107 [inline]
consume_skb+0x35/0x140 net/core/skbuff.c:910
__sk_msg_free+0x2cd/0x350 net/core/skmsg.c:205
sk_msg_free net/core/skmsg.c:218 [inline]
__sk_psock_purge_ingress_msg net/core/skmsg.c:764 [inline]
__sk_psock_zap_ingress net/core/skmsg.c:777 [inline]
sk_psock_destroy+0x3ab/0x870 net/core/skmsg.c:809
process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
kthread+0x3f6/0x4f0 kernel/kthread.c:334
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
</TASK>

Allocated by task 4966:
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_slab_alloc+0x8e/0xc0 mm/kasan/common.c:467
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]
kmem_cache_alloc+0xf3/0x280 mm/slub.c:3233
skb_clone+0x1bb/0x350 net/core/skbuff.c:1523
sk_psock_verdict_recv+0x51/0x5b0 net/core/skmsg.c:1176
unix_read_sock+0x124/0x360 net/unix/af_unix.c:2428
sk_psock_verdict_data_ready+0x147/0x1a0 net/core/skmsg.c:1219
unix_dgram_sendmsg+0x15fc/0x2090 net/unix/af_unix.c:1942
sock_sendmsg_nosec net/socket.c:704 [inline]
__sock_sendmsg net/socket.c:716 [inline]
____sys_sendmsg+0x59e/0x8f0 net/socket.c:2431
___sys_sendmsg+0x252/0x2e0 net/socket.c:2485
__sys_sendmsg net/socket.c:2514 [inline]
__do_sys_sendmsg net/socket.c:2523 [inline]
__se_sys_sendmsg+0x19a/0x260 net/socket.c:2521
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

Freed by task 3709:
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]
kmem_cache_free+0x91/0x1f0 mm/slub.c:3515
kfree_skb include/linux/skbuff.h:1123 [inline]
sock_drop include/linux/skmsg.h:313 [inline]
__sk_psock_zap_ingress net/core/skmsg.c:775 [inline]
sk_psock_destroy+0x1a8/0x870 net/core/skmsg.c:809
process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
kthread+0x3f6/0x4f0 kernel/kthread.c:334
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

The buggy address belongs to the object at ffff888019e14280
which belongs to the cache skbuff_head_cache of size 232
The buggy address is located 220 bytes inside of
232-byte region [ffff888019e14280, ffff888019e14368)
The buggy address belongs to the page:
page:ffffea0000678500 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x19e14
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea000074a980 0000000c0000000c ffff888144bf0140
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 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 3239, ts 32621516360, free_ts 32561618175
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:5423
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]
kmem_cache_alloc_node+0x1ba/0x2c0 mm/slub.c:3256
__alloc_skb+0xdd/0x590 net/core/skbuff.c:415
alloc_skb include/linux/skbuff.h:1167 [inline]
alloc_skb_with_frags+0xa3/0x780 net/core/skbuff.c:6170
sock_alloc_send_pskb+0x915/0xa50 net/core/sock.c:2530
unix_dgram_sendmsg+0x6fd/0x2090 net/unix/af_unix.c:1805
sock_sendmsg_nosec net/socket.c:704 [inline]
__sock_sendmsg net/socket.c:716 [inline]
sock_write_iter+0x39b/0x530 net/socket.c:1079
do_iter_readv_writev+0x594/0x7a0
do_iter_write+0x1e6/0x760 fs/read_write.c:855
vfs_writev fs/read_write.c:928 [inline]
do_writev+0x281/0x470 fs/read_write.c:971
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
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_list+0x1f7/0x8e0 mm/page_alloc.c:3433
release_pages+0x1bb9/0x1f40 mm/swap.c:963
tlb_batch_pages_flush mm/mmu_gather.c:49 [inline]
tlb_flush_mmu_free mm/mmu_gather.c:240 [inline]
tlb_flush_mmu mm/mmu_gather.c:247 [inline]
tlb_finish_mmu+0x177/0x320 mm/mmu_gather.c:338
exit_mmap+0x3cd/0x670 mm/mmap.c:3188
__mmput+0x112/0x3b0 kernel/fork.c:1126
exit_mm+0x688/0x7f0 kernel/exit.c:550
do_exit+0x626/0x2480 kernel/exit.c:861
do_group_exit+0x144/0x310 kernel/exit.c:996
__do_sys_exit_group kernel/exit.c:1007 [inline]
__se_sys_exit_group kernel/exit.c:1005 [inline]
__x64_sys_exit_group+0x3b/0x40 kernel/exit.c:1005
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

Memory state around the buggy address:
ffff888019e14200: fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc
ffff888019e14280: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888019e14300: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc
^
ffff888019e14380: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
ffff888019e14400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Aug 9, 2024, 6:13:19 AMAug 9
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 7e89efd3ae1c Linux 5.15.164
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=11554a6b980000
kernel config: https://syzkaller.appspot.com/x/.config?x=ef3d6716c47442fa
dashboard link: https://syzkaller.appspot.com/bug?extid=0a1590c9227146cfa13f
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17214323980000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=161e98ed980000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/8949eb798dd1/disk-7e89efd3.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/36cb290bbce6/vmlinux-7e89efd3.xz
kernel image: https://storage.googleapis.com/syzbot-assets/1baafc742606/bzImage-7e89efd3.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+0a1590...@syzkaller.appspotmail.com

==================================================================
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:1107 [inline]
BUG: KASAN: use-after-free in consume_skb+0x35/0x140 net/core/skbuff.c:910
Read of size 4 at addr ffff888070ce30dc by task kworker/1:4/3568

CPU: 1 PID: 3568 Comm: kworker/1:4 Not tainted 5.15.164-syzkaller #0
Allocated by task 3567:
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_slab_alloc+0x8e/0xc0 mm/kasan/common.c:467
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]
kmem_cache_alloc+0xf3/0x280 mm/slub.c:3233
skb_clone+0x1bb/0x350 net/core/skbuff.c:1523
sk_psock_verdict_recv+0x51/0x5b0 net/core/skmsg.c:1176
unix_read_sock+0x124/0x360 net/unix/af_unix.c:2428
sk_psock_verdict_data_ready+0x147/0x1a0 net/core/skmsg.c:1219
unix_dgram_sendmsg+0x15fc/0x2090 net/unix/af_unix.c:1942
sock_sendmsg_nosec net/socket.c:704 [inline]
__sock_sendmsg net/socket.c:716 [inline]
____sys_sendmsg+0x59e/0x8f0 net/socket.c:2431
___sys_sendmsg+0x252/0x2e0 net/socket.c:2485
__sys_sendmsg net/socket.c:2514 [inline]
__do_sys_sendmsg net/socket.c:2523 [inline]
__se_sys_sendmsg+0x19a/0x260 net/socket.c:2521
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

Freed by task 3568:
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]
kmem_cache_free+0x91/0x1f0 mm/slub.c:3515
kfree_skb include/linux/skbuff.h:1123 [inline]
sock_drop include/linux/skmsg.h:313 [inline]
__sk_psock_zap_ingress net/core/skmsg.c:775 [inline]
sk_psock_destroy+0x1a8/0x870 net/core/skmsg.c:809
process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
kthread+0x3f6/0x4f0 kernel/kthread.c:334
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

The buggy address belongs to the object at ffff888070ce3000
which belongs to the cache skbuff_head_cache of size 232
The buggy address is located 220 bytes inside of
232-byte region [ffff888070ce3000, ffff888070ce30e8)
The buggy address belongs to the page:
page:ffffea0001c338c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x70ce3
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 dead000000000122 ffff888016be4140
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 3567, ts 52315128637, free_ts 52314155286
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:5423
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]
slab_alloc mm/slub.c:3228 [inline]
kmem_cache_alloc+0x18e/0x280 mm/slub.c:3233
skb_clone+0x1bb/0x350 net/core/skbuff.c:1523
sk_psock_verdict_recv+0x51/0x5b0 net/core/skmsg.c:1176
unix_read_sock+0x124/0x360 net/unix/af_unix.c:2428
sk_psock_verdict_data_ready+0x147/0x1a0 net/core/skmsg.c:1219
unix_dgram_sendmsg+0x15fc/0x2090 net/unix/af_unix.c:1942
sock_sendmsg_nosec net/socket.c:704 [inline]
__sock_sendmsg net/socket.c:716 [inline]
____sys_sendmsg+0x59e/0x8f0 net/socket.c:2431
___sys_sendmsg+0x252/0x2e0 net/socket.c:2485
__sys_sendmsg net/socket.c:2514 [inline]
__do_sys_sendmsg net/socket.c:2523 [inline]
__se_sys_sendmsg+0x19a/0x260 net/socket.c:2521
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
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
__vunmap+0x8d4/0xa20 mm/vmalloc.c:2621
adjust_insn_aux_data kernel/bpf/verifier.c:12050 [inline]
bpf_patch_insn_data+0x828/0xe00 kernel/bpf/verifier.c:12103
convert_ctx_accesses kernel/bpf/verifier.c:12645 [inline]
bpf_check+0x5ffd/0x12d00 kernel/bpf/verifier.c:14142
bpf_prog_load+0x12b3/0x1b60 kernel/bpf/syscall.c:2353
__sys_bpf+0x343/0x670 kernel/bpf/syscall.c:4651
__do_sys_bpf kernel/bpf/syscall.c:4755 [inline]
__se_sys_bpf kernel/bpf/syscall.c:4753 [inline]
__x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:4753
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

Memory state around the buggy address:
ffff888070ce2f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888070ce3000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888070ce3080: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc
^
ffff888070ce3100: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
ffff888070ce3180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
Reply all
Reply to author
Forward
0 new messages