Re: KASAN: use-after-free Read in tipc_group_size

2018-02-01 Thread Eric Biggers
On Mon, Jan 08, 2018 at 08:11:35PM +, Jon Maloy wrote:
> 
> 
> > -Original Message-
> > From: Cong Wang [mailto:xiyou.wangc...@gmail.com]
> > Sent: Monday, January 08, 2018 13:44
> > To: syzbot <syzbot+aae58876fb5a1fad0...@syzkaller.appspotmail.com>
> > Cc: David Miller <da...@davemloft.net>; Jon Maloy
> > <jon.ma...@ericsson.com>; LKML <linux-kernel@vger.kernel.org>; Linux
> > Kernel Network Developers <net...@vger.kernel.org>; syzkaller-
> > b...@googlegroups.com; tipc-discuss...@lists.sourceforge.net; Ying Xue
> > <ying@windriver.com>
> > Subject: Re: KASAN: use-after-free Read in tipc_group_size
> > 
> > On Mon, Jan 8, 2018 at 6:58 AM, syzbot
> > <syzbot+aae58876fb5a1fad0...@syzkaller.appspotmail.com> wrote:
> > > Hello,
> > >
> > > syzkaller hit the following crash on
> > > b2cd1df66037e7c4697c7e40496bf7e4a5e16a2d
> > > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/maste
> > > r
> > > compiler: gcc (GCC) 7.1.1 20170620
> > > .config is attached
> > > Raw console output is attached.
> > > C reproducer is attached
> > > syzkaller reproducer is attached. See https://goo.gl/kgGztJ for
> > > information about syzkaller reproducers
> > >
> > >
> > > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > > Reported-by: syzbot+aae58876fb5a1fad0...@syzkaller.appspotmail.com
> > > 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 tipc_group_size+0x40/0x50
> > > net/tipc/group.c:158 Read of size 2 at addr 8801c08ba280 by task
> > > syzkaller447710/3513
> > >
> > > CPU: 0 PID: 3513 Comm: syzkaller447710 Not tainted 4.15.0-rc7+ #252
> > > 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:252
> > > kasan_report_error mm/kasan/report.c:351 [inline]
> > >  kasan_report+0x25b/0x340 mm/kasan/report.c:409
> > >  __asan_report_load2_noabort+0x14/0x20 mm/kasan/report.c:428
> > >  tipc_group_size+0x40/0x50 net/tipc/group.c:158
> > >  tipc_poll+0x374/0x4f0 net/tipc/socket.c:739
> > 
> > Seems we have to lock the sock for tipc_group_size() in tipc_poll().
> 
> Not quite. I think it is that we initialize 'grp' on the stack before we call 
> sock_poll_wait() and access it after it returns.
> This is anyway fixed in patch #9 of the series I just sent to net-next, where 
> the poll() handling for group members is redesigned.
> 
> ///jon
> 

Last occurred on Jan 16.  Seems to have been fixed by commit 60c2530696320:

#syz fix: tipc: fix race between poll() and setsockopt()

- Eric


Re: KASAN: use-after-free Read in tipc_group_size

