netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Free cookie before we memdup a new one
@ 2019-06-10 16:34 Neil Horman
  2019-06-10 16:38 ` David Miller
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: Neil Horman @ 2019-06-10 16:34 UTC (permalink / raw)
  To: linux-sctp
  Cc: netdev, Neil Horman, Marcelo Ricardo Leitner, Xin Long, David S. Miller

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.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
CC: Xin Long <lucien.xin@gmail.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: netdev@vger.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


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2019-06-15  2:28 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-10 16:34 [PATCH] Free cookie before we memdup a new one Neil Horman
2019-06-10 16:38 ` David Miller
2019-06-10 16:54 ` Xin Long
2019-06-11 11:21 ` [PATCH v2] [net] " Neil Horman
2019-06-11 11:44   ` Marcelo Ricardo Leitner
2019-06-11 12:17   ` Marcelo Ricardo Leitner
2019-06-11 16:06   ` David Miller
2019-06-11 19:22 ` [PATCH v3] [sctp] " Neil Horman
2019-06-11 20:08   ` David Miller
2019-06-11 20:52     ` Neil Horman
2019-06-12  0:38 ` [PATCH v4 net] sctp: " Neil Horman
2019-06-12 17:58   ` Xin Long
2019-06-12 18:07   ` Marcelo Ricardo Leitner
2019-06-12 20:32     ` Neil Horman
2019-06-12 20:41       ` David Miller
2019-06-13 10:35 ` [PATCH v5 " Neil Horman
2019-06-13 16:51   ` Marcelo Ricardo Leitner
2019-06-15  2:27   ` David Miller

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).