netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sctp: Fix memory leak in sctp_sf_do_5_2_4_dupcook
@ 2019-11-22 22:17 Navid Emamdoost
  2019-11-23 13:01 ` Marcelo Ricardo Leitner
  2019-11-24  2:25 ` Jakub Kicinski
  0 siblings, 2 replies; 3+ messages in thread
From: Navid Emamdoost @ 2019-11-22 22:17 UTC (permalink / raw)
  To: Vlad Yasevich, Neil Horman, Marcelo Ricardo Leitner,
	David S. Miller, linux-sctp, netdev, linux-kernel
  Cc: emamd001, Navid Emamdoost

In the implementation of sctp_sf_do_5_2_4_dupcook() the allocated
new_asoc is leaked if security_sctp_assoc_request() fails. Release it
via sctp_association_free().

Fixes: 2277c7cd75e3 ("sctp: Add LSM hooks")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 net/sctp/sm_statefuns.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 0c21c52fc408..4ab8208a2dd4 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -2160,8 +2160,10 @@ enum sctp_disposition sctp_sf_do_5_2_4_dupcook(
 
 	/* Update socket peer label if first association. */
 	if (security_sctp_assoc_request((struct sctp_endpoint *)ep,
-					chunk->skb))
+					chunk->skb)) {
+		sctp_association_free(new_asoc);
 		return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
+	}
 
 	/* Set temp so that it won't be added into hashtable */
 	new_asoc->temp = 1;
-- 
2.17.1


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

* Re: [PATCH] sctp: Fix memory leak in sctp_sf_do_5_2_4_dupcook
  2019-11-22 22:17 [PATCH] sctp: Fix memory leak in sctp_sf_do_5_2_4_dupcook Navid Emamdoost
@ 2019-11-23 13:01 ` Marcelo Ricardo Leitner
  2019-11-24  2:25 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Marcelo Ricardo Leitner @ 2019-11-23 13:01 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: Vlad Yasevich, Neil Horman, David S. Miller, linux-sctp, netdev,
	linux-kernel, emamd001

On Fri, Nov 22, 2019 at 04:17:56PM -0600, Navid Emamdoost wrote:
> In the implementation of sctp_sf_do_5_2_4_dupcook() the allocated
> new_asoc is leaked if security_sctp_assoc_request() fails. Release it
> via sctp_association_free().
> 
> Fixes: 2277c7cd75e3 ("sctp: Add LSM hooks")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

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

* Re: [PATCH] sctp: Fix memory leak in sctp_sf_do_5_2_4_dupcook
  2019-11-22 22:17 [PATCH] sctp: Fix memory leak in sctp_sf_do_5_2_4_dupcook Navid Emamdoost
  2019-11-23 13:01 ` Marcelo Ricardo Leitner
@ 2019-11-24  2:25 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2019-11-24  2:25 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: Vlad Yasevich, Neil Horman, Marcelo Ricardo Leitner,
	David S. Miller, linux-sctp, netdev, linux-kernel, emamd001

On Fri, 22 Nov 2019 16:17:56 -0600, Navid Emamdoost wrote:
> In the implementation of sctp_sf_do_5_2_4_dupcook() the allocated
> new_asoc is leaked if security_sctp_assoc_request() fails. Release it
> via sctp_association_free().
> 
> Fixes: 2277c7cd75e3 ("sctp: Add LSM hooks")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>

Applied, queued for stable, thanks!

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

end of thread, other threads:[~2019-11-24  2:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-22 22:17 [PATCH] sctp: Fix memory leak in sctp_sf_do_5_2_4_dupcook Navid Emamdoost
2019-11-23 13:01 ` Marcelo Ricardo Leitner
2019-11-24  2:25 ` Jakub Kicinski

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