2018-02-01 Thread Eric Biggers
On Mon, Jan 08, 2018 at 08:11:35PM +, Jon Maloy wrote:
> 
> 
> > -Original Message-
> > From: Cong Wang [mailto:xiyou.wangc...@gmail.com]
> > Sent: Monday, January 08, 2018 13:44
> > To: syzbot 
> > Cc: David Miller ; Jon Maloy
> > ; LKML ; Linux
> > Kernel Network Developers ; syzkaller-
> > b...@googlegroups.com; tipc-discuss...@lists.sourceforge.net; Ying Xue
> > 
> > Subject: Re: KASAN: use-after-free Read in tipc_group_size
> > 
> > On Mon, Jan 8, 2018 at 6:58 AM, syzbot
> >  wrote:
> > > Hello,
> > >
> > > syzkaller hit the following crash on
> > > b2cd1df66037e7c4697c7e40496bf7e4a5e16a2d
> > > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/maste
> > > r
> > > compiler: gcc (GCC) 7.1.1 20170620
> > > .config is attached
> > > Raw console output is attached.
> > > C reproducer is attached
> > > syzkaller reproducer is attached. See https://goo.gl/kgGztJ for
> > > information about syzkaller reproducers
> > >
> > >
> > > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > > Reported-by: syzbot+aae58876fb5a1fad0...@syzkaller.appspotmail.com
> > > 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 tipc_group_size+0x40/0x50
> > > net/tipc/group.c:158 Read of size 2 at addr 8801c08ba280 by task
> > > syzkaller447710/3513
> > >
> > > CPU: 0 PID: 3513 Comm: syzkaller447710 Not tainted 4.15.0-rc7+ #252
> > > 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:252
> > > kasan_report_error mm/kasan/report.c:351 [inline]
> > >  kasan_report+0x25b/0x340 mm/kasan/report.c:409
> > >  __asan_report_load2_noabort+0x14/0x20 mm/kasan/report.c:428
> > >  tipc_group_size+0x40/0x50 net/tipc/group.c:158
> > >  tipc_poll+0x374/0x4f0 net/tipc/socket.c:739
> > 
> > Seems we have to lock the sock for tipc_group_size() in tipc_poll().
> 
> Not quite. I think it is that we initialize 'grp' on the stack before we call 
> sock_poll_wait() and access it after it returns.
> This is anyway fixed in patch #9 of the series I just sent to net-next, where 
> the poll() handling for group members is redesigned.
> 
> ///jon
> 

Last occurred on Jan 16.  Seems to have been fixed by commit 60c2530696320:

#syz fix: tipc: fix race between poll() and setsockopt()

- Eric


RE: KASAN: use-after-free Read in tipc_group_size

2018-01-08 Thread Jon Maloy


> -Original Message-
> From: Cong Wang [mailto:xiyou.wangc...@gmail.com]
> Sent: Monday, January 08, 2018 13:44
> To: syzbot <syzbot+aae58876fb5a1fad0...@syzkaller.appspotmail.com>
> Cc: David Miller <da...@davemloft.net>; Jon Maloy
> <jon.ma...@ericsson.com>; LKML <linux-kernel@vger.kernel.org>; Linux
> Kernel Network Developers <net...@vger.kernel.org>; syzkaller-
> b...@googlegroups.com; tipc-discuss...@lists.sourceforge.net; Ying Xue
> <ying....@windriver.com>
> Subject: Re: KASAN: use-after-free Read in tipc_group_size
> 
> On Mon, Jan 8, 2018 at 6:58 AM, syzbot
> <syzbot+aae58876fb5a1fad0...@syzkaller.appspotmail.com> wrote:
> > Hello,
> >
> > syzkaller hit the following crash on
> > b2cd1df66037e7c4697c7e40496bf7e4a5e16a2d
> > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/maste
> > r
> > compiler: gcc (GCC) 7.1.1 20170620
> > .config is attached
> > Raw console output is attached.
> > C reproducer is attached
> > syzkaller reproducer is attached. See https://goo.gl/kgGztJ for
> > information about syzkaller reproducers
> >
> >
> > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > Reported-by: syzbot+aae58876fb5a1fad0...@syzkaller.appspotmail.com
> > 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 tipc_group_size+0x40/0x50
> > net/tipc/group.c:158 Read of size 2 at addr 8801c08ba280 by task
> > syzkaller447710/3513
> >
> > CPU: 0 PID: 3513 Comm: syzkaller447710 Not tainted 4.15.0-rc7+ #252
> > 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:252
> > kasan_report_error mm/kasan/report.c:351 [inline]
> >  kasan_report+0x25b/0x340 mm/kasan/report.c:409
> >  __asan_report_load2_noabort+0x14/0x20 mm/kasan/report.c:428
> >  tipc_group_size+0x40/0x50 net/tipc/group.c:158
> >  tipc_poll+0x374/0x4f0 net/tipc/socket.c:739
> 
> Seems we have to lock the sock for tipc_group_size() in tipc_poll().

