All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Hillf Danton <hdanton@sina.com>
Cc: syzbot <syzbot+6ad9c3bd0a218a2ab41d@syzkaller.appspotmail.com>,
	davem@davemloft.net, linux-kernel@vger.kernel.org,
	linux-sctp@vger.kernel.org, netdev@vger.kernel.org,
	nhorman@tuxdriver.com, syzkaller-bugs@googlegroups.com,
	vyasevich@gmail.com
Subject: Re: memory leak in sctp_send_reset_streams
Date: Sat, 01 Jun 2019 15:47:53 +0000	[thread overview]
Message-ID: <20190601154753.GG3713@localhost.localdomain> (raw)
In-Reply-To: <20190601122615.16872-1-hdanton@sina.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1254", Size: 5531 bytes --]

On Sat, Jun 01, 2019 at 08:26:15PM +0800, Hillf Danton wrote:
> 
> Hi

Hi,

> 
> On Fri, May 31, 2019 at 02:18:06PM -0700, syzbot wrote:
> > Hello,
> > 
> > syzbot found the following crash on:
> > 
> > HEAD commit:    036e3431 Merge git://git.kernel.org/pub/scm/linux/kernel/g..
> > git tree:       upstream
> > console output: https://syzkaller.appspot.com/x/log.txt?x\x153cff12a00000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x0f63a62bb5b13c
> > dashboard link: https://syzkaller.appspot.com/bug?extidjd9c3bd0a218a2ab41d
> > compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x\x12561c86a00000
> > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x\x15b76fd8a00000
> > 
> > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > Reported-by: syzbot+6ad9c3bd0a218a2ab41d@syzkaller.appspotmail.com
> > 
> > executing program
> > executing program
> > executing program
> > executing program
> > executing program
> > BUG: memory leak
> > unreferenced object 0xffff888123894820 (size 32):
> >    comm "syz-executor045", pid 7267, jiffies 4294943559 (age 13.660s)
> >    hex dump (first 32 bytes):
> >      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
> >      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
> >    backtrace:
> >      [<00000000c7e71c69>] kmemleak_alloc_recursive
> > include/linux/kmemleak.h:55 [inline]
> >      [<00000000c7e71c69>] slab_post_alloc_hook mm/slab.h:439 [inline]
> >      [<00000000c7e71c69>] slab_alloc mm/slab.c:3326 [inline]
> >      [<00000000c7e71c69>] __do_kmalloc mm/slab.c:3658 [inline]
> >      [<00000000c7e71c69>] __kmalloc+0x161/0x2c0 mm/slab.c:3669
> >      [<000000003250ed8e>] kmalloc_array include/linux/slab.h:670 [inline]
> >      [<000000003250ed8e>] kcalloc include/linux/slab.h:681 [inline]
> >      [<000000003250ed8e>] sctp_send_reset_streams+0x1ab/0x5a0 net/sctp/stream.c:302
> >      [<00000000cd899c6e>] sctp_setsockopt_reset_streams net/sctp/socket.c:4314 [inline]
> >      [<00000000cd899c6e>] sctp_setsockopt net/sctp/socket.c:4765 [inline]
> >      [<00000000cd899c6e>] sctp_setsockopt+0xc23/0x2bf0 net/sctp/socket.c:4608
> >      [<00000000ff3a21a2>] sock_common_setsockopt+0x38/0x50 net/core/sock.c:3130
> >      [<000000009eb87ae7>] __sys_setsockopt+0x98/0x120 net/socket.c:2078
> >      [<00000000e0ede6ca>] __do_sys_setsockopt net/socket.c:2089 [inline]
> >      [<00000000e0ede6ca>] __se_sys_setsockopt net/socket.c:2086 [inline]
> >      [<00000000e0ede6ca>] __x64_sys_setsockopt+0x26/0x30 net/socket.c:2086
> >      [<00000000c61155f5>] do_syscall_64+0x76/0x1a0 arch/x86/entry/common.c:301
> >      [<00000000e540958c>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
> > 
> > BUG: memory leak
> > unreferenced object 0xffff888123894980 (size 32):
> >    comm "syz-executor045", pid 7268, jiffies 4294944145 (age 7.800s)
> >    hex dump (first 32 bytes):
> >      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
> >      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
> >    backtrace:
> >      [<00000000c7e71c69>] kmemleak_alloc_recursive
> > include/linux/kmemleak.h:55 [inline]
> >      [<00000000c7e71c69>] slab_post_alloc_hook mm/slab.h:439 [inline]
> >      [<00000000c7e71c69>] slab_alloc mm/slab.c:3326 [inline]
> >      [<00000000c7e71c69>] __do_kmalloc mm/slab.c:3658 [inline]
> >      [<00000000c7e71c69>] __kmalloc+0x161/0x2c0 mm/slab.c:3669
> >      [<000000003250ed8e>] kmalloc_array include/linux/slab.h:670 [inline]
> >      [<000000003250ed8e>] kcalloc include/linux/slab.h:681 [inline]
> >      [<000000003250ed8e>] sctp_send_reset_streams+0x1ab/0x5a0 net/sctp/stream.c:302
> >      [<00000000cd899c6e>] sctp_setsockopt_reset_streams net/sctp/socket.c:4314 [inline]
> >      [<00000000cd899c6e>] sctp_setsockopt net/sctp/socket.c:4765 [inline]
> >      [<00000000cd899c6e>] sctp_setsockopt+0xc23/0x2bf0 net/sctp/socket.c:4608
> >      [<00000000ff3a21a2>] sock_common_setsockopt+0x38/0x50 net/core/sock.c:3130
> >      [<000000009eb87ae7>] __sys_setsockopt+0x98/0x120 net/socket.c:2078
> >      [<00000000e0ede6ca>] __do_sys_setsockopt net/socket.c:2089 [inline]
> >      [<00000000e0ede6ca>] __se_sys_setsockopt net/socket.c:2086 [inline]
> >      [<00000000e0ede6ca>] __x64_sys_setsockopt+0x26/0x30 net/socket.c:2086
> >      [<00000000c61155f5>] do_syscall_64+0x76/0x1a0 arch/x86/entry/common.c:301
> >      [<00000000e540958c>] 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@googlegroups.com.
> > 
> > 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
> > 
> The following tiny change is prepared based on the info listed above and I want
> to know if it works for you.
> 
> thanks
> Hillf
> ------->8---
> diff --git a/net/sctp/stream.c b/net/sctp/stream.c
> index 93ed078..d3e2f03 100644
> --- a/net/sctp/stream.c
> +++ b/net/sctp/stream.c
> @@ -310,6 +310,7 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
> 
> 	if (out && !sctp_stream_outq_is_empty(stream, str_nums, nstr_list)) {
> 		retval = -EAGAIN;
> +		kfree(nstr_list);

Yes it does. Thanks Hillf.

> 		goto out;
> 	}
> 
> --
> 

WARNING: multiple messages have this Message-ID (diff)
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Hillf Danton <hdanton@sina.com>
Cc: syzbot <syzbot+6ad9c3bd0a218a2ab41d@syzkaller.appspotmail.com>,
	davem@davemloft.net, linux-kernel@vger.kernel.org,
	linux-sctp@vger.kernel.org, netdev@vger.kernel.org,
	nhorman@tuxdriver.com, syzkaller-bugs@googlegroups.com,
	vyasevich@gmail.com
Subject: Re: memory leak in sctp_send_reset_streams
Date: Sat, 1 Jun 2019 12:47:53 -0300	[thread overview]
Message-ID: <20190601154753.GG3713@localhost.localdomain> (raw)
In-Reply-To: <20190601122615.16872-1-hdanton@sina.com>

On Sat, Jun 01, 2019 at 08:26:15PM +0800, Hillf Danton wrote:
> 
> Hi

Hi,

> 
> On Fri, May 31, 2019 at 02:18:06PM -0700, syzbot wrote:
> > Hello,
> > 
> > syzbot found the following crash on:
> > 
> > HEAD commit:    036e3431 Merge git://git.kernel.org/pub/scm/linux/kernel/g..
> > git tree:       upstream
> > console output: https://syzkaller.appspot.com/x/log.txt?x=153cff12a00000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=8f0f63a62bb5b13c
> > dashboard link: https://syzkaller.appspot.com/bug?extid=6ad9c3bd0a218a2ab41d
> > compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=12561c86a00000
> > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=15b76fd8a00000
> > 
> > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > Reported-by: syzbot+6ad9c3bd0a218a2ab41d@syzkaller.appspotmail.com
> > 
> > executing program
> > executing program
> > executing program
> > executing program
> > executing program
> > BUG: memory leak
> > unreferenced object 0xffff888123894820 (size 32):
> >    comm "syz-executor045", pid 7267, jiffies 4294943559 (age 13.660s)
> >    hex dump (first 32 bytes):
> >      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
> >      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
> >    backtrace:
> >      [<00000000c7e71c69>] kmemleak_alloc_recursive
> > include/linux/kmemleak.h:55 [inline]
> >      [<00000000c7e71c69>] slab_post_alloc_hook mm/slab.h:439 [inline]
> >      [<00000000c7e71c69>] slab_alloc mm/slab.c:3326 [inline]
> >      [<00000000c7e71c69>] __do_kmalloc mm/slab.c:3658 [inline]
> >      [<00000000c7e71c69>] __kmalloc+0x161/0x2c0 mm/slab.c:3669
> >      [<000000003250ed8e>] kmalloc_array include/linux/slab.h:670 [inline]
> >      [<000000003250ed8e>] kcalloc include/linux/slab.h:681 [inline]
> >      [<000000003250ed8e>] sctp_send_reset_streams+0x1ab/0x5a0 net/sctp/stream.c:302
> >      [<00000000cd899c6e>] sctp_setsockopt_reset_streams net/sctp/socket.c:4314 [inline]
> >      [<00000000cd899c6e>] sctp_setsockopt net/sctp/socket.c:4765 [inline]
> >      [<00000000cd899c6e>] sctp_setsockopt+0xc23/0x2bf0 net/sctp/socket.c:4608
> >      [<00000000ff3a21a2>] sock_common_setsockopt+0x38/0x50 net/core/sock.c:3130
> >      [<000000009eb87ae7>] __sys_setsockopt+0x98/0x120 net/socket.c:2078
> >      [<00000000e0ede6ca>] __do_sys_setsockopt net/socket.c:2089 [inline]
> >      [<00000000e0ede6ca>] __se_sys_setsockopt net/socket.c:2086 [inline]
> >      [<00000000e0ede6ca>] __x64_sys_setsockopt+0x26/0x30 net/socket.c:2086
> >      [<00000000c61155f5>] do_syscall_64+0x76/0x1a0 arch/x86/entry/common.c:301
> >      [<00000000e540958c>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
> > 
> > BUG: memory leak
> > unreferenced object 0xffff888123894980 (size 32):
> >    comm "syz-executor045", pid 7268, jiffies 4294944145 (age 7.800s)
> >    hex dump (first 32 bytes):
> >      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
> >      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
> >    backtrace:
> >      [<00000000c7e71c69>] kmemleak_alloc_recursive
> > include/linux/kmemleak.h:55 [inline]
> >      [<00000000c7e71c69>] slab_post_alloc_hook mm/slab.h:439 [inline]
> >      [<00000000c7e71c69>] slab_alloc mm/slab.c:3326 [inline]
> >      [<00000000c7e71c69>] __do_kmalloc mm/slab.c:3658 [inline]
> >      [<00000000c7e71c69>] __kmalloc+0x161/0x2c0 mm/slab.c:3669
> >      [<000000003250ed8e>] kmalloc_array include/linux/slab.h:670 [inline]
> >      [<000000003250ed8e>] kcalloc include/linux/slab.h:681 [inline]
> >      [<000000003250ed8e>] sctp_send_reset_streams+0x1ab/0x5a0 net/sctp/stream.c:302
> >      [<00000000cd899c6e>] sctp_setsockopt_reset_streams net/sctp/socket.c:4314 [inline]
> >      [<00000000cd899c6e>] sctp_setsockopt net/sctp/socket.c:4765 [inline]
> >      [<00000000cd899c6e>] sctp_setsockopt+0xc23/0x2bf0 net/sctp/socket.c:4608
> >      [<00000000ff3a21a2>] sock_common_setsockopt+0x38/0x50 net/core/sock.c:3130
> >      [<000000009eb87ae7>] __sys_setsockopt+0x98/0x120 net/socket.c:2078
> >      [<00000000e0ede6ca>] __do_sys_setsockopt net/socket.c:2089 [inline]
> >      [<00000000e0ede6ca>] __se_sys_setsockopt net/socket.c:2086 [inline]
> >      [<00000000e0ede6ca>] __x64_sys_setsockopt+0x26/0x30 net/socket.c:2086
> >      [<00000000c61155f5>] do_syscall_64+0x76/0x1a0 arch/x86/entry/common.c:301
> >      [<00000000e540958c>] 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@googlegroups.com.
> > 
> > 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
> > 
> The following tiny change is prepared based on the info listed above and I want
> to know if it works for you.
> 
> thanks
> Hillf
> ------->8---
> diff --git a/net/sctp/stream.c b/net/sctp/stream.c
> index 93ed078..d3e2f03 100644
> --- a/net/sctp/stream.c
> +++ b/net/sctp/stream.c
> @@ -310,6 +310,7 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
> 
> 	if (out && !sctp_stream_outq_is_empty(stream, str_nums, nstr_list)) {
> 		retval = -EAGAIN;
> +		kfree(nstr_list);

Yes it does. Thanks Hillf.

> 		goto out;
> 	}
> 
> --
> 

       reply	other threads:[~2019-06-01 15:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190601122615.16872-1-hdanton@sina.com>
2019-06-01 15:47 ` Marcelo Ricardo Leitner [this message]
2019-06-01 15:47   ` memory leak in sctp_send_reset_streams Marcelo Ricardo Leitner
2019-05-31 21:18 syzbot
2019-05-31 21:18 ` syzbot
2019-05-31 21:19 ` Marcelo Ricardo Leitner
2019-05-31 21:19   ` Marcelo Ricardo Leitner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190601154753.GG3713@localhost.localdomain \
    --to=marcelo.leitner@gmail.com \
    --cc=davem@davemloft.net \
    --cc=hdanton@sina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sctp@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=syzbot+6ad9c3bd0a218a2ab41d@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=vyasevich@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.