syzbot


KASAN: use-after-free Read in tcp_fastretrans_alert

Status: fixed on 2020/02/18 14:31
Subsystems: net
[Documentation on labels]
Fix commit: 2bec445f9bf3 net-backports: tcp: do not leave dangling pointers in tp->highest_sack
First crash: 1792d, last: 1792d
Cause bisection: introduced by (bisect log) :
commit 853697504de043ff0bfd815bd3a64de1dce73dc7
Author: Cambda Zhu <cambda@linux.alibaba.com>
Date: Fri Dec 27 08:52:37 2019 +0000

  tcp: Fix highest_sack and highest_sack_seq

Crash: KASAN: use-after-free Read in tcp_check_sack_reordering (log)
Repro: C syz .config
  

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in tcp_highest_sack_seq include/net/tcp.h:1846 [inline]
BUG: KASAN: use-after-free in tcp_check_sack_reordering net/ipv4/tcp_input.c:891 [inline]
BUG: KASAN: use-after-free in tcp_try_undo_partial net/ipv4/tcp_input.c:2730 [inline]
BUG: KASAN: use-after-free in tcp_fastretrans_alert+0x4e5c/0x5560 net/ipv4/tcp_input.c:2847
Read of size 4 at addr ffff8880979b75e8 by task syz-executor634/8514

CPU: 1 PID: 8514 Comm: syz-executor634 Not tainted 5.5.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1fb/0x318 lib/dump_stack.c:118
 print_address_description+0x74/0x5c0 mm/kasan/report.c:374
 __kasan_report+0x149/0x1c0 mm/kasan/report.c:506
 kasan_report+0x26/0x50 mm/kasan/common.c:639
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/generic_report.c:134
 tcp_highest_sack_seq include/net/tcp.h:1846 [inline]
 tcp_check_sack_reordering net/ipv4/tcp_input.c:891 [inline]
 tcp_try_undo_partial net/ipv4/tcp_input.c:2730 [inline]
 tcp_fastretrans_alert+0x4e5c/0x5560 net/ipv4/tcp_input.c:2847
 tcp_ack+0x3cfc/0x6a20 net/ipv4/tcp_input.c:3710
 tcp_rcv_established+0x6da/0x2030 net/ipv4/tcp_input.c:5701
 tcp_v4_do_rcv+0x3ba/0x8d0 net/ipv4/tcp_ipv4.c:1562
 sk_backlog_rcv include/net/sock.h:954 [inline]
 __release_sock+0x1c1/0x4b0 net/core/sock.c:2437
 release_sock+0x65/0x1c0 net/core/sock.c:2953
 sk_stream_wait_memory+0x70e/0xe60 net/core/stream.c:145
 tcp_sendmsg_locked+0xbc8/0x3eb0 net/ipv4/tcp.c:1394
 tcp_sendmsg+0x2f/0x50 net/ipv4/tcp.c:1434
 inet_sendmsg+0x147/0x310 net/ipv4/af_inet.c:807
 sock_sendmsg_nosec net/socket.c:639 [inline]
 sock_sendmsg net/socket.c:659 [inline]
 __sys_sendto+0x43c/0x5e0 net/socket.c:1985
 __do_sys_sendto net/socket.c:1997 [inline]
 __se_sys_sendto net/socket.c:1993 [inline]
 __x64_sys_sendto+0xe5/0x100 net/socket.c:1993
 do_syscall_64+0xf7/0x1c0 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x448889
Code: e8 ec 1a 03 00 48 83 c4 18 c3 0f 1f 80 00 00 00 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 0f 83 3b 0c fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f42708f8cd8 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
RAX: ffffffffffffffda RBX: 00000000006dfc48 RCX: 0000000000448889
RDX: ffffffffffffff67 RSI: 0000000020000640 RDI: 0000000000000003
RBP: 00000000006dfc40 R08: 0000000000000000 R09: ffffffffffffff4f
R10: 00000000040007bd R11: 0000000000000246 R12: 00000000006dfc4c
R13: 00007ffff271017f R14: 00007f42708f99c0 R15: 000000000000002d

Allocated by task 8514:
 save_stack mm/kasan/common.c:72 [inline]
 set_track mm/kasan/common.c:80 [inline]
 __kasan_kmalloc+0x118/0x1c0 mm/kasan/common.c:513
 kasan_slab_alloc+0xf/0x20 mm/kasan/common.c:521
 slab_post_alloc_hook mm/slab.h:584 [inline]
 slab_alloc_node mm/slab.c:3263 [inline]
 kmem_cache_alloc_node+0x235/0x280 mm/slab.c:3575
 __alloc_skb+0x9f/0x500 net/core/skbuff.c:197
 alloc_skb_fclone include/linux/skbuff.h:1099 [inline]
 sk_stream_alloc_skb+0x40a/0xa50 net/ipv4/tcp.c:877
 tcp_sendmsg_locked+0xe1b/0x3eb0 net/ipv4/tcp.c:1284
 tcp_sendmsg+0x2f/0x50 net/ipv4/tcp.c:1434
 inet_sendmsg+0x147/0x310 net/ipv4/af_inet.c:807
 sock_sendmsg_nosec net/socket.c:639 [inline]
 sock_sendmsg net/socket.c:659 [inline]
 __sys_sendto+0x43c/0x5e0 net/socket.c:1985
 __do_sys_sendto net/socket.c:1997 [inline]
 __se_sys_sendto net/socket.c:1993 [inline]
 __x64_sys_sendto+0xe5/0x100 net/socket.c:1993
 do_syscall_64+0xf7/0x1c0 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8516:
 save_stack mm/kasan/common.c:72 [inline]
 set_track mm/kasan/common.c:80 [inline]
 kasan_set_free_info mm/kasan/common.c:335 [inline]
 __kasan_slab_free+0x12e/0x1e0 mm/kasan/common.c:474
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:483
 __cache_free mm/slab.c:3426 [inline]
 kmem_cache_free+0x81/0xf0 mm/slab.c:3694
 kfree_skbmem net/core/skbuff.c:644 [inline]
 __kfree_skb+0x13e/0x1c0 net/core/skbuff.c:680
 sk_eat_skb include/net/sock.h:2468 [inline]
 tcp_recvmsg+0x15f9/0x3530 net/ipv4/tcp.c:2166
 inet_recvmsg+0xf5/0x1d0 net/ipv4/af_inet.c:838
 sock_recvmsg_nosec net/socket.c:873 [inline]
 sock_recvmsg net/socket.c:891 [inline]
 __sys_recvfrom+0x328/0x4b0 net/socket.c:2042
 __do_sys_recvfrom net/socket.c:2060 [inline]
 __se_sys_recvfrom net/socket.c:2056 [inline]
 __x64_sys_recvfrom+0xe5/0x100 net/socket.c:2056
 do_syscall_64+0xf7/0x1c0 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880979b75c0
 which belongs to the cache skbuff_fclone_cache of size 456
The buggy address is located 40 bytes inside of
 456-byte region [ffff8880979b75c0, ffff8880979b7788)
The buggy address belongs to the page:
page:ffffea00025e6dc0 refcount:1 mapcount:0 mapping:ffff8880a9d2d700 index:0x0
raw: 00fffe0000000200 ffffea00028adc88 ffffea00024be2c8 ffff8880a9d2d700
raw: 0000000000000000 ffff8880979b70c0 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880979b7480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880979b7500: fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880979b7580: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
                                                          ^
 ffff8880979b7600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880979b7680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/01/18 13:24 upstream 25e73aadf297 3de7aabb .config console log report syz C ci-upstream-kasan-gce-smack-root
* Struck through repros no longer work on HEAD.