Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752836AbdFSSfH (ORCPT + 2 others); Mon, 19 Jun 2017 14:35:07 -0400 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:52015 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752800AbdFSSfE (ORCPT ); Mon, 19 Jun 2017 14:35:04 -0400 From: Willy Tarreau To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux@roeck-us.net Cc: Xin Long , "David S . Miller" , Willy Tarreau Subject: [PATCH 3.10 254/268] sctp: listen on the sock only when it's state is listening or closed Date: Mon, 19 Jun 2017 20:32:33 +0200 Message-Id: <1497897167-14556-255-git-send-email-w@1wt.eu> X-Mailer: git-send-email 2.8.0.rc2.1.gbe9624a In-Reply-To: <1497897167-14556-1-git-send-email-w@1wt.eu> References: <1497897167-14556-1-git-send-email-w@1wt.eu> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Xin Long commit 34b2789f1d9bf8dcca9b5cb553d076ca2cd898ee upstream. Now sctp doesn't check sock's state before listening on it. It could even cause changing a sock with any state to become a listening sock when doing sctp_listen. This patch is to fix it by checking sock's state in sctp_listen, so that it will listen on the sock with right state. Reported-by: Andrey Konovalov Tested-by: Andrey Konovalov Signed-off-by: Xin Long Acked-by: Marcelo Ricardo Leitner Signed-off-by: David S. Miller Signed-off-by: Willy Tarreau --- net/sctp/socket.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 4178cf3..4358ae8 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -6181,6 +6181,9 @@ int sctp_inet_listen(struct socket *sock, int backlog) if (sock->state != SS_UNCONNECTED) goto out; + if (!sctp_sstate(sk, LISTENING) && !sctp_sstate(sk, CLOSED)) + goto out; + /* If backlog is zero, disable listening. */ if (!backlog) { if (sctp_sstate(sk, CLOSED)) -- 2.8.0.rc2.1.gbe9624a