Netdev List
 help / color / mirror / Atom feed
From: Daniel Borkmann <dborkman@redhat.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-sctp@vger.kernel.org
Subject: [PATCH net] net: sctp: sctp_transport_destroy{,_rcu}: fix potential pointer corruption
Date: Fri,  9 Aug 2013 12:07:29 +0200	[thread overview]
Message-ID: <1376042849-19732-1-git-send-email-dborkman@redhat.com> (raw)

Probably this one is quite unlikely to be triggered, but it's more safe
to hold a pointer to asoc and packet (instead of dereferencing) and access
both though this after we have called sctp_transport_destroy_rcu() where
the transport is being kfree()'d. Introduced by commit 8c98653f ("sctp:
sctp_close: fix release of bindings for deferred call_rcu's").

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
---
 net/sctp/transport.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index bdbbc3f..7142756 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -176,6 +176,9 @@ static void sctp_transport_destroy_rcu(struct rcu_head *head)
  */
 static void sctp_transport_destroy(struct sctp_transport *transport)
 {
+	struct sctp_association *asoc = transport->asoc;
+	struct sctp_packet *packet = &transport->packet;
+
 	if (unlikely(!transport->dead)) {
 		WARN(1, "Attempt to destroy undead transport %p!\n", transport);
 		return;
@@ -183,10 +186,10 @@ static void sctp_transport_destroy(struct sctp_transport *transport)
 
 	call_rcu(&transport->rcu, sctp_transport_destroy_rcu);
 
-	sctp_packet_free(&transport->packet);
+	sctp_packet_free(packet);
 
-	if (transport->asoc)
-		sctp_association_put(transport->asoc);
+	if (asoc != NULL)
+		sctp_association_put(asoc);
 }
 
 /* Start T3_rtx timer if it is not already running and update the heartbeat
-- 
1.7.11.7

             reply	other threads:[~2013-08-09 10:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-09 10:07 Daniel Borkmann [this message]
2013-08-09 10:33 ` [PATCH net] net: sctp: sctp_transport_destroy{,_rcu}: fix potential pointer corruption Daniel Borkmann

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=1376042849-19732-1-git-send-email-dborkman@redhat.com \
    --to=dborkman@redhat.com \
    --cc=davem@davemloft.net \
    --cc=linux-sctp@vger.kernel.org \
    --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