Not quite. I think it is that we initialize 'grp' on the stack before we call 
sock_poll_wait() and access it after it returns.
This is anyway fixed in patch #9 of the series I just sent to net-next, where 
the poll() handling for group members is redesigned.

///jon

> 
> 
> >  sock_poll+0x141/0x320 net/socket.c:1117  do_pollfd fs/select.c:822
> > [inline]  do_poll fs/select.c:872 [inline]
> >  do_sys_poll+0x715/0x10b0 fs/select.c:966  SYSC_poll fs/select.c:1024
> > [inline]
> >  SyS_poll+0x10d/0x450 fs/select.c:1012
> > entry_SYSCALL_64_fastpath+0x23/0x9a
> > RIP: 0033:0x445cb9
> > RSP: 002b:7f04886b1ce8 EFLAGS: 0246 ORIG_RAX:
> 0007
> > RAX: ffda RBX: 006dac3c RCX: 00445cb9
> > RDX:  RSI: 0001 RDI: 20fa2ff8
> > RBP: 006dac38 R08:  R09: 
> > R10:  R11: 0246 R12: 
> > R13: 7ffc84d56d7f R14: 7f04886b29c0 R15: 0005
> >
> > Allocated by task 3510:
> >  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:3610  kmalloc
> > include/linux/slab.h:499 [inline]  kzalloc include/linux/slab.h:688
> > [inline]
> >  tipc_group_create+0x116/0x9c0 net/tipc/group.c:167  tipc_sk_join
> > net/tipc/socket.c:2747 [inline]
> >  tipc_setsockopt+0x249/0xc10 net/tipc/socket.c:2861  SYSC_setsockopt
> > net/socket.c:1829 [inline]
> >  SyS_setsockopt+0x189/0x360 net/socket.c:1808
> > entry_SYSCALL_64_fastpath+0x23/0x9a
> >
> > Freed by task 3510:
> >  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:3488 [inline]
> >  kfree+0xd6/0x260 mm/slab.c:3803
> >  tipc_group_delete+0x2c8/0x3d0 net/tipc/group.c:206  tipc_sk_join
> > net/tipc/socket.c:2760 [inline]
> >  tipc_setsockopt+0xb0d/0xc10 net/tipc/socket.c:2861  SYSC_setsockopt
> > net/socket.c:1829 [inline]
> >  SyS_setsockopt

RE: KASAN: use-after-free Read in tipc_group_size

2018-01-08 Thread Jon Maloy


> -Original Message-
> From: Cong Wang [mailto:xiyou.wangc...@gmail.com]
> Sent: Monday, January 08, 2018 13:44
> To: syzbot 
> Cc: David Miller ; Jon Maloy
> ; LKML ; Linux
> Kernel Network Developers ; syzkaller-
> b...@googlegroups.com; tipc-discuss...@lists.sourceforge.net; Ying Xue
> 
> Subject: Re: KASAN: use-after-free Read in tipc_group_size
> 
> On Mon, Jan 8, 2018 at 6:58 AM, syzbot
>  wrote:
> > Hello,
> >
> > syzkaller hit the following crash on
> > b2cd1df66037e7c4697c7e40496bf7e4a5e16a2d
> > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/maste
> > r
> > compiler: gcc (GCC) 7.1.1 20170620
> > .config is attached
> > Raw console output is attached.
> > C reproducer is attached
> > syzkaller reproducer is attached. See https://goo.gl/kgGztJ for
> > information about syzkaller reproducers
> >
> >
> > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > Reported-by: syzbot+aae58876fb5a1fad0...@syzkaller.appspotmail.com
> > 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 tipc_group_size+0x40/0x50
> > net/tipc/group.c:158 Read of size 2 at addr 8801c08ba280 by task
> > syzkaller447710/3513
> >
> > CPU: 0 PID: 3513 Comm: syzkaller447710 Not tainted 4.15.0-rc7+ #252
> > 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:252
> > kasan_report_error mm/kasan/report.c:351 [inline]
> >  kasan_report+0x25b/0x340 mm/kasan/report.c:409
> >  __asan_report_load2_noabort+0x14/0x20 mm/kasan/report.c:428
> >  tipc_group_size+0x40/0x50 net/tipc/group.c:158
> >  tipc_poll+0x374/0x4f0 net/tipc/socket.c:739
> 
> Seems we have to lock the sock for tipc_group_size() in tipc_poll().

