Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2462058imm; Mon, 24 Sep 2018 04:56:45 -0700 (PDT) X-Google-Smtp-Source: ACcGV60ZQ0sGIVYnFTz+4LQafiCDE0BUWth+O6qCqYtzdy9Kz/BvxrPPLNvgrCoWb1ouPh5SRjQ1 X-Received: by 2002:a63:fe02:: with SMTP id p2-v6mr9354000pgh.148.1537790205001; Mon, 24 Sep 2018 04:56:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537790204; cv=none; d=google.com; s=arc-20160816; b=0pO9ecVGmIpcpb3yhT0iHAN/2/rC9zcNvJFlWS4/E7JQCYLrumalUzYhZ32TnF6Ogh HkG+J1/R5f9/GPgh3GZJPkHaP7Yy3hhL48/0F07XnAgcG5yN0wZzHGuQSrx4dWHDmysX /6WWVJ2V5nqF6IWfc4UbrDMwOWceE/wgIIVpsLWaot2H0s3GE0EwPrGqJRyuffM1ZUDM me5WZbfjiMIYoyLRxDvGac1sD52i0YsKUdmJOu8QBnke9AvamKNvntF+7tBoy9PmnYHU UQigWAke9AimnpDA4Oyc5Vz6m/MVlnxABIcecbGjcBeq++4sA/yBKf/VOWsLFUUDp+Ba 3kfQ== 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; bh=JlpSP2r8fXGQxeGdCPmd2Q86t/dlTAmIKgugyWrK7xY=; b=l43HmygmVyhGWyRlZzNh8JwIDTIMlAGvIlQ8JI/6IeEEononHw8sL8IvRdC4BSss12 yRLUk3mz+AUIF5Uy5QlKgGDfAoy8+xGCWiS8Lw3hbwNG2X+1bWt4BjZo1Px+BpEPlbfZ /2vitWBAFe6JIRxnYptB28puc6SZu77bXESqbMPZKeIf+pMmnrAe4U+P3h4K35aoIfsv HxlPpGQ7c0ujExcqOOWHuIV5Ks2BbSLclRn+An3MjJ9hSa1sHxcX7cjB5Tfyb08QzU9O sHpMt+wos2ZnfnrGS8UVjplkKUvnqxfRVvvH+iIq85co3D5JCkIt1Ys6mMyS+IFsEs9N pJcg== ARC-Authentication-Results: i=1; mx.google.com; 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 g70-v6si37719998pfe.4.2018.09.24.04.56.29; Mon, 24 Sep 2018 04:56:44 -0700 (PDT) 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; 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 S1729862AbeIXR51 (ORCPT + 99 others); Mon, 24 Sep 2018 13:57:27 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51900 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728425AbeIXR51 (ORCPT ); Mon, 24 Sep 2018 13:57:27 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 35FF41072; Mon, 24 Sep 2018 11:55:42 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aaron Knister , Ira Weiny , Jason Gunthorpe Subject: [PATCH 4.4 32/70] IB/ipoib: Avoid a race condition between start_xmit and cm_rep_handler Date: Mon, 24 Sep 2018 13:52:31 +0200 Message-Id: <20180924113102.437212825@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113058.420454070@linuxfoundation.org> References: <20180924113058.420454070@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Aaron Knister commit 816e846c2eb9129a3e0afa5f920c8bbc71efecaa upstream. Inside of start_xmit() the call to check if the connection is up and the queueing of the packets for later transmission is not atomic which leaves a window where cm_rep_handler can run, set the connection up, dequeue pending packets and leave the subsequently queued packets by start_xmit() sitting on neigh->queue until they're dropped when the connection is torn down. This only applies to connected mode. These dropped packets can really upset TCP, for example, and cause multi-minute delays in transmission for open connections. Here's the code in start_xmit where we check to see if the connection is up: if (ipoib_cm_get(neigh)) { if (ipoib_cm_up(neigh)) { ipoib_cm_send(dev, skb, ipoib_cm_get(neigh)); goto unref; } } The race occurs if cm_rep_handler execution occurs after the above connection check (specifically if it gets to the point where it acquires priv->lock to dequeue pending skb's) but before the below code snippet in start_xmit where packets are queued. if (skb_queue_len(&neigh->queue) < IPOIB_MAX_PATH_REC_QUEUE) { push_pseudo_header(skb, phdr->hwaddr); spin_lock_irqsave(&priv->lock, flags); __skb_queue_tail(&neigh->queue, skb); spin_unlock_irqrestore(&priv->lock, flags); } else { ++dev->stats.tx_dropped; dev_kfree_skb_any(skb); } The patch acquires the netif tx lock in cm_rep_handler for the section where it sets the connection up and dequeues and retransmits deferred skb's. Fixes: 839fcaba355a ("IPoIB: Connected mode experimental support") Cc: stable@vger.kernel.org Signed-off-by: Aaron Knister Tested-by: Ira Weiny Reviewed-by: Ira Weiny Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/ulp/ipoib/ipoib_cm.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c @@ -992,12 +992,14 @@ static int ipoib_cm_rep_handler(struct i skb_queue_head_init(&skqueue); + netif_tx_lock_bh(p->dev); spin_lock_irq(&priv->lock); set_bit(IPOIB_FLAG_OPER_UP, &p->flags); if (p->neigh) while ((skb = __skb_dequeue(&p->neigh->queue))) __skb_queue_tail(&skqueue, skb); spin_unlock_irq(&priv->lock); + netif_tx_unlock_bh(p->dev); while ((skb = __skb_dequeue(&skqueue))) { skb->dev = p->dev;