Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4820925ybl; Wed, 22 Jan 2020 05:23:16 -0800 (PST) X-Google-Smtp-Source: APXvYqwPT3ZDpgriPmMFOyhdr11T/cF3O+Rd5qLQGjTkbItbut+f09RHNSUMtHkZw2AurfVvVczg X-Received: by 2002:a05:6808:64e:: with SMTP id z14mr6432107oih.79.1579699396224; Wed, 22 Jan 2020 05:23:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579699396; cv=none; d=google.com; s=arc-20160816; b=YWid8a+H/B1q6f0ePi3nexpn4ILPL7a6u1abPENyQqIA0YH9VbLDi8v5fjsdozKrCH 5HuCgkHsiJ+Nzzg2EIHft9Z/jWF8+lpVuOcrx13hprOT2PYQ3romnMaESwj3UYQx8z6y 8ovx13iuUyNyhlCYHYwuCgD9IrTJgAUUealsK1QHpc0m4pkYCCdSkoK4SkkAX1ECUm89 IwPmgUdsdOd37fDfwBFCjlGMCWQgd4N6QphUFT/wI8Ux6pLlceuw86aqPAjf1InNKz4g pmFgGTOLBdq/rP2vJRRPO7KmP+oeMgdC2yTcU4i65P4X1SE2Q+OftY3KVeJxy6soUCtD GsSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5wnHQWrRShl2QURV8vAVeZxTJFPtUCUPlrCoHu5GTT0=; b=uElFrXls/KYLf9EIdfP/UMAvvFi4dOcn7D6EnvHUzg8Pa4vVDzxkhFUJceUh/XWL9x zNRDn5oLy2F5KvmcemXMhj89lX8uVAL1aiqVIJznfTotVWikdyFeCMNSI6pVTszNcmMw ORjR3HrUBVoAhtE8vcfixEcnw+UF2C4iZro22kyz03BpSKQ21ZeBNma0GTIFrVbdnkem 3Mk21OZOUjGU7SAp0uaJHuvvbs2WNeq0qjFnnDces3AE6R39kgT93C+uvx7r/rZ9aycP ErqjyibqAZOLK2aGQIZ2svI/hmutwm0GW1a4KUknI9YlkyBRhXRJZ/YGIVenNwYgpLai BMVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=j68xtD08; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r15si23159345ota.264.2020.01.22.05.23.04; Wed, 22 Jan 2020 05:23:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=j68xtD08; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729499AbgAVNVq (ORCPT + 99 others); Wed, 22 Jan 2020 08:21:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:38956 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730333AbgAVNVp (ORCPT ); Wed, 22 Jan 2020 08:21:45 -0500 Received: from localhost (unknown [84.241.205.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7639D2467C; Wed, 22 Jan 2020 13:21:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699304; bh=qGeoai9UnnZ3Cp9T1ScTRcn83Sx5k4kgEfiDhgQv7kA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j68xtD08w0PmIvXYE66TkbnuIagOggDfGhSfiJYIuD38VrgNBs3A33ibwYjK0nYgu 6N8PJmlEQbYMPplqnkHrZbw7S5SQjkDwrSzl7FYUpnuUc60n9BdoBfhIzGdveLhwcT x0HGF/hfNNwi1aY75hXBZWKxknDze97C2Iu+ZCMc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jon Maloy , Tuong Lien , "David S. Miller" Subject: [PATCH 5.4 102/222] tipc: fix potential hanging after b/rcast changing Date: Wed, 22 Jan 2020 10:28:08 +0100 Message-Id: <20200122092841.046200497@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tuong Lien commit dca4a17d24ee9d878836ce5eb8dc25be1ffa5729 upstream. In commit c55c8edafa91 ("tipc: smooth change between replicast and broadcast"), we allow instant switching between replicast and broadcast by sending a dummy 'SYN' packet on the last used link to synchronize packets on the links. The 'SYN' message is an object of link congestion also, so if that happens, a 'SOCK_WAKEUP' will be scheduled to be sent back to the socket... However, in that commit, we simply use the same socket 'cong_link_cnt' counter for both the 'SYN' & normal payload message sending. Therefore, if both the replicast & broadcast links are congested, the counter will be not updated correctly but overwritten by the latter congestion. Later on, when the 'SOCK_WAKEUP' messages are processed, the counter is reduced one by one and eventually overflowed. Consequently, further activities on the socket will only wait for the false congestion signal to disappear but never been met. Because sending the 'SYN' message is vital for the mechanism, it should be done anyway. This commit fixes the issue by marking the message with an error code e.g. 'TIPC_ERR_NO_PORT', so its sending should not face a link congestion, there is no need to touch the socket 'cong_link_cnt' either. In addition, in the event of any error (e.g. -ENOBUFS), we will purge the entire payload message queue and make a return immediately. Fixes: c55c8edafa91 ("tipc: smooth change between replicast and broadcast") Acked-by: Jon Maloy Signed-off-by: Tuong Lien Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/tipc/bcast.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c @@ -305,17 +305,17 @@ static int tipc_rcast_xmit(struct net *n * @skb: socket buffer to copy * @method: send method to be used * @dests: destination nodes for message. - * @cong_link_cnt: returns number of encountered congested destination links * Returns 0 if success, otherwise errno */ static int tipc_mcast_send_sync(struct net *net, struct sk_buff *skb, struct tipc_mc_method *method, - struct tipc_nlist *dests, - u16 *cong_link_cnt) + struct tipc_nlist *dests) { struct tipc_msg *hdr, *_hdr; struct sk_buff_head tmpq; struct sk_buff *_skb; + u16 cong_link_cnt; + int rc = 0; /* Is a cluster supporting with new capabilities ? */ if (!(tipc_net(net)->capabilities & TIPC_MCAST_RBCTL)) @@ -343,18 +343,19 @@ static int tipc_mcast_send_sync(struct n _hdr = buf_msg(_skb); msg_set_size(_hdr, MCAST_H_SIZE); msg_set_is_rcast(_hdr, !msg_is_rcast(hdr)); + msg_set_errcode(_hdr, TIPC_ERR_NO_PORT); __skb_queue_head_init(&tmpq); __skb_queue_tail(&tmpq, _skb); if (method->rcast) - tipc_bcast_xmit(net, &tmpq, cong_link_cnt); + rc = tipc_bcast_xmit(net, &tmpq, &cong_link_cnt); else - tipc_rcast_xmit(net, &tmpq, dests, cong_link_cnt); + rc = tipc_rcast_xmit(net, &tmpq, dests, &cong_link_cnt); /* This queue should normally be empty by now */ __skb_queue_purge(&tmpq); - return 0; + return rc; } /* tipc_mcast_xmit - deliver message to indicated destination nodes @@ -396,9 +397,14 @@ int tipc_mcast_xmit(struct net *net, str msg_set_is_rcast(hdr, method->rcast); /* Switch method ? */ - if (rcast != method->rcast) - tipc_mcast_send_sync(net, skb, method, - dests, cong_link_cnt); + if (rcast != method->rcast) { + rc = tipc_mcast_send_sync(net, skb, method, dests); + if (unlikely(rc)) { + pr_err("Unable to send SYN: method %d, rc %d\n", + rcast, rc); + goto exit; + } + } if (method->rcast) rc = tipc_rcast_xmit(net, pkts, dests, cong_link_cnt);