netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* SCTP: Fix dead loop while received unexpected chunk with length set to zero
@ 2007-08-27  1:06 Wei Yongjun
       [not found] ` <46D44630.8070802@hp.com>
  0 siblings, 1 reply; 9+ messages in thread
From: Wei Yongjun @ 2007-08-27  1:06 UTC (permalink / raw)
  To: lksctp-developers, netdev, Vlad Yasevich

A ootb chunk such as data in close state or init-ack in estab state will 
cause SCTP to enter dead loop. Look like this:

(1)
  Endpoint A                      Endpoint B
  (Closed)                        (Closed)

  DATA      ----------------->   Kernel dead loop
  (With Length set to zero)

(2)
  Endpoint A                      Endpoint B
  (Established)                   (Established)

  INIT-ACK   ----------------->   Kernel dead loop
  (With Length set to zero)


This is beacuse when process chunks, chunk->chunk_end is set to the 
chunk->chunk_hdr plus chunk length, if chunk length is set to zero, 
chunk->chunk_end will be never changed and process enter dead loop.
Following is the patch.

Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>

--- a/net/sctp/inqueue.c	2007-08-25 10:53:45.000000000 -0400
+++ b/net/sctp/inqueue.c	2007-08-26 05:45:57.000000000 -0400
@@ -165,10 +165,8 @@ struct sctp_chunk *sctp_inq_pop(struct s
 	skb_pull(chunk->skb, sizeof(sctp_chunkhdr_t));
 	chunk->subh.v = NULL; /* Subheader is no longer valid.  */
 
-	if (chunk->chunk_end < skb_tail_pointer(chunk->skb)) {
-		/* This is not a singleton */
-		chunk->singleton = 0;
-	} else if (chunk->chunk_end > skb_tail_pointer(chunk->skb)) {
+	if (chunk->chunk_end > skb_tail_pointer(chunk->skb) ||
+	    chunk->chunk_end == chunk->chunk_hdr) {
 		/* RFC 2960, Section 6.10  Bundling
 		 *
 		 * Partial chunks MUST NOT be placed in an SCTP packet.
@@ -183,6 +181,9 @@ struct sctp_chunk *sctp_inq_pop(struct s
 		chunk = queue->in_progress = NULL;
 
 		return NULL;
+	} else if (chunk->chunk_end < skb_tail_pointer(chunk->skb)) {
+		/* This is not a singleton */
+		chunk->singleton = 0;
 	} else {
 		/* We are at the end of the packet, so mark the chunk
 		 * in case we need to send a SACK.



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

end of thread, other threads:[~2007-09-05 21:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-27  1:06 SCTP: Fix dead loop while received unexpected chunk with length set to zero Wei Yongjun
     [not found] ` <46D44630.8070802@hp.com>
2007-08-29  7:26   ` [Lksctp-developers] " Wei Yongjun
2007-08-29 15:26     ` Vlad Yasevich
2007-08-30  5:42       ` Wei Yongjun
2007-08-30 13:45         ` Vlad Yasevich
2007-08-31  2:38           ` Wei Yongjun
2007-08-31  5:17           ` David Miller
2007-08-31 10:21           ` Wei Yongjun
2007-09-05 20:57             ` Vlad Yasevich

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