From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1532C64EC4 for ; Fri, 10 Mar 2023 13:54:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229779AbjCJNyC (ORCPT ); Fri, 10 Mar 2023 08:54:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231193AbjCJNx5 (ORCPT ); Fri, 10 Mar 2023 08:53:57 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C1DDE7EC7 for ; Fri, 10 Mar 2023 05:53:44 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C0F7961771 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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);