Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2180595iof; Tue, 7 Jun 2022 22:22:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySvWWr/QFcNdnfzWHAuC4I6hedXGKZDlkZNUfaWIhgU4AKxw5HKPXpxDxCLVOTwQLfH5Lq X-Received: by 2002:a63:2:0:b0:3f6:5b37:e94c with SMTP id 2-20020a630002000000b003f65b37e94cmr28597202pga.356.1654665762525; Tue, 07 Jun 2022 22:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654665762; cv=none; d=google.com; s=arc-20160816; b=g0qL84SZ9dRV9q9QwSRKYOrQPuGFqIBXHu4TDtdXcUJdRo3pj3r8lF4BTG/CTLPgZi W0Dk7xnJXrd8Zuy0CRp9AIMiyNFNtcWIAmBdIGcvD21/3opyd/1+GTgOCgVdt/aKfMVo hpEpRAEhzysc2JrYj3a9ngulXeObA/ftpeXwYmwHeeTl0gA04JB+WsPcpEWHDBXf+TNR MY1ZFvwGsPWjdDlrImoILjm+6iqD7Ri59oiXLoJR/8I+boxAX7MX+cUtGFiMSoyoYF/Z yTOi3MxJxsSlTb3YH/EQvmIWaiL+42C05B/4Vu8QIkbrX2PQu0u/vGO39D9lrP/udrO4 h0EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Wml2XTyqU9k+S7ajPwkjduFfQZl2sfN5cnywoAkT8oo=; b=jJL8FOW1tvFDOa7u9VOuKp3FJmSbNp3/lYO5GCt+kLNuiVd98jn6rUju2/8ajzkzVB 0hxP4UetxXnrxtq6KYZ5GnK6bJlUznqTCQEqWaJzCSa7RJccUk6IB26kMHbtqFO4ONGb Ociwk2jPdprcm/SDyyfmz6LLh6/aAqGK5jV7hCyQl1Z/l5WmdskQ1xPRWvbbkqkzEkrc Ox3OoW3piScd6evYejrFP3SxVoa9EZchCHK6la1WSwXMPUN1VeiUHrK75PHFpkQ35QHD BNtdrGuTmkyQgx2EWf0Yf902mWQ4XWK4tUhmtAFcYHCql9wXJsGVCoKgWD4lH3ZYQLtK nulQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZZMYXYWt; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l5-20020a17090270c500b0015d1dbd6abasi23383892plt.237.2022.06.07.22.22.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:22:42 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZZMYXYWt; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0F855302217; Tue, 7 Jun 2022 21:50:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235048AbiFGRsv (ORCPT + 99 others); Tue, 7 Jun 2022 13:48:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348329AbiFGRbq (ORCPT ); Tue, 7 Jun 2022 13:31:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB50E11803A; Tue, 7 Jun 2022 10:29:54 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id CEF4AB82285; Tue, 7 Jun 2022 17:29:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31679C385A5; Tue, 7 Jun 2022 17:29:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654622991; bh=b++NisNEOYAJekWC1SOtCV27oqLTWJV7laUnxid2riI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZZMYXYWtIjovskPA5qlxn7HH24XFnbcBJlyXTr8z6xB/fCIPFJb0LIvUJeqRC/4vZ HefzYFC6pzCm6sHntxCOio1ph9P4BOEDfEzQo3nz60ffqDPXnmLXYTVFgT/j0mglCw UDhGGWvnIdrJ9o6Lm/wiaXePHU/BAoFMqwufABo4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, liuyacan , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 257/452] net/smc: postpone sk_refcnt increment in connect() Date: Tue, 7 Jun 2022 19:01:54 +0200 Message-Id: <20220607164916.215711033@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: liuyacan [ Upstream commit 75c1edf23b95a9c66923d9269d8e86e4dbde151f ] Same trigger condition as commit 86434744. When setsockopt runs in parallel to a connect(), and switch the socket into fallback mode. Then the sk_refcnt is incremented in smc_connect(), but its state stay in SMC_INIT (NOT SMC_ACTIVE). This cause the corresponding sk_refcnt decrement in __smc_release() will not be performed. Fixes: 86434744fedf ("net/smc: add fallback check to connect()") Signed-off-by: liuyacan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/smc/af_smc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 35db3260e8d5..5d7710dd9514 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -1118,9 +1118,9 @@ static int smc_connect(struct socket *sock, struct sockaddr *addr, if (rc && rc != -EINPROGRESS) goto out; - sock_hold(&smc->sk); /* sock put in passive closing */ if (smc->use_fallback) goto out; + sock_hold(&smc->sk); /* sock put in passive closing */ if (flags & O_NONBLOCK) { if (queue_work(smc_hs_wq, &smc->connect_work)) smc->connect_nonblock = 1; -- 2.35.1