Skip to contentSkip to conversation

sctp: fix oops when update assoc retran

PATCH In review Wei Yongjun 3 participants 4 messages May 11, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sctp: fix oops when update assoc retran

commit fbdf501c9374966a56829ecca3a7f25d2b49a305
sctp: Do no select unconfirmed transports for retransmissions

added code to make sure that we do not select unconfirmed paths for data transmission. This caused a problem when there are only 2 paths, 1 unconfirmed and 1 unreachable. In that case, the next retransmit path returned is NULL and that causes a kernel crash.

commit d598b166ced20d9b9281ea3527c0e18405ddb803
sctp: Make sure we always return valid retransmit path
try to fix it, but if DEBUG is configured, the oops is still exists.

---
 net/sctp/associola.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
net/sctp/associola.c +8 -7
index 3912420..1f49af5 100644
@@ -1323,15 +1323,16 @@ void sctp_assoc_update_retran_path(struct sctp_association *asoc)
 		}
 	}
 
-	if (t)
+	if (t) {
 		asoc->peer.retran_path = t;
 
-	SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_update_retran_path:association"
-				 " %p addr: ",
-				 " port: %d\n",
-				 asoc,
-				 (&t->ipaddr),
-				 ntohs(t->ipaddr.v4.sin_port));
+		SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_update_retran_path:"
+					 "association %p addr: ",
+					 " port: %d\n",
+					 asoc,
+					 (&t->ipaddr),
+					 ntohs(t->ipaddr.v4.sin_port));
+	}
 }
 
 /* Choose the transport for sending retransmit packet.  */
Signature · 1 line
1.6.5.2
Tested-by on v1 1/1
#1 lore raw

Wei Yongjun wrote, at 05/11/2010 02:43 PM:

Quoted 27 lines

commit fbdf501c9374966a56829ecca3a7f25d2b49a305
sctp: Do no select unconfirmed transports for retransmissions

added code to make sure that we do not select unconfirmed paths for data transmission. This caused a problem when there are only 2 paths, 1 unconfirmed and 1 unreachable. In that case, the next retransmit path returned is NULL and that causes a kernel crash.

commit d598b166ced20d9b9281ea3527c0e18405ddb803
sctp: Make sure we always return valid retransmit path
try to fix it, but if DEBUG is configured, the oops is still exists.

---
 net/sctp/associola.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
net/sctp/associola.c +0 -1
index 3912420..1f49af5 100644
@@ -1323,15 +1323,16 @@ void sctp_assoc_update_retran_path(struct sctp_association *asoc)
 		}
 	}
 
-	if (t)

net/sctp/associola.c void sctp_assoc_update_retran_path(struct sctp_association *asoc) · line 1329

Quoted 10 lines
net/sctp/associola.c +2 -6
+	if (t) {
 		asoc->peer.retran_path = t;
 
-	SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_update_retran_path:association"
-				 " %p addr: ",
-				 " port: %d\n",
-				 asoc,
-				 (&t->ipaddr),
-				 ntohs(t->ipaddr.v4.sin_port));
+		SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_update_retran_path:"

Try __func__ to simplify code.

net/sctp/associola.c void sctp_assoc_update_retran_path(struct sctp_association *asoc) · line 1335

Quoted 6 lines
net/sctp/associola.c +6 -0
+					 "association %p addr: ",
+					 " port: %d\n",
+					 asoc,
+					 (&t->ipaddr),
+					 ntohs(t->ipaddr.v4.sin_port));
+	}

How about providing debug infos if t is NULL?
something like "failed to update retran path", or "no change to retran path".

Signature · 3 lines
Best Regards
-----
Shan Wei
Quoted 3 lines
net/sctp/associola.c +0 -0
 }
 
 /* Choose the transport for sending retransmit packet.  */
#2 lore raw
In reply to Wei Yongjun
Quoted 51 lines · Shan Wei

Wei Yongjun wrote, at 05/11/2010 02:43 PM:

Quoted 27 lines

commit fbdf501c9374966a56829ecca3a7f25d2b49a305
sctp: Do no select unconfirmed transports for retransmissions

added code to make sure that we do not select unconfirmed paths for data transmission. This caused a problem when there are only 2 paths, 1 unconfirmed and 1 unreachable. In that case, the next retransmit path returned is NULL and that causes a kernel crash.

commit d598b166ced20d9b9281ea3527c0e18405ddb803
sctp: Make sure we always return valid retransmit path
try to fix it, but if DEBUG is configured, the oops is still exists.

---
 net/sctp/associola.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
net/sctp/associola.c +0 -1
index 3912420..1f49af5 100644
@@ -1323,15 +1323,16 @@ void sctp_assoc_update_retran_path(struct sctp_association *asoc)
 		}
 	}
 
-	if (t)

net/sctp/associola.c void sctp_assoc_update_retran_path(struct sctp_association *asoc) · line 1329

Quoted 10 lines
net/sctp/associola.c +2 -6
+	if (t) {
 		asoc->peer.retran_path = t;
 
-	SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_update_retran_path:association"
-				 " %p addr: ",
-				 " port: %d\n",
-				 asoc,
-				 (&t->ipaddr),
-				 ntohs(t->ipaddr.v4.sin_port));
+		SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_update_retran_path:"

Try __func__ to simplify code.

net/sctp/associola.c void sctp_assoc_update_retran_path(struct sctp_association *asoc) · line 1335

Quoted 6 lines
net/sctp/associola.c +6 -0
+					 "association %p addr: ",
+					 " port: %d\n",
+					 asoc,
+					 (&t->ipaddr),
+					 ntohs(t->ipaddr.v4.sin_port));
+	}

How about providing debug infos if t is NULL?
something like "failed to update retran path", or "no change to retran path".

Quoted 2 lines

Sorry, I didn't run with debug enabled.... Actually, we should probably just refer back to retran_path so that DEBUG output still shows which path we are retransmitting on.

-vlad

#3 lore raw

Re: [PATCH for net-next-2.6] sctp: fix oops when update assoc retran path

In reply to Wei Yongjun

Here is what I am planning to commit:

sctp: fix oops when updating retransmit path with DEBUG on

commit fbdf501c9374966a56829ecca3a7f25d2b49a305
sctp: Do no select unconfirmed transports for retransmissions

Introduced the initial falt.

commit d598b166ced20d9b9281ea3527c0e18405ddb803
sctp: Make sure we always return valid retransmit path

Solved the problem, but forgot to change the DEBUG statement. Thus it was still possible to dereference a NULL pointer.

---
 net/sctp/associola.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
net/sctp/associola.c +2 -0
index 65f9a7c..1b26878 100644
@@ -1323,6 +1323,8 @@ void sctp_assoc_update_retran_path(struct sctp_association *asoc)
 
 	if (t)
 		asoc->peer.retran_path = t;
+	else
+		t = asoc->peer.retran_path;
 
 	SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_update_retran_path:association"
 				 " %p addr: ",
Signature · 1 line
1.6.0.4