syzbot


KASAN: use-after-free Read in napi_gro_frags

Status: fixed on 2019/06/18 17:49
Fix commit: a4270d6795b0 net-gro: fix use-after-free read in napi_gro_frags()
First crash: 2017d, last: 2015d
Cause bisection: introduced by (bisect log) :
commit aa6daacaa113cda96760c8d3157bae937908f6e3
Author: Eric Dumazet <edumazet@google.com>
Date: Sun Nov 18 15:37:33 2018 +0000

  tun: use netdev_alloc_frag() in tun_napi_alloc_frags()

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

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in napi_frags_skb net/core/dev.c:5833 [inline]
BUG: KASAN: use-after-free in napi_gro_frags+0xc6f/0xd10 net/core/dev.c:5841
Read of size 2 at addr ffff88808381000c by task syz-executor272/10147

CPU: 1 PID: 10147 Comm: syz-executor272 Not tainted 5.2.0-rc2+ #14
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:188
 __kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
 kasan_report+0x12/0x20 mm/kasan/common.c:614
 __asan_report_load_n_noabort+0xf/0x20 mm/kasan/generic_report.c:142
 napi_frags_skb net/core/dev.c:5833 [inline]
 napi_gro_frags+0xc6f/0xd10 net/core/dev.c:5841
 tun_get_user+0x2f3c/0x3ff0 drivers/net/tun.c:1991
 tun_chr_write_iter+0xbd/0x156 drivers/net/tun.c:2037
 call_write_iter include/linux/fs.h:1872 [inline]
 do_iter_readv_writev+0x5f8/0x8f0 fs/read_write.c:693
 do_iter_write fs/read_write.c:970 [inline]
 do_iter_write+0x184/0x610 fs/read_write.c:951
 vfs_writev+0x1b3/0x2f0 fs/read_write.c:1015
 do_writev+0x15b/0x330 fs/read_write.c:1058
 __do_sys_writev fs/read_write.c:1131 [inline]
 __se_sys_writev fs/read_write.c:1128 [inline]
 __x64_sys_writev+0x75/0xb0 fs/read_write.c:1128
 do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x443010
Code: 05 48 3d 01 f0 ff ff 0f 83 9d 09 fc ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 83 3d 01 90 29 00 00 75 14 b8 14 00 00 00 0f 05 <48> 3d 01 f0 ff ff 0f 83 74 09 fc ff c3 48 83 ec 08 e8 ba 2b 00 00
RSP: 002b:00007ffd221d26a8 EFLAGS: 00000246 ORIG_RAX: 0000000000000014
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000443010
RDX: 0000000000000003 RSI: 00007ffd221d26d0 RDI: 00000000000000f0
RBP: 0000000000013ab7 R08: 0000000000000003 R09: 0000000020000100
R10: 0000000020000036 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000403ea0 R14: 0000000000000000 R15: 0000000000000000

The buggy address belongs to the page:
page:ffffea00020e0400 refcount:0 mapcount:-128 mapping:0000000000000000 index:0x0
flags: 0x1fffc0000000000()
raw: 01fffc0000000000 ffffea00023a9e08 ffff88812fffc878 0000000000000000
raw: 0000000000000000 0000000000000003 00000000ffffff7f 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88808380ff00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88808380ff80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888083810000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                      ^
 ffff888083810080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888083810100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (16):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/05/31 10:12 upstream 20f944965601 d9aaf3c2 .config console log report syz C ci-upstream-kasan-gce-root
2019/05/31 09:35 upstream 20f944965601 d9aaf3c2 .config console log report syz C ci-upstream-kasan-gce-root
2019/05/31 07:47 upstream 20f944965601 d9aaf3c2 .config console log report syz C ci-upstream-kasan-gce-root
2019/05/29 19:00 upstream 9fb67d643f6f 5457ef34 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/05/29 18:57 upstream 9fb67d643f6f 5457ef34 .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/05/29 17:32 upstream 9fb67d643f6f 5457ef34 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/05/29 17:21 upstream 9fb67d643f6f 5457ef34 .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/05/29 16:50 upstream 9fb67d643f6f 5457ef34 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/05/29 16:42 upstream 9fb67d643f6f 5457ef34 .config console log report syz C ci-upstream-kasan-gce-smack-root
2019/05/29 18:53 net-old a6cd0d2d493a 5457ef34 .config console log report syz C ci-upstream-net-this-kasan-gce
2019/05/29 16:59 net-old a6cd0d2d493a 5457ef34 .config console log report syz C ci-upstream-net-this-kasan-gce
2019/05/29 16:18 net-old a6cd0d2d493a 5457ef34 .config console log report syz C ci-upstream-net-this-kasan-gce
2019/05/29 20:25 net-next-old 36f18439ea16 5457ef34 .config console log report syz C ci-upstream-net-kasan-gce
2019/05/29 19:13 net-next-old 36f18439ea16 5457ef34 .config console log report syz C ci-upstream-net-kasan-gce
2019/05/29 15:51 net-next-old 36f18439ea16 5457ef34 .config console log report syz C ci-upstream-net-kasan-gce
2019/05/29 15:19 net-next-old 36f18439ea16 5457ef34 .config console log report ci-upstream-net-kasan-gce
* Struck through repros no longer work on HEAD.