Subject: KASAN: use-after-free Read in inet_shutdown

From: syzbot <[email-masked]>
Date: Tue, 16 Jan 2018 10:30:01 -0800

Hello,

syzkaller hit the following crash on  
ce3c209f6733e2cff9335bb1b2ac847fa823410a
git://git.cmpxchg.org/linux-mmots.git/master
compiler: gcc (GCC) 7.1.1 20170620
.config is attached
Raw console output is attached.
Unfortunately, I don't have any reproducer for this bug yet.

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: [email-masked]
It will help syzbot understand when the bug is fixed. See footer for  
details.
If you forward the report, please keep this part and the footer.

==================================================================
BUG: KASAN: use-after-free in inet_shutdown+0x2d4/0x350  
net/ipv4/af_inet.c:819
Read of size 4 at addr ffff8801d15e5200 by task syz-executor0/6148

CPU: 1 PID: 6148 Comm: syz-executor0 Not tainted 4.15.0-rc7-mm1+ #56
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011
Call Trace:
  __dump_stack lib/dump_stack.c:17 [inline]
  dump_stack+0x194/0x257 lib/dump_stack.c:53
  print_address_description+0x73/0x250 mm/kasan/report.c:256
  kasan_report_error mm/kasan/report.c:354 [inline]
  kasan_report+0x23b/0x360 mm/kasan/report.c:412
  __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:432
  inet_shutdown+0x2d4/0x350 net/ipv4/af_inet.c:819
  pppol2tp_session_close+0x92/0xf0 net/l2tp/l2tp_ppp.c:430
  l2tp_tunnel_closeall+0x305/0x410 net/l2tp/l2tp_core.c:1288
  l2tp_udp_encap_destroy+0x95/0x100 net/l2tp/l2tp_core.c:1311
  udpv6_destroy_sock+0x161/0x190 net/ipv6/udp.c:1407
  sk_common_release+0x6b/0x2f0 net/core/sock.c:2999
  udp_lib_close+0x15/0x20 include/net/udp.h:203
  inet_release+0xed/0x1c0 net/ipv4/af_inet.c:427
  inet6_release+0x50/0x70 net/ipv6/af_inet6.c:432
  sock_release+0x8d/0x1e0 net/socket.c:595
  sock_close+0x16/0x20 net/socket.c:1123
  __fput+0x327/0x7e0 fs/file_table.c:209
  ____fput+0x15/0x20 fs/file_table.c:243
  task_work_run+0x199/0x270 kernel/task_work.c:113
  tracehook_notify_resume include/linux/tracehook.h:191 [inline]
  exit_to_usermode_loop+0x275/0x2f0 arch/x86/entry/common.c:165
  prepare_exit_to_usermode arch/x86/entry/common.c:195 [inline]
  syscall_return_slowpath+0x490/0x550 arch/x86/entry/common.c:264
  entry_SYSCALL_64_fastpath+0x9e/0xa0
RIP: 0033:0x452df9
RSP: 002b:00007fed7ec85c58 EFLAGS: 00000212 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 000000000071bea0 RCX: 0000000000452df9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000017
RBP: 000000000000004e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000212 R12: 00000000006ee7f0
R13: 00000000ffffffff R14: 00007fed7ec866d4 R15: 0000000000000000

Allocated by task 6154:
  save_stack+0x43/0xd0 mm/kasan/kasan.c:447
  set_track mm/kasan/kasan.c:459 [inline]
  kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:552
  kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:489
  kmem_cache_alloc+0x12e/0x760 mm/slab.c:3541
  sock_alloc_inode+0x70/0x300 net/socket.c:244
  alloc_inode+0x65/0x180 fs/inode.c:209
  new_inode_pseudo+0x69/0x190 fs/inode.c:890
  sock_alloc+0x41/0x270 net/socket.c:565
  __sock_create+0x148/0x850 net/socket.c:1223
  sock_create net/socket.c:1299 [inline]
  SYSC_socket net/socket.c:1329 [inline]
  SyS_socket+0xeb/0x1d0 net/socket.c:1309
  entry_SYSCALL_64_fastpath+0x29/0xa0

Freed by task 6154:
  save_stack+0x43/0xd0 mm/kasan/kasan.c:447
  set_track mm/kasan/kasan.c:459 [inline]
  __kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:520
  kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:527
  __cache_free mm/slab.c:3485 [inline]
  kmem_cache_free+0x86/0x2b0 mm/slab.c:3743
  sock_destroy_inode+0x56/0x70 net/socket.c:274
  destroy_inode+0x15d/0x200 fs/inode.c:266
  evict+0x57e/0x920 fs/inode.c:570
  iput_final fs/inode.c:1515 [inline]
  iput+0x7b9/0xaf0 fs/inode.c:1542
  dentry_unlink_inode+0x4b0/0x5e0 fs/dcache.c:375
  __dentry_kill+0x3b7/0x6d0 fs/dcache.c:572
  dentry_kill fs/dcache.c:613 [inline]
  dput.part.23+0x6fb/0x830 fs/dcache.c:823
  dput+0x1f/0x30 fs/dcache.c:787
  __fput+0x51c/0x7e0 fs/file_table.c:227
  ____fput+0x15/0x20 fs/file_table.c:243
  task_work_run+0x199/0x270 kernel/task_work.c:113
  tracehook_notify_resume include/linux/tracehook.h:191 [inline]
  exit_to_usermode_loop+0x275/0x2f0 arch/x86/entry/common.c:165
  prepare_exit_to_usermode arch/x86/entry/common.c:195 [inline]
  syscall_return_slowpath+0x490/0x550 arch/x86/entry/common.c:264
  entry_SYSCALL_64_fastpath+0x9e/0xa0

The buggy address belongs to the object at ffff8801d15e5200
  which belongs to the cache sock_inode_cache of size 992
The buggy address is located 0 bytes inside of
  992-byte region [ffff8801d15e5200, ffff8801d15e55e0)
The buggy address belongs to the page:
page:ffffea0007457940 count:1 mapcount:0 mapping:ffff8801d15e5200  
index:0xffff8801d15e5ffd
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffff8801d15e5200 ffff8801d15e5ffd 0000000100000003
raw: ffffea00074576a0 ffffea0006eb5260 ffff8801d986c9c0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
  ffff8801d15e5100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
  ffff8801d15e5180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> ffff8801d15e5200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                    ^
  ffff8801d15e5280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
  ffff8801d15e5300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

---
This bug is generated by a dumb bot. It may contain errors.
See https://goo.gl/tpsmEJ for details.
Direct all questions to [email-masked].

syzbot will keep track of this bug report.
If you forgot to add the Reported-by tag, once the fix for this bug is  
merged
into any tree, please reply to this email with:
#syz fix: exact-commit-title
To mark this as a duplicate of another syzbot report, please reply with:
#syz dup: exact-subject-of-another-report
If it's a one-off invalid bug report, please reply with:
#syz invalid
Note: if the crash happens again, it will cause creation of a new bug  
report.
Note: all commands must start from beginning of the line in the email body.