syzbot


KASAN: stack-out-of-bounds Write in __ip_options_echo

Status: fixed on 2019/05/27 12:48
Subsystems: net
[Documentation on labels]
Fix commit: 20ff83f10f11 ipv4: add sanity checks in ipv4_link_failure()
First crash: 1847d, last: 1843d
Cause bisection: introduced by (bisect log) :
commit ed0de45a1008991fdaa27a0152befcb74d126a8b
Author: Stephen Suryaputra <ssuryaextr@gmail.com>
Date: Fri Apr 12 20:19:27 2019 +0000

  ipv4: recompile ip options in ipv4_link_failure

Crash: KASAN: stack-out-of-bounds Write in __ip_options_echo (log)
Repro: syz .config
  
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: stack-out-of-bounds Write in __ip_options_echo 1 1838d 1838d 0/1 auto-closed as invalid on 2019/10/25 08:39
linux-4.14 KASAN: stack-out-of-bounds Write in __ip_options_echo 1 1840d 1839d 0/1 auto-closed as invalid on 2019/10/24 16:14
upstream KASAN: stack-out-of-bounds Write in __ip_options_echo (2) net 1 911d 911d 0/26 closed as invalid on 2021/12/14 20:02

Sample crash report:
==================================================================
BUG: KASAN: stack-out-of-bounds in memcpy include/linux/string.h:355 [inline]
BUG: KASAN: stack-out-of-bounds in __ip_options_echo+0x294/0x1120 net/ipv4/ip_options.c:123
Write of size 69 at addr ffff888091067068 by task syz-executor.0/9445

CPU: 0 PID: 9445 Comm: syz-executor.0 Not tainted 5.1.0-rc6 #79
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+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:187
 kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
 check_memory_region_inline mm/kasan/generic.c:185 [inline]
 check_memory_region+0x123/0x190 mm/kasan/generic.c:191
 memcpy+0x38/0x50 mm/kasan/common.c:133
 memcpy include/linux/string.h:355 [inline]
 __ip_options_echo+0x294/0x1120 net/ipv4/ip_options.c:123
 __icmp_send+0x725/0x1400 net/ipv4/icmp.c:695
 ipv4_link_failure+0x29f/0x550 net/ipv4/route.c:1204
 dst_link_failure include/net/dst.h:427 [inline]
 vti6_xmit net/ipv6/ip6_vti.c:514 [inline]
 vti6_tnl_xmit+0x10d4/0x1c0c net/ipv6/ip6_vti.c:553
 __netdev_start_xmit include/linux/netdevice.h:4414 [inline]
 netdev_start_xmit include/linux/netdevice.h:4423 [inline]
 xmit_one net/core/dev.c:3292 [inline]
 dev_hard_start_xmit+0x1b2/0x980 net/core/dev.c:3308
 __dev_queue_xmit+0x271d/0x3060 net/core/dev.c:3878
 dev_queue_xmit+0x18/0x20 net/core/dev.c:3911
 neigh_direct_output+0x16/0x20 net/core/neighbour.c:1527
 neigh_output include/net/neighbour.h:508 [inline]
 ip_finish_output2+0x949/0x1740 net/ipv4/ip_output.c:229
 ip_finish_output+0x73c/0xd50 net/ipv4/ip_output.c:317
 NF_HOOK_COND include/linux/netfilter.h:278 [inline]
 ip_output+0x21f/0x670 net/ipv4/ip_output.c:405
 dst_output include/net/dst.h:444 [inline]
 NF_HOOK include/linux/netfilter.h:289 [inline]
 raw_send_hdrinc net/ipv4/raw.c:432 [inline]
 raw_sendmsg+0x1d2b/0x2f20 net/ipv4/raw.c:663
 inet_sendmsg+0x147/0x5d0 net/ipv4/af_inet.c:798
 sock_sendmsg_nosec net/socket.c:651 [inline]
 sock_sendmsg+0xdd/0x130 net/socket.c:661
 sock_write_iter+0x27c/0x3e0 net/socket.c:988
 call_write_iter include/linux/fs.h:1866 [inline]
 new_sync_write+0x4c7/0x760 fs/read_write.c:474
 __vfs_write+0xe4/0x110 fs/read_write.c:487
 vfs_write+0x20c/0x580 fs/read_write.c:549
 ksys_write+0x14f/0x2d0 fs/read_write.c:599
 __do_sys_write fs/read_write.c:611 [inline]
 __se_sys_write fs/read_write.c:608 [inline]
 __x64_sys_write+0x73/0xb0 fs/read_write.c:608
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x458c29
Code: ad b8 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 7b b8 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f7a4e3b1c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000458c29
RDX: 000000000000001c RSI: 0000000020000100 RDI: 0000000000000003
RBP: 000000000073bf00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f7a4e3b26d4
R13: 00000000004c8703 R14: 00000000004deea0 R15: 00000000ffffffff

The buggy address belongs to the page:
page:ffffea00024419c0 count:0 mapcount:0 mapping:0000000000000000 index:0x0
flags: 0x1fffc0000000000()
raw: 01fffc0000000000 0000000000000000 ffffffff02440101 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888091066f80: 00 00 00 f2 f2 f2 f2 f2 00 00 00 00 00 00 00 f2
 ffff888091067000: f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888091067080: 00 00 f3 f3 f3 f3 00 00 00 00 00 00 00 00 00 00
                         ^
 ffff888091067100: 00 00 00 00 f1 f1 f1 f1 00 00 f3 f3 00 00 00 00
 ffff888091067180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (8):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/04/23 18:42 upstream 085b7755808a 53199d6e .config console log report syz ci-upstream-kasan-gce-root
2019/04/20 05:58 upstream 55e3a6ba5cce b0e8efcb .config console log report syz ci-upstream-kasan-gce-smack-root
2019/04/20 04:39 upstream 3ecafda911f4 b0e8efcb .config console log report syz ci-upstream-kasan-gce-root
2019/04/20 04:11 upstream 3ecafda911f4 b0e8efcb .config console log report syz ci-upstream-kasan-gce
2019/04/20 04:41 net-old d1bcf2b65177 b0e8efcb .config console log report syz ci-upstream-net-this-kasan-gce
2019/04/20 04:42 net-next-old d7cc399e1227 b0e8efcb .config console log report syz ci-upstream-net-kasan-gce
2019/04/23 14:32 upstream 085b7755808a 53199d6e .config console log report ci-upstream-kasan-gce-root
2019/04/20 03:30 upstream 3ecafda911f4 b0e8efcb .config console log report ci-upstream-kasan-gce
* Struck through repros no longer work on HEAD.