Not quite. I think it is that we initialize 'grp' on the stack before we call 
sock_poll_wait() and access it after it returns.
This is anyway fixed in patch #9 of the series I just sent to net-next, where 
the poll() handling for group members is redesigned.

///jon

> 
> 
> >  sock_poll+0x141/0x320 net/socket.c:1117  do_pollfd fs/select.c:822
> > [inline]  do_poll fs/select.c:872 [inline]
> >  do_sys_poll+0x715/0x10b0 fs/select.c:966  SYSC_poll fs/select.c:1024
> > [inline]
> >  SyS_poll+0x10d/0x450 fs/select.c:1012
> > entry_SYSCALL_64_fastpath+0x23/0x9a
> > RIP: 0033:0x445cb9
> > RSP: 002b:7f04886b1ce8 EFLAGS: 0246 ORIG_RAX:
> 0007
> > RAX: ffda RBX: 006dac3c RCX: 00445cb9
> > RDX:  RSI: 0001 RDI: 20fa2ff8
> > RBP: 006dac38 R08:  R09: 
> > R10:  R11: 0246 R12: 
> > R13: 7ffc84d56d7f R14: 7f04886b29c0 R15: 0005
> >
> > Allocated by task 3510:
> >  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:3610  kmalloc
> > include/linux/slab.h:499 [inline]  kzalloc include/linux/slab.h:688
> > [inline]
> >  tipc_group_create+0x116/0x9c0 net/tipc/group.c:167  tipc_sk_join
> > net/tipc/socket.c:2747 [inline]
> >  tipc_setsockopt+0x249/0xc10 net/tipc/socket.c:2861  SYSC_setsockopt
> > net/socket.c:1829 [inline]
> >  SyS_setsockopt+0x189/0x360 net/socket.c:1808
> > entry_SYSCALL_64_fastpath+0x23/0x9a
> >
> > Freed by task 3510:
> >  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:3488 [inline]
> >  kfree+0xd6/0x260 mm/slab.c:3803
> >  tipc_group_delete+0x2c8/0x3d0 net/tipc/group.c:206  tipc_sk_join
> > net/tipc/socket.c:2760 [inline]
> >  tipc_setsockopt+0xb0d/0xc10 net/tipc/socket.c:2861  SYSC_setsockopt
> > net/socket.c:1829 [inline]
> >  SyS_setsockopt+0x189/0x360 net/socket.c:1808
> > entry_SYSCALL_64_fastpath+0x23/0x9a
> >
> > The buggy address belongs to the object at 8801c08ba200  which
> > belongs to the cache kmalloc-192 of size 192 The buggy address is
> > located 128 bytes inside of  19

Re: KASAN: use-after-free Read in tipc_group_size

2018-01-08 Thread Cong Wang
On Mon, Jan 8, 2018 at 6:58 AM, syzbot
 wrote:
> Hello,
>
> syzkaller hit the following crash on
> b2cd1df66037e7c4697c7e40496bf7e4a5e16a2d
> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/master
> compiler: gcc (GCC) 7.1.1 20170620
> .config is attached
> Raw console output is attached.
> C reproducer is attached
> syzkaller reproducer is attached. See https://goo.gl/kgGztJ
> for information about syzkaller reproducers
>
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+aae58876fb5a1fad0...@syzkaller.appspotmail.com
> 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 tipc_group_size+0x40/0x50 net/tipc/group.c:158
> Read of size 2 at addr 8801c08ba280 by task syzkaller447710/3513
>
> CPU: 0 PID: 3513 Comm: syzkaller447710 Not tainted 4.15.0-rc7+ #252
> 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:252
>  kasan_report_error mm/kasan/report.c:351 [inline]
>  kasan_report+0x25b/0x340 mm/kasan/report.c:409
>  __asan_report_load2_noabort+0x14/0x20 mm/kasan/report.c:428
>  tipc_group_size+0x40/0x50 net/tipc/group.c:158
>  tipc_poll+0x374/0x4f0 net/tipc/socket.c:739

