[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20190622082011.GB10751@amd>
Date: Sat, 22 Jun 2019 10:20:11 +0200
From: Pavel Machek <pavel@...x.de>
To: pavel@....cz
Cc: linux-kernel@...r.kernel.org, Neil Horman <nhorman@...driver.com>,
syzbot+f7e9153b037eac9b1df8@...kaller.appspotmail.com,
Marcelo Ricardo Leitner <marcelo.leitner@...il.com>,
Xin Long <lucien.xin@...il.com>,
"David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org
Subject: Re: [PATCH 4.19 10/61] sctp: Free cookie before we memdup a new one
Hi!
On Thu 2019-06-20 19:57:05, Greg Kroah-Hartman wrote:
> From: Neil Horman <nhorman@...driver.com>
>
> [ Upstream commit ce950f1050cece5e406a5cde723c69bba60e1b26 ]
>
> 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.
>
> --- a/net/sctp/sm_make_chunk.c
> +++ b/net/sctp/sm_make_chunk.c
> @@ -2600,6 +2600,8 @@ do_addr_param:
> 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;
kfree() handles NULL just fine. Can we simply work without the tests
and save a bit of code?
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)
Powered by blists - more mailing lists