linux-sctp.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrei Pelinescu-Onciul <andrei@iptel.org>
To: linux-sctp@vger.kernel.org
Subject: [PATCH 1/3] sctp: fix autoclose timer race
Date: Thu, 12 Nov 2009 15:48:47 +0000	[thread overview]
Message-ID: <20091112154847.GN10897@shell.iptel.org> (raw)

For very small autoclose timeouts (e.g. 0 or close to 0 due to
overflows) it's possible that the timer is executed immediately
after is set, before there is a chance to increase the association
reference counter. To avoid this race, always reference the
association before calling mod_timer() and dereference it back if
the timer was already active.

Signed-off-by: Andrei Pelinescu-Onciul <andrei@iptel.org>
---
 net/sctp/output.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/sctp/output.c b/net/sctp/output.c
index b94c211..8c39bd2 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -586,8 +586,9 @@ int sctp_packet_transmit(struct sctp_packet *packet)
 			timer = &asoc->timers[SCTP_EVENT_TIMEOUT_AUTOCLOSE];
 			timeout = asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE];
 
-			if (!mod_timer(timer, jiffies + timeout))
-				sctp_association_hold(asoc);
+			sctp_association_hold(asoc);
+			if (mod_timer(timer, jiffies + timeout))
+				sctp_association_put(asoc); /* already active, deref */
 		}
 	}
 
-- 
1.6.5.2


                 reply	other threads:[~2009-11-12 15:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20091112154847.GN10897@shell.iptel.org \
    --to=andrei@iptel.org \
    --cc=linux-sctp@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;
as well as URLs for NNTP newsgroup(s).