[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADvbK_czxOqGPDCZmvZgP6A7aSKC-W4U2WaAwL89uBpi4EEVog@mail.gmail.com>
Date: Tue, 11 Jun 2019 00:54:22 +0800
From: Xin Long <lucien.xin@...il.com>
To: Neil Horman <nhorman@...driver.com>
Cc: linux-sctp@...r.kernel.org, network dev <netdev@...r.kernel.org>,
Marcelo Ricardo Leitner <marcelo.leitner@...il.com>,
"David S. Miller" <davem@...emloft.net>
Subject: Re: [PATCH] Free cookie before we memdup a new one
On Tue, Jun 11, 2019 at 12:35 AM Neil Horman <nhorman@...driver.com> wrote:
>
> Based on comments from Xin, even after fixes for our recent syzbot
> report of cookie memory leaks, its possible to get a resend of an INIT
> chunk which would lead to us leaking cookie memory.
>
> To ensure that we don't leak cookie memory, free any previously
> allocated cookie first.
Hi, Neil,
I think we should also do the same thing to the other 2 kmemdups in
sctp_process_param():
asoc->peer.peer_random
asoc->peer.peer_hmacs
>
> Signed-off-by: Neil Horman <nhorman@...driver.com>
> CC: Marcelo Ricardo Leitner <marcelo.leitner@...il.com>
> CC: Xin Long <lucien.xin@...il.com>
> CC: "David S. Miller" <davem@...emloft.net>
> CC: netdev@...r.kernel.org
> ---
> net/sctp/sm_make_chunk.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
> index f17908f5c4f3..21f7faf032e5 100644
> --- a/net/sctp/sm_make_chunk.c
> +++ b/net/sctp/sm_make_chunk.c
> @@ -2583,6 +2583,8 @@ static int sctp_process_param(struct sctp_association *asoc,
> case SCTP_PARAM_STATE_COOKIE:
> asoc->peer.cookie_len =
> ntohs(param.p->length) - sizeof(struct sctp_paramhdr);
> + if (asoc->peer.cookie)
> + kfree(asoc->peer.cookie);
> asoc->peer.cookie = kmemdup(param.cookie->body, asoc->peer.cookie_len, gfp);
> if (!asoc->peer.cookie)
> retval = 0;
> --
> 2.20.1
>
Powered by blists - more mailing lists