Skip to contentSkip to conversation

Patch "sctp: change sk state only when it has assocs in sctp_shutdown" has been added to the 4.8-stable tree

PATCH [email protected] 1 participant 1 message Nov 18, 2016

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

sctp: change sk state only when it has assocs in sctp_shutdown

to the 4.8-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
sctp-change-sk-state-only-when-it-has-assocs-in-sctp_shutdown.patch
and it can be found in the queue-4.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Fri Nov 18 11:35:46 CET 2016

From: Xin Long <[email protected]>
Date: Sun, 13 Nov 2016 21:44:37 +0800
Subject: sctp: change sk state only when it has assocs in sctp_shutdown

From: Xin Long <[email protected]>

[ Upstream commit 5bf35ddfee052d44f39ebaa395d87101c8918405 ]

Now when users shutdown a sock with SEND_SHUTDOWN in sctp, even if this sock has no connection (assoc), sk state would be changed to SCTP_SS_CLOSING, which is not as we expect.

Besides, after that if users try to listen on this sock, kernel could even panic when it dereference sctp_sk(sk)->bind_hash in sctp_inet_listen, as bind_hash is null when sock has no assoc.

This patch is to move sk state change after checking sk assocs is not empty, and also merge these two if() conditions and reduce indent level.

---
 net/sctp/socket.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
net/sctp/socket.c +7 -8
@@ -4281,19 +4281,18 @@ static void sctp_shutdown(struct sock *s
 {
 	struct net *net = sock_net(sk);
 	struct sctp_endpoint *ep;
-	struct sctp_association *asoc;
 
 	if (!sctp_style(sk, TCP))
 		return;
 
-	if (how & SEND_SHUTDOWN) {
+	ep = sctp_sk(sk)->ep;
+	if (how & SEND_SHUTDOWN && !list_empty(&ep->asocs)) {
+		struct sctp_association *asoc;
+
 		sk->sk_state = SCTP_SS_CLOSING;
-		ep = sctp_sk(sk)->ep;
-		if (!list_empty(&ep->asocs)) {
-			asoc = list_entry(ep->asocs.next,
-					  struct sctp_association, asocs);
-			sctp_primitive_SHUTDOWN(net, asoc, NULL);
-		}
+		asoc = list_entry(ep->asocs.next,
+				  struct sctp_association, asocs);
+		sctp_primitive_SHUTDOWN(net, asoc, NULL);
 	}
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.8/sctp-assign-assoc_id-earlier-in-__sctp_connect.patch queue-4.8/sctp-change-sk-state-only-when-it-has-assocs-in-sctp_shutdown.patch