From patchwork Mon May 23 03:24:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liuyacan@corp.netease.com X-Patchwork-Id: 12858421 X-Patchwork-Delegate: kuba@kernel.org 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 02D30C433F5 for ; Mon, 23 May 2022 03:25:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244494AbiEWDY4 (ORCPT ); Sun, 22 May 2022 23:24:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236096AbiEWDYz (ORCPT ); Sun, 22 May 2022 23:24:55 -0400 Received: from corp-front10-corp.i.nease.net (corp-front11-corp.i.nease.net [42.186.62.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7CEC2A72F; Sun, 22 May 2022 20:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corp.netease.com; s=s210401; h=Received:From:To:Cc:Subject: Date:Message-Id:MIME-Version:Content-Transfer-Encoding; bh=F2Ijg PZqOOdRp/fL0Q+UbB5zcPYlxJ9x/Q7Ip6MURLg=; b=cJFolywZ7E1/hbc7Fr5Wz yjE7nZkrlmkDStwm6u8IP5VI9avoizk64tbWkFnn/A6K2QPNWuGEjoSXn01zFEgn PmztcA5APuE1e0SADPNID6Lnl2+mxnpM+CmEV8IeI3FYdmpto7fsNxjO6L1CLsPh SAxvbXT59zSYqHYdd9206s= Received: from pubt1-k8s74.yq.163.org (unknown [115.238.122.38]) by corp-front11-corp.i.nease.net (Coremail) with SMTP id aYG_CgAnP2F3_opiFfsfAA--.3654S2; Mon, 23 May 2022 11:24:39 +0800 (HKT) From: liuyacan@corp.netease.com To: kgraul@linux.ibm.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ubraun@linux.ibm.com, liuyacan Subject: [PATCH net] net/smc: postpone sk_refcnt increment in connect() Date: Mon, 23 May 2022 11:24:37 +0800 Message-Id: <20220523032437.1059718-1-liuyacan@corp.netease.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: aYG_CgAnP2F3_opiFfsfAA--.3654S2 X-Coremail-Antispam: 1UD129KBjvdXoW7XrWxtFWUZw18uF4rWrWruFg_yoWkWrcE9r Z3WFWDCr4jyF4rJ3yxA3yrAa97tw4rGr48Aws8ArWIq3W8WryDurs8Crsxur1Duw45Cr13 Wr4FgFWrC34IyjkaLaAFLSUrUUUU8b8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbMkYjxAI6xCIbckI1I0E57IF64kEYxAxM7AC8VAFwI0_Gr0_Xr1l 1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0I I2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0 Y4vE2Ix0cI8IcVCY1x0267AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7 xvwVC2z280aVCY1x0267AKxVW0oVCq3wAaw2AFwI0_Jrv_JF1ln4vE1TuYJxujqTIEc-sF P3VYkVW5Jr1DJw4UKVWUGwAawVCFI7vE04vSzxk24VAqrcv_Gr1UXr18M2AIxVAIcxkEcV Aq07x20xvEncxIr21l57IF6s8CjcxG0xyl5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r1Y6r17McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxa n2IY04v7M4kE6xkIj40Ew7xC0wCjxxvEw4Wlc2IjII80xcxEwVAKI48JMxAIw28IcxkI7V AKI48JMxCjnVAK0II2c7xJMxC20s026xCaFVCjc4AY6r1j6r4UMxCIbVAxMI8I3I0E5I8C rVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8Zw CIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x02 67AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr 0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7sRi1v VJUUUUU== X-CM-SenderInfo: 5olx5txfdqquhrush05hwht23hof0z/1tbiBQAMCVt76zN6BgAYsc Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: liuyacan 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. Signed-off-by: liuyacan Fixes: 86434744 ("net/smc: add fallback check to connect()") --- 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 fce16b9d6..45a24d242 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;