From: Pavel Machek <pavel@denx.de>
To: pavel@ucw.cz
Cc: linux-kernel@vger.kernel.org, Neil Horman <nhorman@tuxdriver.com>,
syzbot+f7e9153b037eac9b1df8@syzkaller.appspotmail.com,
Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
Xin Long <lucien.xin@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org
Subject: Re: [PATCH 4.19 10/61] sctp: Free cookie before we memdup a new one
Date: Sat, 22 Jun 2019 10:20:11 +0200 [thread overview]
Message-ID: <20190622082011.GB10751@amd> (raw)
In-Reply-To: <20190620174339.137345137@linuxfoundation.org>
[-- Attachment #1: Type: text/plain, Size: 1068 bytes --]
Hi!
On Thu 2019-06-20 19:57:05, Greg Kroah-Hartman wrote:
> From: Neil Horman <nhorman@tuxdriver.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
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
prev parent reply other threads:[~2019-06-22 8:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190620174336.357373754@linuxfoundation.org>
2019-06-20 17:57 ` [PATCH 4.19 10/61] sctp: Free cookie before we memdup a new one Greg Kroah-Hartman
2019-06-22 8:20 ` Pavel Machek [this message]
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=20190622082011.GB10751@amd \
--to=pavel@denx.de \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lucien.xin@gmail.com \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=pavel@ucw.cz \
--cc=syzbot+f7e9153b037eac9b1df8@syzkaller.appspotmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).