Free cookie before we memdup a new one
Subsystems (3)
PATCH 1/1 Free cookie before we memdup a new one
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.
--- net/sctp/sm_make_chunk.c | 2 ++ 1 file changed, 2 insertions(+)
net/sctp/sm_make_chunk.c +2 -0
@@ -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 ;
Signature · 1 line
2.20.1
David Miller
maintainerFrom: Neil Horman <[email protected]>
Date: Mon, 10 Jun 2019 12:34:56 -0400
Quoted 8 lines
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 <[email protected]>
Please post with an appropriate subsystem prefix in the Subject.
Thank you.
Xin Long
maintainerQuoted 7 lines · Neil Horman
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_randomasoc->peer.peer_hmacs
Quoted 25 lines
Signed-off-by Neil Horman <[email protected]>CC Marcelo Ricardo Leitner <[email protected]>CC Xin Long <[email protected]>CC "David S. Miller" <[email protected]>--- net/sctp/sm_make_chunk.c | 2 ++ 1 file changed, 2 insertions(+)net/sctp/sm_make_chunk.c +2
-1@@ -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
PATCH v2 1/1 Free cookie before we memdup a new one
In reply to Neil HormanBased 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.
---
Change notesv1->v2
update subsystem tag in subject (davem)
repeat kfree check for peer_random and peer_hmacs (xin)
--- net/sctp/sm_make_chunk.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/sctp/sm_make_chunk.c +6 -0
@@ -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 ;
@@ -2647,6 +2649,8 @@ static int sctp_process_param(struct sctp_association *asoc, goto fall_through;/* Save peer's random parameter */ +if (asoc->peer.peer_random) +kfree (asoc->peer.peer_random); asoc->peer.peer_random =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_random) {
@@ -2660,6 +2664,8 @@ static int sctp_process_param(struct sctp_association *asoc, goto fall_through;/* Save peer's HMAC list */ +if (asoc->peer.peer_hmacs) +kfree (asoc->peer.peer_hmacs); asoc->peer.peer_hmacs =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_hmacs) {
Signature · 1 line
2.20.1
Marcelo Ricardo Leitner
maintainerQuoted 4 lines · Neil Horman
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.
Quoted 8 lines
To ensure that we don't leak cookie memory, free any previously allocated cookie first.
---
Change notesv1->v2
update subsystem tag in subject (davem)
repeat kfree check forpeer_randomandpeer_hmacs(xin)
They are actually 4 vars. The 4th one being peer_chunks. And a syzkaller Fixes tag would be welcomed as well, so that if someone backports the fix for it will have a hint to backport this patch also.
Quoted 43 lines
Signed-off-by Neil Horman <[email protected]>CC Marcelo Ricardo Leitner <[email protected]>CC Xin Long <[email protected]>CC "David S. Miller" <[email protected]>--- net/sctp/sm_make_chunk.c | 6 ++++++ 1 file changed, 6 insertions(+)net/sctp/sm_make_chunk.c +6
-0@@ -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 ;@@ -2647,6 +2649,8 @@ static int sctp_process_param(struct sctp_association *asoc, goto fall_through;/* Save peer's random parameter */ +if (asoc->peer.peer_random) +kfree (asoc->peer.peer_random); asoc->peer.peer_random =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_random) {@@ -2660,6 +2664,8 @@ static int sctp_process_param(struct sctp_association *asoc, goto fall_through;/* Save peer's HMAC list */ +if (asoc->peer.peer_hmacs) +kfree (asoc->peer.peer_hmacs); asoc->peer.peer_hmacs =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_hmacs) {Signature · 1 line
2.20.1
Marcelo Ricardo Leitner
maintainerOn Tue, Jun 11, 2019 at 07:21:28AM -0400, Neil Horman wrote:
Btw, I guess DaveM had meant to add "sctp: " in the subject.
Marcelo
David Miller
maintainerFrom: Neil Horman <[email protected]>
Date: Tue, 11 Jun 2019 07:21:28 -0400
Quoted 11 lines
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.
---
Change notesv1->v2
update subsystem tag in subject (davem)
Subsystem tag is "sctp: " which still isn't there :-)
PATCH v3 1/1 Free cookie before we memdup a new one
In reply to Neil HormanBased 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.
---
Change notesv1->v2
update subsystem tag in subject (davem)
repeat kfree check for peer_random and peer_hmacs (xin)
v2->v3net->sctp
also free peer_chunks
--- net/sctp/sm_make_chunk.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/sctp/sm_make_chunk.c +8 -0
@@ -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 ;
@@ -2647,6 +2649,8 @@ static int sctp_process_param(struct sctp_association *asoc, goto fall_through;/* Save peer's random parameter */ +if (asoc->peer.peer_random) +kfree (asoc->peer.peer_random); asoc->peer.peer_random =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_random) {
@@ -2660,6 +2664,8 @@ static int sctp_process_param(struct sctp_association *asoc, goto fall_through;/* Save peer's HMAC list */ +if (asoc->peer.peer_hmacs) +kfree (asoc->peer.peer_hmacs); asoc->peer.peer_hmacs =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_hmacs) {
@@ -2675,6 +2681,8 @@ static int sctp_process_param(struct sctp_association *asoc,if (!ep->auth_enable) goto fall_through; +if (asoc->peer.peer_chunks) +kfree (asoc->peer.peer_chunks); asoc->peer.peer_chunks =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_chunks)
Signature · 1 line
2.20.1
David Miller
maintainerFrom: Neil Horman <[email protected]>
Date: Tue, 11 Jun 2019 15:22:45 -0400
Quoted 3 lines
v2->v3net->sctp
also freepeer_chunks
Neil this isn't the first time you're submitting sctp patches right? ;-)
Subject: "[PATCH v3 net] sctp: Free cookie before we memdup a new one"
It's "subsystem_prefix: " and I even stated this explicitly yesterday.
Quoted 7 lines · David Miller
From: Neil Horman <[email protected]>
Date: Tue, 11 Jun 2019 15:22:45 -0400Quoted 3 lines
v2->v3net->sctp
also freepeer_chunks
Quoted 6 lines
Neil this isn't the first time you're submitting sctp patches right? ;-)
Subject: "[PATCH v3 net] sctp: Free cookie before we memdup a new one"
It's "
subsystem_prefix: " and I even stated this explicitly yesterday.
No, sorry, I'm trying to do this while I get a CI mess sorted out at the same time, and I'm not close attention here.
If you want to take over a few dozen user space packages for me in RHEL, I'll gladly get this right on the first try :)
Neil
PATCH v4 1/1 sctp: Free cookie before we memdup a new one
In reply to Neil HormanBased 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.
---
Change notesv1->v2
update subsystem tag in subject (davem)
repeat kfree check for peer_random and peer_hmacs (xin)
v2->v3net->sctp
also free peer_chunks
v3->v4
fix subject tags
--- net/sctp/sm_make_chunk.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/sctp/sm_make_chunk.c +8 -0
@@ -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 ;
@@ -2647,6 +2649,8 @@ static int sctp_process_param(struct sctp_association *asoc, goto fall_through;/* Save peer's random parameter */ +if (asoc->peer.peer_random) +kfree (asoc->peer.peer_random); asoc->peer.peer_random =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_random) {
@@ -2660,6 +2664,8 @@ static int sctp_process_param(struct sctp_association *asoc, goto fall_through;/* Save peer's HMAC list */ +if (asoc->peer.peer_hmacs) +kfree (asoc->peer.peer_hmacs); asoc->peer.peer_hmacs =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_hmacs) {
@@ -2675,6 +2681,8 @@ static int sctp_process_param(struct sctp_association *asoc,if (!ep->auth_enable) goto fall_through; +if (asoc->peer.peer_chunks) +kfree (asoc->peer.peer_chunks); asoc->peer.peer_chunks =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_chunks)
Signature · 1 line
2.20.1
Re: [PATCH v4 net] sctp: Free cookie before we memdup a new one
Quoted 71 lines · Neil Horman
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.
---
Change notesv1->v2
update subsystem tag in subject (davem)
repeat kfree check forpeer_randomandpeer_hmacs(xin)
v2->v3net->sctp
also freepeer_chunks
v3->v4
fix subject tagsSigned-off-by Neil Horman <[email protected]>Reported-by [email protected]CC Marcelo Ricardo Leitner <[email protected]>CC Xin Long <[email protected]>CC "David S. Miller" <[email protected]>--- net/sctp/sm_make_chunk.c | 8 ++++++++ 1 file changed, 8 insertions(+)net/sctp/sm_make_chunk.c +8
-1@@ -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 ;@@ -2647,6 +2649,8 @@ static int sctp_process_param(struct sctp_association *asoc, goto fall_through;/* Save peer's random parameter */ +if (asoc->peer.peer_random) +kfree (asoc->peer.peer_random); asoc->peer.peer_random =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_random) {@@ -2660,6 +2664,8 @@ static int sctp_process_param(struct sctp_association *asoc, goto fall_through;/* Save peer's HMAC list */ +if (asoc->peer.peer_hmacs) +kfree (asoc->peer.peer_hmacs); asoc->peer.peer_hmacs =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_hmacs) {@@ -2675,6 +2681,8 @@ static int sctp_process_param(struct sctp_association *asoc,if (!ep->auth_enable) goto fall_through; +if (asoc->peer.peer_chunks) +kfree (asoc->peer.peer_chunks); asoc->peer.peer_chunks =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_chunks) --
Quoted 2 lines
2.20.1
Re: [PATCH v4 net] sctp: Free cookie before we memdup a new one
In reply to Neil HormanQuoted 8 lines · Neil Horman
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.
---
This marker can't be here, as it causes git to loose everything below.
Quoted 12 lines
Change notes
v1->v2
update subsystem tag in subject (davem)
repeat kfree check forpeer_randomandpeer_hmacs(xin)
v2->v3net->sctp
also freepeer_chunks
v3->v4
fix subject tags
Quoted 6 lines
Signed-off-by Neil Horman <[email protected]>Reported-by [email protected]CC Marcelo Ricardo Leitner <[email protected]>CC Xin Long <[email protected]>CC "David S. Miller" <[email protected]>
Anyhow, LGTM and reproducer didn't give any hits in 2 runs of 50mins.
Re: [PATCH v4 net] sctp: Free cookie before we memdup a new one
Quoted 5 lines · Marcelo Ricardo Leitner
Quoted 4 lines · Neil Horman
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.
Quoted 7 lines
Quoted 4 lines
To ensure that we don't leak cookie memory, free any previously allocated cookie first.
---
This marker can't be here, as it causes git to loose everything below.
thats intentional so that, when Dave commits it, the change notes arent carried into the changelog (I.e. the change notes are useful for email review, but not especially useful in the permanent commit history).
Neil
Quoted 22 lines
Quoted 12 lines
Change notes
v1->v2
update subsystem tag in subject (davem)
repeat kfree check forpeer_randomandpeer_hmacs(xin)
v2->v3net->sctp
also freepeer_chunks
v3->v4
fix subject tagsQuoted 6 lines
Signed-off-by Neil Horman <[email protected]>Reported-by [email protected]CC Marcelo Ricardo Leitner <[email protected]>CC Xin Long <[email protected]>CC "David S. Miller" <[email protected]>Anyhow, LGTM and reproducer didn't give any hits in 2 runs of 50mins.
David Miller
maintainerRe: [PATCH v4 net] sctp: Free cookie before we memdup a new one
From: Neil Horman <[email protected]>
Date: Wed, 12 Jun 2019 16:32:30 -0400
Quoted 9 lines · Marcelo Ricardo Leitner
Quoted 8 lines · Neil Horman
Quoted 7 lines
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.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
---
This marker can't be here, as it causes git to loose everything below.
thats intentional so that, when Dave commits it, the change notes arent carried into the changelog (I.e. the change notes are useful for email review, but not especially useful in the permanent commit history).
1) I like the changelog notes to be included
2) Your signoff etc. was in that area too so would have been lost as well
PATCH v5 1/1 sctp: Free cookie before we memdup a new one
In reply to Neil HormanBased 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.
Change notesv1->v2
update subsystem tag in subject (davem)
repeat kfree check for peer_random and peer_hmacs (xin)
v2->v3net->sctp
also free peer_chunks
v3->v4
fix subject tags
v4->v5
remove cut line
--- net/sctp/sm_make_chunk.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/sctp/sm_make_chunk.c +8 -0
@@ -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 ;
@@ -2647,6 +2649,8 @@ static int sctp_process_param(struct sctp_association *asoc, goto fall_through;/* Save peer's random parameter */ +if (asoc->peer.peer_random) +kfree (asoc->peer.peer_random); asoc->peer.peer_random =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_random) {
@@ -2660,6 +2664,8 @@ static int sctp_process_param(struct sctp_association *asoc, goto fall_through;/* Save peer's HMAC list */ +if (asoc->peer.peer_hmacs) +kfree (asoc->peer.peer_hmacs); asoc->peer.peer_hmacs =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_hmacs) {
@@ -2675,6 +2681,8 @@ static int sctp_process_param(struct sctp_association *asoc,if (!ep->auth_enable) goto fall_through; +if (asoc->peer.peer_chunks) +kfree (asoc->peer.peer_chunks); asoc->peer.peer_chunks =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_chunks)
Signature · 1 line
2.20.1
Re: [PATCH v5 net] sctp: Free cookie before we memdup a new one
Quoted 22 lines · Neil Horman
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.
Change notes
v1->v2
update subsystem tag in subject (davem)
repeat kfree check forpeer_randomandpeer_hmacs(xin)
v2->v3net->sctp
also freepeer_chunks
v3->v4
fix subject tags
v4->v5
remove cut line
Quoted 6 lines
Signed-off-by Neil Horman <[email protected]>Reported-by [email protected]CC Marcelo Ricardo Leitner <[email protected]>CC Xin Long <[email protected]>CC "David S. Miller" <[email protected]>
Quoted 46 lines
--- net/sctp/sm_make_chunk.c | 8 ++++++++ 1 file changed, 8 insertions(+)net/sctp/sm_make_chunk.c +8
-0@@ -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 ;@@ -2647,6 +2649,8 @@ static int sctp_process_param(struct sctp_association *asoc, goto fall_through;/* Save peer's random parameter */ +if (asoc->peer.peer_random) +kfree (asoc->peer.peer_random); asoc->peer.peer_random =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_random) {@@ -2660,6 +2664,8 @@ static int sctp_process_param(struct sctp_association *asoc, goto fall_through;/* Save peer's HMAC list */ +if (asoc->peer.peer_hmacs) +kfree (asoc->peer.peer_hmacs); asoc->peer.peer_hmacs =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_hmacs) {@@ -2675,6 +2681,8 @@ static int sctp_process_param(struct sctp_association *asoc,if (!ep->auth_enable) goto fall_through; +if (asoc->peer.peer_chunks) +kfree (asoc->peer.peer_chunks); asoc->peer.peer_chunks =kmemdup (param.p,ntohs (param.p->length), gfp);if (!asoc->peer.peer_chunks)Signature · 1 line
2.20.1
Re: [PATCH v5 net] sctp: Free cookie before we memdup a new one
In reply to Neil HormanFrom: Neil Horman <[email protected]>
Date: Thu, 13 Jun 2019 06:35:59 -0400
Quoted 16 lines
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.
Change notes
v1->v2
update subsystem tag in subject (davem)
repeat kfree check forpeer_randomandpeer_hmacs(xin)
v2->v3net->sctp
also freepeer_chunks
Quoted 8 lines
v3->v4
fix subject tags
v4->v5
remove cut lineSigned-off-by Neil Horman <[email protected]>Reported-by [email protected]
Applied, thanks.