From: Neil Horman <nhorman@tuxdriver.com> To: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Cc: syzbot <syzbot+f7e9153b037eac9b1df8@syzkaller.appspotmail.com>, davem@davemloft.net, linux-kernel@vger.kernel.org, linux-sctp@vger.kernel.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com, vyasevich@gmail.com Subject: Re: memory leak in sctp_process_init Date: Thu, 30 May 2019 07:24:18 -0400 [thread overview] Message-ID: <20190530112418.GB1966@hmswarspite.think-freely.org> (raw) In-Reply-To: <20190529233757.GC3713@localhost.localdomain> On Wed, May 29, 2019 at 08:37:57PM -0300, Marcelo Ricardo Leitner wrote: > On Wed, May 29, 2019 at 03:07:09PM -0400, Neil Horman wrote: > > --- a/net/sctp/sm_make_chunk.c > > +++ b/net/sctp/sm_make_chunk.c > > @@ -2419,9 +2419,12 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk, > > /* Copy cookie in case we need to resend COOKIE-ECHO. */ > > cookie = asoc->peer.cookie; > > if (cookie) { > > + if (asoc->peer.cookie_allocated) > > + kfree(cookie); > > asoc->peer.cookie = kmemdup(cookie, asoc->peer.cookie_len, gfp); > > if (!asoc->peer.cookie) > > goto clean_up; > > + asoc->peer.cookie_allocated=1; > > } > > > > /* RFC 2960 7.2.1 The initial value of ssthresh MAY be arbitrarily > > What if we kmemdup directly at sctp_process_param(), as it's done for > others already? Like SCTP_PARAM_RANDOM and SCTP_PARAM_HMAC_ALGO. I > don't see a reason for SCTP_PARAM_STATE_COOKIE to be different > here. This way it would be always allocated, and ready to be kfreed. > > We still need to free it after the handshake, btw. > Yeah, that makes sense, I'll give that a shot. Neil > Marcelo >
WARNING: multiple messages have this Message-ID (diff)
From: Neil Horman <nhorman@tuxdriver.com> To: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Cc: syzbot <syzbot+f7e9153b037eac9b1df8@syzkaller.appspotmail.com>, davem@davemloft.net, linux-kernel@vger.kernel.org, linux-sctp@vger.kernel.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com, vyasevich@gmail.com Subject: Re: memory leak in sctp_process_init Date: Thu, 30 May 2019 11:24:18 +0000 [thread overview] Message-ID: <20190530112418.GB1966@hmswarspite.think-freely.org> (raw) In-Reply-To: <20190529233757.GC3713@localhost.localdomain> On Wed, May 29, 2019 at 08:37:57PM -0300, Marcelo Ricardo Leitner wrote: > On Wed, May 29, 2019 at 03:07:09PM -0400, Neil Horman wrote: > > --- a/net/sctp/sm_make_chunk.c > > +++ b/net/sctp/sm_make_chunk.c > > @@ -2419,9 +2419,12 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk, > > /* Copy cookie in case we need to resend COOKIE-ECHO. */ > > cookie = asoc->peer.cookie; > > if (cookie) { > > + if (asoc->peer.cookie_allocated) > > + kfree(cookie); > > asoc->peer.cookie = kmemdup(cookie, asoc->peer.cookie_len, gfp); > > if (!asoc->peer.cookie) > > goto clean_up; > > + asoc->peer.cookie_allocated=1; > > } > > > > /* RFC 2960 7.2.1 The initial value of ssthresh MAY be arbitrarily > > What if we kmemdup directly at sctp_process_param(), as it's done for > others already? Like SCTP_PARAM_RANDOM and SCTP_PARAM_HMAC_ALGO. I > don't see a reason for SCTP_PARAM_STATE_COOKIE to be different > here. This way it would be always allocated, and ready to be kfreed. > > We still need to free it after the handshake, btw. > Yeah, that makes sense, I'll give that a shot. Neil > Marcelo >
next prev parent reply other threads:[~2019-05-30 11:24 UTC|newest] Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-05-28 0:48 memory leak in sctp_process_init syzbot 2019-05-28 0:48 ` syzbot 2019-05-28 1:36 ` Marcelo Ricardo Leitner 2019-05-28 1:36 ` Marcelo Ricardo Leitner 2019-05-28 11:15 ` Neil Horman 2019-05-28 11:15 ` Neil Horman 2019-05-29 19:07 ` Neil Horman 2019-05-29 19:07 ` Neil Horman 2019-05-29 23:37 ` Marcelo Ricardo Leitner 2019-05-29 23:37 ` Marcelo Ricardo Leitner 2019-05-30 11:24 ` Neil Horman [this message] 2019-05-30 11:24 ` Neil Horman 2019-05-30 14:20 ` Neil Horman 2019-05-30 14:20 ` Neil Horman 2019-05-30 15:17 ` Marcelo Ricardo Leitner 2019-05-30 15:17 ` Marcelo Ricardo Leitner 2019-05-30 19:56 ` Neil Horman 2019-05-30 19:56 ` Neil Horman 2019-05-31 12:42 ` Marcelo Ricardo Leitner 2019-05-31 12:42 ` Marcelo Ricardo Leitner 2019-05-31 16:43 ` Neil Horman 2019-05-31 16:43 ` Neil Horman 2019-06-03 20:32 ` [PATCH V2] Fix " Neil Horman 2019-06-03 20:32 ` Neil Horman 2019-06-03 21:42 ` Marcelo Ricardo Leitner 2019-06-03 21:42 ` Marcelo Ricardo Leitner 2019-06-04 20:16 ` Xin Long 2019-06-04 20:16 ` Xin Long 2019-06-04 20:59 ` Marcelo Ricardo Leitner 2019-06-04 20:59 ` Marcelo Ricardo Leitner 2019-06-05 11:20 ` Neil Horman 2019-06-05 11:20 ` Neil Horman 2019-06-06 15:47 ` Marcelo Ricardo Leitner 2019-06-06 15:47 ` Marcelo Ricardo Leitner 2019-06-07 10:56 ` Neil Horman 2019-06-07 10:56 ` Neil Horman 2019-06-07 12:48 ` Marcelo Ricardo Leitner 2019-06-07 12:48 ` Marcelo Ricardo Leitner 2019-06-08 7:06 ` Xin Long 2019-06-08 7:06 ` Xin Long 2019-06-06 0:14 ` David Miller 2019-06-06 0:14 ` David Miller
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=20190530112418.GB1966@hmswarspite.think-freely.org \ --to=nhorman@tuxdriver.com \ --cc=davem@davemloft.net \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-sctp@vger.kernel.org \ --cc=marcelo.leitner@gmail.com \ --cc=netdev@vger.kernel.org \ --cc=syzbot+f7e9153b037eac9b1df8@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: linkBe 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.