Re: memory leak in sctp_get_port_local (3)

From: Xin Long
Date: Mon Oct 14 2019 - 13:12:15 EST


On Mon, Oct 14, 2019 at 10:50 AM syzbot
<syzbot+d44f7bbebdea49dbc84a@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hello,
>
> syzbot found the following crash on:
>
> HEAD commit: da940012 Merge tag 'char-misc-5.4-rc3' of git://git.kernel..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=11c87fc7600000
> kernel config: https://syzkaller.appspot.com/x/.config?x=e76c708f07645488
> dashboard link: https://syzkaller.appspot.com/bug?extid=d44f7bbebdea49dbc84a
> compiler: gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=128d3f8b600000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17ead04b600000
We probably need to add ".no_autobind = true" in sctp_prot to prevent
sendmsg() from going the path: inet_sendmsg()->inet_send_prepare()->
inet_autobind(), and leave sctp_sendmsg() to handle sctp_autobind().

will have a try tomorrow.

>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+d44f7bbebdea49dbc84a@xxxxxxxxxxxxxxxxxxxxxxxxx
>
> executing program
> executing program
> BUG: memory leak
> unreferenced object 0xffff888120b3d380 (size 64):
> comm "syz-executor517", pid 6949, jiffies 4294941316 (age 13.400s)
> hex dump (first 32 bytes):
> 23 4e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 #N..............
> 88 16 ef 24 81 88 ff ff 00 00 00 00 00 00 00 00 ...$............
> backtrace:
> [<000000006e6207b2>] kmemleak_alloc_recursive
> include/linux/kmemleak.h:43 [inline]
> [<000000006e6207b2>] slab_post_alloc_hook mm/slab.h:586 [inline]
> [<000000006e6207b2>] slab_alloc mm/slab.c:3319 [inline]
> [<000000006e6207b2>] kmem_cache_alloc+0x13f/0x2c0 mm/slab.c:3483
> [<00000000d0d058e2>] sctp_bucket_create net/sctp/socket.c:8523 [inline]
> [<00000000d0d058e2>] sctp_get_port_local+0x189/0x5a0
> net/sctp/socket.c:8270
> [<0000000082735c7f>] sctp_do_bind+0xcc/0x200 net/sctp/socket.c:402
> [<0000000080c8d55e>] sctp_bindx_add+0x4b/0xd0 net/sctp/socket.c:497
> [<00000000eb10f474>] sctp_setsockopt_bindx+0x156/0x1b0
> net/sctp/socket.c:1022
> [<000000004e959dd5>] sctp_setsockopt net/sctp/socket.c:4641 [inline]
> [<000000004e959dd5>] sctp_setsockopt+0xaea/0x2dc0 net/sctp/socket.c:4611
> [<000000000e9e767a>] sock_common_setsockopt+0x38/0x50
> net/core/sock.c:3147
> [<00000000a549638a>] __sys_setsockopt+0x10f/0x220 net/socket.c:2084
> [<000000003c15b96c>] __do_sys_setsockopt net/socket.c:2100 [inline]
> [<000000003c15b96c>] __se_sys_setsockopt net/socket.c:2097 [inline]
> [<000000003c15b96c>] __x64_sys_setsockopt+0x26/0x30 net/socket.c:2097
> [<00000000ee3ea8a3>] do_syscall_64+0x73/0x1f0
> arch/x86/entry/common.c:290
> [<000000006bf005e9>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
>
>
>
> ---
> This bug is generated by a bot. It may contain errors.
> See https://goo.gl/tpsmEJ for more information about syzbot.
> syzbot engineers can be reached at syzkaller@xxxxxxxxxxxxxxxxx
>
> syzbot will keep track of this bug report. See:
> https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
> syzbot can test patches for this bug, for details see:
> https://goo.gl/tpsmEJ#testing-patches