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

From: syzbot <[email-masked]>
Date: Thu, 02 Nov 2017 03:53:39 -0700

Hello,

syzkaller hit the following crash on  
d18b4b35e310c5e30a3726309a93db8893cd3251
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/master
compiler: gcc (GCC) 7.1.1 20170620
.config is attached
Raw console output is attached.

netlink: 7 bytes leftover after parsing attributes in process  
`syz-executor2'.
PF_BRIDGE: br_mdb_parse() with unknown ifindex
==================================================================
BUG: KASAN: use-after-free in tipc_send_group_bcast+0xb08/0xcf0  
net/tipc/socket.c:1022
Read of size 1 at addr ffff8801c330c95e by task syz-executor6/1793

CPU: 1 PID: 1793 Comm: syz-executor6 Not tainted 4.14.0-rc4+ #84
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011
Call Trace:
  __dump_stack lib/dump_stack.c:16 [inline]
  dump_stack+0x194/0x257 lib/dump_stack.c:52
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0  
sclass=netlink_route_socket pig=1805 comm=syz-executor2
  print_address_description+0x73/0x250 mm/kasan/report.c:252
  kasan_report_error mm/kasan/report.c:351 [inline]
  kasan_report+0x25b/0x340 mm/kasan/report.c:409
  __asan_report_load1_noabort+0x14/0x20 mm/kasan/report.c:427
  tipc_send_group_bcast+0xb08/0xcf0 net/tipc/socket.c:1022
  __tipc_sendmsg+0xc97/0x1b20 net/tipc/socket.c:1285
  tipc_sendmsg+0x50/0x70 net/tipc/socket.c:1250
  sock_sendmsg_nosec net/socket.c:633 [inline]
  sock_sendmsg+0xca/0x110 net/socket.c:643
  sock_write_iter+0x320/0x5e0 net/socket.c:912
  call_write_iter include/linux/fs.h:1770 [inline]
  do_iter_readv_writev+0x531/0x7f0 fs/read_write.c:673
  do_iter_write+0x15a/0x540 fs/read_write.c:952
  vfs_writev+0x18a/0x340 fs/read_write.c:997
  do_writev+0xfc/0x2a0 fs/read_write.c:1032
  SYSC_writev fs/read_write.c:1105 [inline]
  SyS_writev+0x27/0x30 fs/read_write.c:1102
  entry_SYSCALL_64_fastpath+0x1f/0xbe
RIP: 0033:0x452719
RSP: 002b:00007f35dad57be8 EFLAGS: 00000212 ORIG_RAX: 0000000000000014
RAX: ffffffffffffffda RBX: 0000000000758020 RCX: 0000000000452719
RDX: 0000000000000001 RSI: 0000000020121ff0 RDI: 0000000000000013
RBP: 0000000000000508 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000212 R12: 00000000006f5960
R13: 00000000ffffffff R14: 00007f35dad586d4 R15: 0000000000000000

Allocated by task 1793:
  save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
  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:551
  kmem_cache_alloc_trace+0x136/0x750 mm/slab.c:3627
  kmalloc include/linux/slab.h:493 [inline]
  kzalloc include/linux/slab.h:666 [inline]
  tipc_group_create+0x116/0x9c0 net/tipc/group.c:167
  tipc_sk_join net/tipc/socket.c:2751 [inline]
  tipc_setsockopt+0x25e/0xc00 net/tipc/socket.c:2863
  SYSC_setsockopt net/socket.c:1852 [inline]
  SyS_setsockopt+0x189/0x360 net/socket.c:1831
  entry_SYSCALL_64_fastpath+0x1f/0xbe

Freed by task 1793:
  save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
  save_stack+0x43/0xd0 mm/kasan/kasan.c:447
  set_track mm/kasan/kasan.c:459 [inline]
  kasan_slab_free+0x71/0xc0 mm/kasan/kasan.c:524
  __cache_free mm/slab.c:3503 [inline]
  kfree+0xca/0x250 mm/slab.c:3820
  tipc_group_delete+0x2c0/0x3c0 net/tipc/group.c:206
  tipc_sk_join net/tipc/socket.c:2764 [inline]
  tipc_setsockopt+0xb33/0xc00 net/tipc/socket.c:2863
  SYSC_setsockopt net/socket.c:1852 [inline]
  SyS_setsockopt+0x189/0x360 net/socket.c:1831
  entry_SYSCALL_64_fastpath+0x1f/0xbe

The buggy address belongs to the object at ffff8801c330c900
  which belongs to the cache kmalloc-192 of size 192
The buggy address is located 94 bytes inside of
  192-byte region [ffff8801c330c900, ffff8801c330c9c0)
The buggy address belongs to the page:
page:ffffea00070cc300 count:1 mapcount:0 mapping:ffff8801c330c000 index:0x0
flags: 0x200000000000100(slab)
raw: 0200000000000100 ffff8801c330c000 0000000000000000 0000000100000010
raw: ffffea00071352a0 ffffea00070a38e0 ffff8801dac00040 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
  ffff8801c330c800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
  ffff8801c330c880: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
> ffff8801c330c900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                     ^
  ffff8801c330c980: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
  ffff8801c330ca00: 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].
Please credit me with: Reported-by: syzbot <[email-masked]>

syzbot will keep track of this bug report.
Once a fix for this bug is committed, 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.