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 3C627C433EF for ; Mon, 7 Mar 2022 10:15:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239260AbiCGKQP (ORCPT ); Mon, 7 Mar 2022 05:16:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241167AbiCGKJ5 (ORCPT ); Mon, 7 Mar 2022 05:09: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 49DA727B32; Mon, 7 Mar 2022 01:52:49 -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 CC39960919; Mon, 7 Mar 2022 09:52:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1FD0C340F5; Mon, 7 Mar 2022 09:52:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646646759; bh=9hk4H8I+KzAD19sWJ0jw7OSMyMGpO9KaKuqO+K3HBUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MW3dgVEJGkJe+UhNRLluWgfSbE0uZXBA5AzNrcRndDYVOLa2IilyMyhYYc2gHEUiY Ktph1e4xqOGc/eTAxzd7VnbzENoIxYtUkYrPjJRiSGSL0aGjeJIO/qLjQN8CaUaNou XqQNGU8peKIqh5OdHMEqVZSFRcztol1XU30aae5g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "D. Wythe" , "David S. Miller" Subject: [PATCH 5.16 084/186] net/smc: fix unexpected SMC_CLC_DECL_ERR_REGRMB error generated by client Date: Mon, 7 Mar 2022 10:18:42 +0100 Message-Id: <20220307091656.435078522@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091654.092878898@linuxfoundation.org> References: <20220307091654.092878898@linuxfoundation.org> User-Agent: quilt/0.66 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: D. Wythe commit 0537f0a2151375dcf90c1bbfda6a0aaf57164e89 upstream. The main reason for this unexpected SMC_CLC_DECL_ERR_REGRMB in client dues to following execution sequence: Server Conn A: Server Conn B: Client Conn B: smc_lgr_unregister_conn smc_lgr_register_conn smc_clc_send_accept -> smc_rtoken_add smcr_buf_unuse -> Client Conn A: smc_rtoken_delete smc_lgr_unregister_conn() makes current link available to assigned to new incoming connection, while smcr_buf_unuse() has not executed yet, which means that smc_rtoken_add may fail because of insufficient rtoken_entry, reversing their execution order will avoid this problem. Fixes: 3e034725c0d8 ("net/smc: common functions for RMBs and send buffers") Signed-off-by: D. Wythe Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/smc/smc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -1132,8 +1132,8 @@ void smc_conn_free(struct smc_connection cancel_work_sync(&conn->abort_work); } if (!list_empty(&lgr->list)) { - smc_lgr_unregister_conn(conn); smc_buf_unuse(conn, lgr); /* allow buffer reuse */ + smc_lgr_unregister_conn(conn); } if (!lgr->conns_num)