From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69280847E for ; Fri, 10 Mar 2023 13:53:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB0EEC433EF; Fri, 10 Mar 2023 13:53:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678456423; bh=GI6BGBr45Px0kVaMQOsvuH6bA9ow98rDMmVptW52C9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uiy5DEno/32mMyZJuAn8i/aVZ+xnYagTfZnYAGb6TVTSZuzf80HMmaK8mqzZBURPn uTxTk7j61qvhr19YrP4cX2brw07eeTRJPhYcL6EKvb7IsWV+/4tx288yGmx/HevkLE ra0DzVDEcP9SyNPvkvh7Dz9cIwTfy5eTeF6yOkCw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Winter , Kuniyuki Iwashima Subject: [PATCH 4.14 192/193] tcp: Fix listen() regression in 4.14.303. Date: Fri, 10 Mar 2023 14:39:34 +0100 Message-Id: <20230310133717.445624759@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310133710.926811681@linuxfoundation.org> References: <20230310133710.926811681@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Kuniyuki Iwashima commit fdaf88531cfd17b2a710cceb3141ef6f9085ff40 upstream. When we backport dadd0dcaa67d ("net/ulp: prevent ULP without clone op from entering the LISTEN status"), we have accidentally backported a part of 7a7160edf1bf ("net: Return errno in sk->sk_prot->get_port().") and removed err = -EADDRINUSE in inet_csk_listen_start(). Thus, listen() no longer returns -EADDRINUSE even if ->get_port() failed as reported in [0]. We set -EADDRINUSE to err just before ->get_port() to fix the regression. [0]: https://lore.kernel.org/stable/EF8A45D0-768A-4CD5-9A8A-0FA6E610ABF7@winter.cafe/ Reported-by: Winter Signed-off-by: Kuniyuki Iwashima Signed-off-by: Greg Kroah-Hartman --- net/ipv4/inet_connection_sock.c | 1 + 1 file changed, 1 insertion(+) --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -925,6 +925,7 @@ int inet_csk_listen_start(struct sock *s * It is OK, because this socket enters to hash table only * after validation is complete. */ + err = -EADDRINUSE; sk_state_store(sk, TCP_LISTEN); if (!sk->sk_prot->get_port(sk, inet->inet_num)) { inet->inet_sport = htons(inet->inet_num);