Seems we have to lock the sock for tipc_group_size() in
tipc_poll().


>  sock_poll+0x141/0x320 net/socket.c:1117
>  do_pollfd fs/select.c:822 [inline]
>  do_poll fs/select.c:872 [inline]
>  do_sys_poll+0x715/0x10b0 fs/select.c:966
>  SYSC_poll fs/select.c:1024 [inline]
>  SyS_poll+0x10d/0x450 fs/select.c:1012
>  entry_SYSCALL_64_fastpath+0x23/0x9a
> RIP: 0033:0x445cb9
> RSP: 002b:7f04886b1ce8 EFLAGS: 0246 ORIG_RAX: 0007
> RAX: ffda RBX: 006dac3c RCX: 00445cb9
> RDX:  RSI: 0001 RDI: 20fa2ff8
> RBP: 006dac38 R08:  R09: 
> R10:  R11: 0246 R12: 
> R13: 7ffc84d56d7f R14: 7f04886b29c0 R15: 0005
>
> Allocated by task 3510:
>  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:3610
>  kmalloc include/linux/slab.h:499 [inline]
>  kzalloc include/linux/slab.h:688 [inline]
>  tipc_group_create+0x116/0x9c0 net/tipc/group.c:167
>  tipc_sk_join net/tipc/socket.c:2747 [inline]
>  tipc_setsockopt+0x249/0xc10 net/tipc/socket.c:2861
>  SYSC_setsockopt net/socket.c:1829 [inline]
>  SyS_setsockopt+0x189/0x360 net/socket.c:1808
>  entry_SYSCALL_64_fastpath+0x23/0x9a
>
> Freed by task 3510:
>  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:3488 [inline]
>  kfree+0xd6/0x260 mm/slab.c:3803
>  tipc_group_delete+0x2c8/0x3d0 net/tipc/group.c:206
>  tipc_sk_join net/tipc/socket.c:2760 [inline]
>  tipc_setsockopt+0xb0d/0xc10 net/tipc/socket.c:2861
>  SYSC_setsockopt net/socket.c:1829 [inline]
>  SyS_setsockopt+0x189/0x360 net/socket.c:1808
>  entry_SYSCALL_64_fastpath+0x23/0x9a
>
> The buggy address belongs to the object at 8801c08ba200
>  which belongs to the cache kmalloc-192 of size 192
> The buggy address is located 128 bytes inside of
>  192-byte region [8801c08ba200, 8801c08ba2c0)
> The buggy address belongs to the page:
> page:ea0007022e80 count:1 mapcount:0 mapping:8801c08ba000 index:0x0
> flags: 0x2fffc000100(slab)
> raw: 02fffc000100 8801c08ba000  00010010
> raw: ea00071338a0 ea0006fe2360 8801dac00040 
> page dumped because: kasan: bad access detected
>
> Memory state around the buggy address:
>  8801c08ba180: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>  8801c08ba200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>>
>> 8801c08ba280: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>
>^
>  8801c08ba300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>  8801c08ba380: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
> ==
>
>
> ---
> This bug is generated by a dumb bot. It may contain errors.
> See https://goo.gl/tpsmEJ for details.
> Direct all questions to syzkal...@googlegroups.com.
>
> 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
> If you want to test a patch for this 

Re: KASAN: use-after-free Read in tipc_group_size

2018-01-08 Thread Cong Wang
On Mon, Jan 8, 2018 at 6:58 AM, syzbot
 wrote:
