From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:58118 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752338AbcKRKhe (ORCPT ); Fri, 18 Nov 2016 05:37:34 -0500 Subject: Patch "sctp: change sk state only when it has assocs in sctp_shutdown" has been added to the 4.8-stable tree To: lucien.xin@gmail.com, andreyknvl@google.com, davem@davemloft.net, gregkh@linuxfoundation.org, marcelo.leitner@gmail.com, nhorman@tuxdriver.com Cc: , From: Date: Fri, 18 Nov 2016 11:37:11 +0100 Message-ID: <1479465431178140@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: 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 know about it. >>From foo@baz Fri Nov 18 11:35:46 CET 2016 From: Xin Long 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 [ 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. Fixes: d46e416c11c8 ("sctp: sctp should change socket state when shutdown is received") Reported-by: Andrey Konovalov Tested-by: Andrey Konovalov Signed-off-by: Xin Long Acked-by: Marcelo Ricardo Leitner Acked-by: Neil Horman Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sctp/socket.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -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 lucien.xin@gmail.com 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