From: Vlad Yasevich <vladislav.yasevich@hp.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, lksctp-developers@lists.sourceforge.net,
Jesper Juhl <jesper.juhl@gmail.com>,
Vlad Yasevich <vladislav.yasevich@hp.com>
Subject: [PATCH 14/14] Fix memory leak in discard case of sctp_sf_abort_violation()
Date: Mon, 12 Nov 2007 11:38:29 -0500 [thread overview]
Message-ID: <11948855193018-git-send-email-vladislav.yasevich@hp.com> (raw)
In-Reply-To: <11948855091808-git-send-email-vladislav.yasevich@hp.com>
From: Jesper Juhl <jesper.juhl@gmail.com>
In net/sctp/sm_statefuns.c::sctp_sf_abort_violation() we may leak
the storage allocated for 'abort' by returning from the function
without using or freeing it. This happens in case
"sctp_auth_recv_cid(SCTP_CID_ABORT, asoc)" is true and we jump to
the 'discard' label.
Spotted by the Coverity checker.
The simple fix is to simply move the creation of the "abort chunk"
to after the possible jump to the 'discard' label. This way we don't
even have to allocate the memory at all in the problem case.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
---
net/sctp/sm_statefuns.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index a66075a..5ebbe80 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -4064,11 +4064,6 @@ static sctp_disposition_t sctp_sf_abort_violation(
struct sctp_chunk *chunk = arg;
struct sctp_chunk *abort = NULL;
- /* Make the abort chunk. */
- abort = sctp_make_abort_violation(asoc, chunk, payload, paylen);
- if (!abort)
- goto nomem;
-
/* SCTP-AUTH, Section 6.3:
* It should be noted that if the receiver wants to tear
* down an association in an authenticated way only, the
@@ -4083,6 +4078,11 @@ static sctp_disposition_t sctp_sf_abort_violation(
if (sctp_auth_recv_cid(SCTP_CID_ABORT, asoc))
goto discard;
+ /* Make the abort chunk. */
+ abort = sctp_make_abort_violation(asoc, chunk, payload, paylen);
+ if (!abort)
+ goto nomem;
+
if (asoc) {
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort));
SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS);
--
1.5.2.4
next prev parent reply other threads:[~2007-11-12 16:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-12 16:38 [GIT PATCHES v2] SCTP bug fixes Vlad Yasevich
2007-11-12 16:38 ` [PATCH 01/14] SCTP : Fix bad formatted comment in outqueue.c Vlad Yasevich
2007-11-12 16:38 ` [PATCH 02/14] SCTP : Fix to process bundled ASCONF chunk correctly Vlad Yasevich
2007-11-12 16:38 ` [PATCH 03/14] SCTP: Fix difference cases of retransmit Vlad Yasevich
2007-11-12 16:38 ` [PATCH 04/14] SCTP: Update RCU handling during the ADD-IP case Vlad Yasevich
2007-11-12 16:38 ` [PATCH 05/14] SCTP: Correctly disable ADD-IP when AUTH is not supported Vlad Yasevich
2007-11-12 16:38 ` [PATCH 06/14] SCTP: Allow ADD_IP to work with AUTH for backward compatibility Vlad Yasevich
2007-11-12 16:38 ` [PATCH 07/14] SCTP: Fix a potential race between timers and receive path Vlad Yasevich
2007-11-12 16:38 ` [PATCH 08/14] SCTP: Use hashed lookup when looking for an association Vlad Yasevich
2007-11-12 16:38 ` [PATCH 09/14] SCTP: Convert custom hash lists to use hlist Vlad Yasevich
2007-11-12 16:38 ` [PATCH 10/14] SCTP: Make sctp_verify_param return multiple indications Vlad Yasevich
2007-11-12 16:38 ` [PATCH 11/14] SCTP: Fix PR-SCTP to deliver all the accumulated ordered chunks Vlad Yasevich
2007-11-12 16:38 ` [PATCH 12/14] SCTP: Clean-up some defines for regressions tests Vlad Yasevich
2007-11-12 16:38 ` [PATCH 13/14] SCTP: Always flush the queue when uncorcking Vlad Yasevich
2007-11-12 16:38 ` Vlad Yasevich [this message]
2007-11-13 5:01 ` [GIT PATCHES v2] SCTP bug fixes David Miller
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=11948855193018-git-send-email-vladislav.yasevich@hp.com \
--to=vladislav.yasevich@hp.com \
--cc=davem@davemloft.net \
--cc=jesper.juhl@gmail.com \
--cc=lksctp-developers@lists.sourceforge.net \
--cc=netdev@vger.kernel.org \
/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