Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp577228iog; Mon, 13 Jun 2022 08:27:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTps1FDCs23r5yxuhJtPIDbHDB/gTX5QFegwSHsvKrsnXTGTgRtiWFGW9rWS7UV9UGFQUU X-Received: by 2002:a63:488:0:b0:3fc:d244:2cde with SMTP id 130-20020a630488000000b003fcd2442cdemr157474pge.426.1655134073799; Mon, 13 Jun 2022 08:27:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655134073; cv=none; d=google.com; s=arc-20160816; b=fNZtKoPIPYS9SKnt73WuMmcI75R5mHnGeIuZd0vgwblVpRAcNhtSueBXsm/q+0cr5M vRqD2Bw8/f0kEAE2HelDNcqHoTppClNbtcqlxtM+Q+eGWsgbkuncBTZRO1JDyDEwp+JM OJ1r2jTrw7p+moWFIcQRYaXvaCwPHlLfl3H0A6VrzRo3mw0K6nFZ1Z6tB0qU1dCI0ap7 idzW8bXB0Jl/tAqa3Zf1hHb+yiOokUucZ0d9Rg+HY7hof5ISN3mhQfUWdP4rftPJhoQe z7Lwe32rjSpYgnxU//Di9jj3Hd7MHXk35vGDczyex7HOJE8ElpaxlU+LZWV8GBGu44m1 hxZg== 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=CbQm4gOmBx8M+B0uohSllXoz2praDUEZG2rACzYapa4=; b=XMfmZPMcqaRPssejdnPJL6vslASl4v+J9v25MNPRI8pncSGbphAVtiSDykMKkhX6ZK Hw1mJb4TqoG7Bw/iIpWwk0HJsmzt1NO/5jPJGy+HYjqbqALjUIi1XKDRoBby3hhV6L07 3yNWMTt15Xbr8l6Bz1H0TtVPLl32J7Ocr4d2w+kkXFlFZwXHUNDWn+v+TD13oJL/JUnp HCCi1IWZ5cjOQfM1Kc1Mx+GhizD57K5pOKgWZQXRMO7nbs58DHfoITGJfs5LMVOc++mA 4f3zh0etSCB5GG+Xl73mmSkkRe/ReF7ABf/2udDpWqO/dgMsXJ7b70TuJeRUACiSPa9B x+Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="oM/4zx8Q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e13-20020a056a001a8d00b005108171fe28si10386082pfv.162.2022.06.13.08.27.41; Mon, 13 Jun 2022 08:27:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="oM/4zx8Q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353330AbiFMLXa (ORCPT + 99 others); Mon, 13 Jun 2022 07:23:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353663AbiFMLQK (ORCPT ); Mon, 13 Jun 2022 07:16:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F84838BDA; Mon, 13 Jun 2022 03:38:50 -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 C035BB80EAC; Mon, 13 Jun 2022 10:38:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F280C34114; Mon, 13 Jun 2022 10:38:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116727; bh=nKTfZeuLrKxdwEf0gmHdzEbNZIZRCIXzPoBOQmXgezQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oM/4zx8QCZMSmjpnsChN2JxW+JSb6AKW5jhzwZLAuL4hbJgfMTo/usiQ7i/efkiHi hC5gnbFDiN5VBECGWvf2DXnSRJoShFLKobrg+hNm0AeJdIwo7etfNKyGqsg1DUiXjD wJOX3jTjPdGruODPcYH2m3hTfDz5RlBkLsWrb1xg= 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.4 155/411] net/smc: postpone sk_refcnt increment in connect() Date: Mon, 13 Jun 2022 12:07:08 +0200 Message-Id: <20220613094933.311476944@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@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=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 a5a8cca46bd5..394491692a07 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -877,9 +877,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 (schedule_work(&smc->connect_work)) smc->connect_nonblock = 1; -- 2.35.1