Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2199089iof; Tue, 7 Jun 2022 23:00:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbgJ8J18jTo5OS6ojSUQAjJk67vAIlEEOQB1pOvlDxYXL9jkYcqlTUC2h8FOvPVchXoBUm X-Received: by 2002:a17:90b:4f88:b0:1e8:4013:e5f5 with SMTP id qe8-20020a17090b4f8800b001e84013e5f5mr26655799pjb.220.1654668000194; Tue, 07 Jun 2022 23:00:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654668000; cv=none; d=google.com; s=arc-20160816; b=OYCbEDL+FPWExKEXaAoZkpcO4GpRu3NikI+jeBLNDwoie0FAKJkKtuzUu4db7xkYrb 2kxGDWeET7HCJUsQrgmIb4x/GIncB+meumsdloHtRqkSScNY8exFpH0Mj9ia/dGQFlSL TAfUOexbCjedmL8jOdZaLa04rE4G5riXqREl0VgZeUH0woDKsCkPThcC/O//rw+GSvFC ajmyVn8hK26zQ2kuIkpm1C60HO0Jc+6waaL+G3cpO3KbUt9x9pay+tMv996khcxbuN52 yQbybKqGPd0r8yMWSks3Z7NDCf1Ef+HD4LApDffA7AYZYb5a7+4k+pPktf5b7GU5acKn mjDQ== 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=b8IaCco5x8a7wX5ZWcKvkW1cCE4ZfyTWdsz0sUNoZbc=; b=C39y/xJpfgQMrlSY85qdcmDex8sbyAZ5kSd9cTnIHl2yA4+eYuhEfuJ8ZQNniWjRgK S2n/xjXEWCxUFor7YkrVdIftmiEltjRtVSPhuz8z/9XI5319Kw/naokx/wGWhoXtxks7 scuFLjVkWaNCM5lBrgsXYtK2+tX2MB2pAVbQQthnmsy0JVCc79Xtzt1CMHCYaP/InrBC Le+IEclI+12CsshUrs1o6rfVoDn+QHLS95o/+dzC7OYvyymsfsOBql6Gii26fSH8nnVP PC0MfkhNr6gf5CM0t+ltsUjvs+ESMbLYUeqvYDwxHBNt1sMfIqlxM/i80FIWAnAPF+4h xAHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QXVu2wUI; 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 p11-20020a170902a40b00b0015826677457si25630871plq.354.2022.06.07.22.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:00:00 -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=QXVu2wUI; 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 478E54B92B0; Tue, 7 Jun 2022 22:25:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344409AbiFHBJN (ORCPT + 99 others); Tue, 7 Jun 2022 21:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382820AbiFGVv6 (ORCPT ); Tue, 7 Jun 2022 17:51:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2202223EFA1; Tue, 7 Jun 2022 12:09:45 -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 dfw.source.kernel.org (Postfix) with ESMTPS id B1C77617D0; Tue, 7 Jun 2022 19:09:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9805C385A2; Tue, 7 Jun 2022 19:09:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628984; bh=DnFAkqsw38ueMjMLEGksplQdPl/DtdAFVCmpTN10CRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QXVu2wUIPZwk/bAFcysM9qaXxv/evR1FIxOt6+dna//KqEqyoECuWu+HODiutgssr bbaCcFJMV062UIlnYFPwXsshrxEqZ1U/VfYaOShGzHkMYgZf4z89Rq+tM9xpn3FE1A 2xfOzKma9G5noi+WTjC4HMbcHfJ0QUWvxtO/VIdY= 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.18 527/879] net/smc: postpone sk_refcnt increment in connect() Date: Tue, 7 Jun 2022 19:00:45 +0200 Message-Id: <20220607165018.171731326@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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 fce16b9d6e1a..45a24d24210f 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -1564,9 +1564,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