Received: by 10.223.185.116 with SMTP id b49csp1010381wrg; Wed, 21 Feb 2018 10:30:57 -0800 (PST) X-Google-Smtp-Source: AH8x225IJGffUiDr8mbgErM3kkQqnrZhmd0snO3ZK2IbQw8DmoHZcKnrsAgiXN+jYPoryUEhTFXO X-Received: by 2002:a17:902:7587:: with SMTP id j7-v6mr4061381pll.135.1519237857292; Wed, 21 Feb 2018 10:30:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519237857; cv=none; d=google.com; s=arc-20160816; b=kvC5TRCq0mIGoOeTAOuu/Pp0CYDfM/XbY3uFO2A3wgGdgSEnaBF5UiyOzfa86bcLRj 7anJ7CRG1a2QPla9yt61x6g696m3TurJjC33RKKWaR4pPZ0deBMMz1MXMCqzGyZbCwTt jK8OwADW4HskWFhTyYFOFPfofT0gWD4aWLt+VkLnA6l60Ydrr38mwJeyX5Djpdc/z43Z ADwQRn5eLGi350i3WMQeV8bIJVhSNsFxrxK6eR8jcQ4yYL0sE+6rus+7Dqs5WDukms0V gkcTz8/Hm4NLqXvQe9vgdfdjT1kwtnAvQHuJ7xDKCV4rObF3lWAQ6Sm+/EkmzsbLCP1l h6mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=euLTwpMQBUKIWRjqjkFVaOmYdSaa3bSMpsrZWOnaGfk=; b=vKCet6LSYxC1HjrXN2VW3Pm8kSgK7zO+ofaL078bTs8CMCdWZBZumfXvGHNZL32rWJ wcOwoZnIsFH41swW3iNxvifNJ4Laaqy13TlXxViR/DevtAqifLR+cVb94uOHQyxlrlTr WIX+QdLNEsHJWRpE64gbaRgNuC2m4naJzLKnJ/GfofNXTtb6asCpDYL/dt3eRLjpYOf9 PcUtglcAlPVcYf1Y4yqYoXapJpYiHlU5y0vMmegLAoDlW65S4b1Yh/qvzS51raeK/Uon 004saScdHIF0iA5sxC5IAlGhMn1BieP8YTWKT03omlDH2hIX3edlJAINZvT4TllDGuIq fwAQ== 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 n13si1511872pgq.674.2018.02.21.10.30.42; Wed, 21 Feb 2018 10:30:57 -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; 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 S964925AbeBUNF6 (ORCPT + 99 others); Wed, 21 Feb 2018 08:05:58 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40484 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964913AbeBUNF4 (ORCPT ); Wed, 21 Feb 2018 08:05:56 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EDEE911CC; Wed, 21 Feb 2018 13:05:55 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Moni Shoua , Bart Van Assche , Doug Ledford Subject: [PATCH 4.15 011/163] RDMA/rxe: Fix a race condition in rxe_requester() Date: Wed, 21 Feb 2018 13:47:20 +0100 Message-Id: <20180221124530.623695921@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124529.931834518@linuxfoundation.org> References: <20180221124529.931834518@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bart Van Assche commit 65567e41219888feec72fee1de98ccf1efbbc16d upstream. The rxe driver works as follows: * The send queue, receive queue and completion queues are implemented as circular buffers. * ib_post_send() and ib_post_recv() calls are serialized through a spinlock. * Removing elements from various queues happens from tasklet context. Tasklets are guaranteed to run on at most one CPU. This serializes access to these queues. See also rxe_completer(), rxe_requester() and rxe_responder(). * rxe_completer() processes the skbs queued onto qp->resp_pkts. * rxe_requester() handles the send queue (qp->sq.queue). * rxe_responder() processes the skbs queued onto qp->req_pkts. Since rxe_drain_req_pkts() processes qp->req_pkts, calling rxe_drain_req_pkts() from rxe_requester() is racy. Hence this patch. Reported-by: Moni Shoua Signed-off-by: Bart Van Assche Cc: stable@vger.kernel.org Signed-off-by: Doug Ledford Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/sw/rxe/rxe_loc.h | 1 - drivers/infiniband/sw/rxe/rxe_req.c | 9 +-------- drivers/infiniband/sw/rxe/rxe_resp.c | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-) --- a/drivers/infiniband/sw/rxe/rxe_loc.h +++ b/drivers/infiniband/sw/rxe/rxe_loc.h @@ -237,7 +237,6 @@ int rxe_srq_from_attr(struct rxe_dev *rx void rxe_release(struct kref *kref); -void rxe_drain_req_pkts(struct rxe_qp *qp, bool notify); int rxe_completer(void *arg); int rxe_requester(void *arg); int rxe_responder(void *arg); --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -594,15 +594,8 @@ int rxe_requester(void *arg) rxe_add_ref(qp); next_wqe: - if (unlikely(!qp->valid)) { - rxe_drain_req_pkts(qp, true); + if (unlikely(!qp->valid || qp->req.state == QP_STATE_ERROR)) goto exit; - } - - if (unlikely(qp->req.state == QP_STATE_ERROR)) { - rxe_drain_req_pkts(qp, true); - goto exit; - } if (unlikely(qp->req.state == QP_STATE_RESET)) { qp->req.wqe_index = consumer_index(qp->sq.queue); --- a/drivers/infiniband/sw/rxe/rxe_resp.c +++ b/drivers/infiniband/sw/rxe/rxe_resp.c @@ -1210,7 +1210,7 @@ static enum resp_states do_class_d1e_err } } -void rxe_drain_req_pkts(struct rxe_qp *qp, bool notify) +static void rxe_drain_req_pkts(struct rxe_qp *qp, bool notify) { struct sk_buff *skb;