syzbot


KASAN: use-after-free Write in tcp_sendmsg_locked (2)

Status: closed as invalid on 2023/09/01 06:55
Subsystems: net
[Documentation on labels]
First crash: 802d, last: 783d
Similar bugs (1)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Write in tcp_sendmsg_locked net 24 1 858d 858d 0/29 closed as invalid on 2023/05/31 08:10

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in instrument_copy_from_user_before include/linux/instrumented.h:129 [inline]
BUG: KASAN: use-after-free in copyin.part.0+0x57/0x80 lib/iov_iter.c:192
Write of size 156 at addr ffff88807bb38efc by task sshd/4988

CPU: 1 PID: 4988 Comm: sshd Not tainted 6.4.0-syzkaller-01406-ge8f75c0270d9 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106
 print_address_description.constprop.0+0x2c/0x3c0 mm/kasan/report.c:351
 print_report mm/kasan/report.c:462 [inline]
 kasan_report+0x11c/0x130 mm/kasan/report.c:572
 check_region_inline mm/kasan/generic.c:181 [inline]
 kasan_check_range+0x141/0x190 mm/kasan/generic.c:187
 instrument_copy_from_user_before include/linux/instrumented.h:129 [inline]
 copyin.part.0+0x57/0x80 lib/iov_iter.c:192
 copyin lib/iov_iter.c:390 [inline]
 _copy_from_iter+0x2cc/0x1290 lib/iov_iter.c:390
 copy_from_iter include/linux/uio.h:202 [inline]
 copy_from_iter_full include/linux/uio.h:209 [inline]
 skb_do_copy_data_nocache include/net/sock.h:2257 [inline]
 skb_copy_to_page_nocache include/net/sock.h:2283 [inline]
 tcp_sendmsg_locked+0x139f/0x2960 net/ipv4/tcp.c:1380
 tcp_sendmsg+0x2f/0x50 net/ipv4/tcp.c:1487
 inet_sendmsg+0x9d/0xe0 net/ipv4/af_inet.c:827
 sock_sendmsg_nosec net/socket.c:725 [inline]
 sock_sendmsg+0xde/0x190 net/socket.c:748
 sock_write_iter+0x29b/0x3d0 net/socket.c:1141
 call_write_iter include/linux/fs.h:1872 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x981/0xda0 fs/read_write.c:584
 ksys_write+0x1e3/0x250 fs/read_write.c:637
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f9e7eb16bf2
Code: 89 c7 48 89 44 24 08 e8 7b 34 fa ff 48 8b 44 24 08 48 83 c4 28 c3 c3 64 8b 04 25 18 00 00 00 85 c0 75 20 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 76 6f 48 8b 15 07 a2 0d 00 f7 d8 64 89 02 48 83
RSP: 002b:00007ffeb8b05728 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 000000000000009c RCX: 00007f9e7eb16bf2
RDX: 000000000000009c RSI: 000055c9afb08150 RDI: 0000000000000004
RBP: 000055c9afae6220 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000055c9ae881aa4
R13: 000000000000032f R14: 000055c9ae8823e8 R15: 00007ffeb8b05798
 </TASK>

The buggy address belongs to the physical page:
page:ffffea0001eece00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7bb38
head:ffffea0001eece00 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000010200 ffff888012442140 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d2820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 23468, tgid 23468 (kworker/0:16), ts 815596276194, free_ts 815495948668
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x2db/0x350 mm/page_alloc.c:1744
 prep_new_page mm/page_alloc.c:1751 [inline]
 get_page_from_freelist+0xf41/0x2c00 mm/page_alloc.c:3523
 __alloc_pages+0x1cb/0x4a0 mm/page_alloc.c:4794
 alloc_pages+0x1aa/0x270 mm/mempolicy.c:2279
 alloc_slab_page mm/slub.c:1851 [inline]
 allocate_slab+0x25f/0x390 mm/slub.c:1998
 new_slab mm/slub.c:2051 [inline]
 ___slab_alloc+0xa91/0x1400 mm/slub.c:3192
 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3291
 __slab_alloc_node mm/slub.c:3344 [inline]
 slab_alloc_node mm/slub.c:3441 [inline]
 __kmem_cache_alloc_node+0x136/0x320 mm/slub.c:3490
 __do_kmalloc_node mm/slab_common.c:965 [inline]
 __kmalloc_node_track_caller+0x4f/0x1a0 mm/slab_common.c:986
 kmalloc_reserve+0xf0/0x270 net/core/skbuff.c:585
 __alloc_skb+0x129/0x330 net/core/skbuff.c:654
 alloc_skb include/linux/skbuff.h:1288 [inline]
 nsim_dev_trap_skb_build drivers/net/netdevsim/dev.c:751 [inline]
 nsim_dev_trap_report drivers/net/netdevsim/dev.c:808 [inline]
 nsim_dev_trap_report_work+0x2b1/0xc80 drivers/net/netdevsim/dev.c:853
 process_one_work+0x99a/0x15e0 kernel/workqueue.c:2408
 worker_thread+0x67d/0x10c0 kernel/workqueue.c:2555
 kthread+0x344/0x440 kernel/kthread.c:379
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1308 [inline]
 free_unref_page_prepare+0x62e/0xcb0 mm/page_alloc.c:2577
 free_unref_page+0x33/0x370 mm/page_alloc.c:2672
 diUnmount+0xf1/0x130 fs/jfs/jfs_imap.c:195
 jfs_umount+0x189/0x430 fs/jfs/jfs_umount.c:63
 jfs_put_super+0x85/0x1d0 fs/jfs/super.c:194
 generic_shutdown_super+0x158/0x480 fs/super.c:500
 kill_block_super+0x64/0xb0 fs/super.c:1418
 deactivate_locked_super+0x98/0x160 fs/super.c:331
 deactivate_super+0xb1/0xd0 fs/super.c:362
 cleanup_mnt+0x2ae/0x3d0 fs/namespace.c:1254
 task_work_run+0x16f/0x270 kernel/task_work.c:179
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
 exit_to_user_mode_prepare+0x210/0x240 kernel/entry/common.c:204
 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
 syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:297
 do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Memory state around the buggy address:
 ffff88807bb38d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807bb38e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807bb38e80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                                ^
 ffff88807bb38f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807bb38f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/06/30 05:06 upstream e8f75c0270d9 7b33cf8f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: use-after-free Write in tcp_sendmsg_locked
2023/06/10 09:23 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci d8b213732169 7086cdb9 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: use-after-free Write in tcp_sendmsg_locked
* Struck through repros no longer work on HEAD.