> Hello,
>
> syzkaller hit the following crash on
> b2cd1df66037e7c4697c7e40496bf7e4a5e16a2d
> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/master
> compiler: gcc (GCC) 7.1.1 20170620
> .config is attached
> Raw console output is attached.
> C reproducer is attached
> syzkaller reproducer is attached. See https://goo.gl/kgGztJ
> for information about syzkaller reproducers
>
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+aae58876fb5a1fad0...@syzkaller.appspotmail.com
> 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 tipc_group_size+0x40/0x50 net/tipc/group.c:158
> Read of size 2 at addr 8801c08ba280 by task syzkaller447710/3513
>
> CPU: 0 PID: 3513 Comm: syzkaller447710 Not tainted 4.15.0-rc7+ #252
> 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:252
>  kasan_report_error mm/kasan/report.c:351 [inline]
>  kasan_report+0x25b/0x340 mm/kasan/report.c:409
>  __asan_report_load2_noabort+0x14/0x20 mm/kasan/report.c:428
>  tipc_group_size+0x40/0x50 net/tipc/group.c:158
>  tipc_poll+0x374/0x4f0 net/tipc/socket.c:739

Seems we have to lock the sock for tipc_group_size() in
tipc_poll().


>  sock_poll+0x141/0x320 net/socket.c:1117
>  do_pollfd fs/select.c:822 [inline]
>  do_poll fs/select.c:872 [inline]
>  do_sys_poll+0x715/0x10b0 fs/select.c:966
>  SYSC_poll fs/select.c:1024 [inline]
>  SyS_poll+0x10d/0x450 fs/select.c:1012
>  entry_SYSCALL_64_fastpath+0x23/0x9a
> RIP: 0033:0x445cb9
> RSP: 002b:7f04886b1ce8 EFLAGS: 0246 ORIG_RAX: 0007
> RAX: ffda RBX: 006dac3c RCX: 00445cb9
> RDX:  RSI: 0001 RDI: 20fa2ff8
> RBP: 006dac38 R08:  R09: 
> R10:  R11: 0246 R12: 
> R13: 7ffc84d56d7f R14: 7f04886b29c0 R15: 0005
>
> Allocated by task 3510:
>  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:3610
>  kmalloc include/linux/slab.h:499 [inline]
>  kzalloc include/linux/slab.h:688 [inline]
>  tipc_group_create+0x116/0x9c0 net/tipc/group.c:167
>  tipc_sk_join net/tipc/socket.c:2747 [inline]
>  tipc_setsockopt+0x249/0xc10 net/tipc/socket.c:2861
>  SYSC_setsockopt net/socket.c:1829 [inline]
>  SyS_setsockopt+0x189/0x360 net/socket.c:1808
>  entry_SYSCALL_64_fastpath+0x23/0x9a
>
> Freed by task 3510:
>  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:3488 [inline]
>  kfree+0xd6/0x260 mm/slab.c:3803
>  tipc_group_delete+0x2c8/0x3d0 net/tipc/group.c:206
>  tipc_sk_join net/tipc/socket.c:2760 [inline]
>  tipc_setsockopt+0xb0d/0xc10 net/tipc/socket.c:2861
>  SYSC_setsockopt net/socket.c:1829 [inline]
>  SyS_setsockopt+0x189/0x360 net/socket.c:1808
>  entry_SYSCALL_64_fastpath+0x23/0x9a
>
> The buggy address belongs to the object at 8801c08ba200
>  which belongs to the cache kmalloc-192 of size 192
> The buggy address is located 128 bytes inside of
>  192-byte region [8801c08ba200, 8801c08ba2c0)
> The buggy address belongs to the page:
> page:ea0007022e80 count:1 mapcount:0 mapping:8801c08ba000 index:0x0
> flags: 0x2fffc000100(slab)
> raw: 02fffc000100 8801c08ba000  00010010
> raw: ea00071338a0 ea0006fe2360 8801dac00040 
> page dumped because: kasan: bad access detected
>
> Memory state around the buggy address:
>  8801c08ba180: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>  8801c08ba200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>>
>> 8801c08ba280: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>
>^
>  8801c08ba300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>  8801c08ba380: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
> ==
>
>
> ---
> This bug is generated by a dumb bot. It may contain errors.
> See https://goo.gl/tpsmEJ for details.
> Direct all questions to syzkal...@googlegroups.com.
>
> 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
> If you want to test a patch for this bug, please reply with:
> #syz test: