syzbot


KASAN: stack-out-of-bounds Read in tcp_inbound_hash

Status: fixed on 2024/01/11 00:25
Subsystems: net
[Documentation on labels]
Fix commit: 02f0717e9835 net/tcp: fix possible out-of-bounds reads in tcp_hash_fail()
First crash: 125d, last: 112d
Cause bisection: introduced by (bisect log) :
commit 2717b5adea9e2558798c30eb0e93c01722edbb0a
Author: Dmitry Safonov <dima@arista.com>
Date: Mon Oct 23 19:22:07 2023 +0000

  net/tcp: Add tcp_hash_fail() ratelimited logs

Crash: KASAN: stack-out-of-bounds Read in tcp_inbound_hash (log)
Repro: C syz .config
  

Sample crash report:
==================================================================
BUG: KASAN: stack-out-of-bounds in string_nocheck lib/vsprintf.c:645 [inline]
BUG: KASAN: stack-out-of-bounds in string+0x394/0x3d0 lib/vsprintf.c:727
Read of size 1 at addr ffffc9000397f3f5 by task syz-executor299/5039

CPU: 1 PID: 5039 Comm: syz-executor299 Not tainted 6.6.0-rc7-syzkaller-02075-g55c900477f5b #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:364 [inline]
 print_report+0xc4/0x620 mm/kasan/report.c:475
 kasan_report+0xda/0x110 mm/kasan/report.c:588
 string_nocheck lib/vsprintf.c:645 [inline]
 string+0x394/0x3d0 lib/vsprintf.c:727
 vsnprintf+0xc5f/0x1870 lib/vsprintf.c:2818
 vprintk_store+0x3a0/0xb80 kernel/printk/printk.c:2191
 vprintk_emit+0x14c/0x5f0 kernel/printk/printk.c:2288
 vprintk+0x7b/0x90 kernel/printk/printk_safe.c:45
 _printk+0xc8/0x100 kernel/printk/printk.c:2332
 tcp_inbound_hash.constprop.0+0xdb2/0x10d0 include/net/tcp.h:2760
 tcp_v6_rcv+0x2b31/0x34d0 net/ipv6/tcp_ipv6.c:1882
 ip6_protocol_deliver_rcu+0x33b/0x13d0 net/ipv6/ip6_input.c:438
 ip6_input_finish+0x14f/0x2f0 net/ipv6/ip6_input.c:483
 NF_HOOK include/linux/netfilter.h:314 [inline]
 NF_HOOK include/linux/netfilter.h:308 [inline]
 ip6_input+0xce/0x440 net/ipv6/ip6_input.c:492
 dst_input include/net/dst.h:461 [inline]
 ip6_rcv_finish net/ipv6/ip6_input.c:79 [inline]
 NF_HOOK include/linux/netfilter.h:314 [inline]
 NF_HOOK include/linux/netfilter.h:308 [inline]
 ipv6_rcv+0x563/0x720 net/ipv6/ip6_input.c:310
 __netif_receive_skb_one_core+0x115/0x180 net/core/dev.c:5527
 __netif_receive_skb+0x1f/0x1b0 net/core/dev.c:5641
 netif_receive_skb_internal net/core/dev.c:5727 [inline]
 netif_receive_skb+0x133/0x700 net/core/dev.c:5786
 tun_rx_batched+0x429/0x780 drivers/net/tun.c:1579
 tun_get_user+0x29e7/0x3bc0 drivers/net/tun.c:2002
 tun_chr_write_iter+0xe8/0x210 drivers/net/tun.c:2048
 call_write_iter include/linux/fs.h:1956 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x650/0xe40 fs/read_write.c:584
 ksys_write+0x12f/0x250 fs/read_write.c:637
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7ffaa04cc340
Code: 40 00 48 c7 c2 b8 ff ff ff f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 80 3d 61 ed 07 00 00 74 17 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 58 c3 0f 1f 80 00 00 00 00 48 83 ec 28 48 89
RSP: 002b:00007ffd49172c68 EFLAGS: 00000202 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007ffaa051b070 RCX: 00007ffaa04cc340
RDX: 000000000000008a RSI: 00000000200002c0 RDI: 00000000000000c8
RBP: 00007ffd49172c78 R08: bb1414ac00000000 R09: bb1414ac00000000
R10: bb1414ac00000000 R11: 0000000000000202 R12: 00007ffd49172c74
R13: 0000000000000000 R14: 00007ffd49172c80 R15: 00007ffaa051b004
 </TASK>

The buggy address belongs to stack of task syz-executor299/5039
 and is located at offset 101 in frame:
 tcp_inbound_hash.constprop.0+0x0/0x10d0 include/net/net_namespace.h:385

This frame has 3 objects:
 [32, 40) 'md5_tmp'
 [64, 72) 'ao_tmp'
 [96, 101) 'hdr_flags'

The buggy address belongs to the virtual mapping at
 [ffffc90003978000, ffffc90003981000) created by:
 kernel_clone+0xfd/0x920 kernel/fork.c:2909

The buggy address belongs to the physical page:
page:ffffea0001c84f80 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7213e
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000000 0000000000000000 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000000000 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 0x2dc2(GFP_KERNEL|__GFP_HIGHMEM|__GFP_NOWARN|__GFP_ZERO), pid 5038, tgid 5038 (syz-executor299), ts 73918475985, free_ts 66675395950
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x2cf/0x340 mm/page_alloc.c:1536
 prep_new_page mm/page_alloc.c:1543 [inline]
 get_page_from_freelist+0xee0/0x2f20 mm/page_alloc.c:3170
 __alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4426
 alloc_pages+0x1a9/0x270 mm/mempolicy.c:2299
 vm_area_alloc_pages mm/vmalloc.c:3063 [inline]
 __vmalloc_area_node mm/vmalloc.c:3139 [inline]
 __vmalloc_node_range+0xa6e/0x1540 mm/vmalloc.c:3320
 alloc_thread_stack_node kernel/fork.c:309 [inline]
 dup_task_struct kernel/fork.c:1118 [inline]
 copy_process+0x13e3/0x73f0 kernel/fork.c:2327
 kernel_clone+0xfd/0x920 kernel/fork.c:2909
 __do_sys_clone+0xba/0x100 kernel/fork.c:3052
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1136 [inline]
 free_unref_page_prepare+0x476/0xa40 mm/page_alloc.c:2312
 free_unref_page+0x33/0x3b0 mm/page_alloc.c:2405
 __folio_put_small mm/swap.c:106 [inline]
 __folio_put+0xc3/0x110 mm/swap.c:129
 folio_put include/linux/mm.h:1475 [inline]
 put_page include/linux/mm.h:1544 [inline]
 anon_pipe_buf_release+0x3fa/0x4b0 fs/pipe.c:138
 pipe_buf_release include/linux/pipe_fs_i.h:203 [inline]
 pipe_read+0x635/0x1270 fs/pipe.c:324
 call_read_iter include/linux/fs.h:1950 [inline]
 new_sync_read fs/read_write.c:389 [inline]
 vfs_read+0x7ef/0x930 fs/read_write.c:470
 ksys_read+0x1f0/0x250 fs/read_write.c:613
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Memory state around the buggy address:
 ffffc9000397f280: 00 f1 f1 f1 f1 00 00 00 f3 f3 f3 f3 f3 00 00 00
 ffffc9000397f300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffffc9000397f380: 00 00 f1 f1 f1 f1 00 f2 f2 f2 00 f2 f2 f2 05 f3
                                                             ^
 ffffc9000397f400: f3 f3 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffffc9000397f480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (28):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/10/29 22:01 net-next 55c900477f5b 3c418d72 .config strace log report syz C [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/05 07:41 upstream aea6bf908d73 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/04 04:21 upstream 8f6f76a6a29f 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/04 04:10 upstream 8f6f76a6a29f 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/04 04:01 upstream 8f6f76a6a29f 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/04 00:43 upstream 8f6f76a6a29f 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/03 23:10 upstream 8f6f76a6a29f 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/02 10:48 upstream babe393974de 69904c9f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/01 22:05 upstream 8bc9e6515183 69904c9f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/01 14:52 upstream 89ed67ef126c 69904c9f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/01 14:44 upstream 89ed67ef126c 69904c9f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/01 14:42 upstream 89ed67ef126c 69904c9f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/01 14:34 upstream 89ed67ef126c 69904c9f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/01 07:32 upstream 89ed67ef126c 69904c9f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/04 00:23 upstream 8f6f76a6a29f 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-386 KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/01 17:55 upstream 8bc9e6515183 69904c9f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-386 KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/04 03:56 upstream 2c40c1c6adab 500bfdc4 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/04 04:57 upstream 2c40c1c6adab 500bfdc4 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/04 03:40 upstream 2c40c1c6adab 500bfdc4 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/07 04:44 net-next ff269e2cd5ad 78fae24e .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/07 01:11 net-next ff269e2cd5ad 78fae24e .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/03 23:03 net-next ff269e2cd5ad 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/03 16:57 net-next ff269e2cd5ad c4ac074c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/02 09:32 net-next ff269e2cd5ad 69904c9f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/10/29 21:30 net-next 55c900477f5b 3c418d72 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/12 07:54 linux-next e27090b1413f 6d6dbf8a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/12 07:28 linux-next e27090b1413f 6d6dbf8a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: stack-out-of-bounds Read in tcp_inbound_hash
2023/11/01 14:51 linux-next fa7d0c172786 69904c9f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: stack-out-of-bounds Read in tcp_inbound_hash
* Struck through repros no longer work on HEAD.