Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2183956iof; Tue, 7 Jun 2022 22:29:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw01qL0kqR0yhPKbm3XlCvdnaZcXGTfXgOwoS7M/UkZ9jmixhm4CeWsqkg7kbI7B6nChovT X-Received: by 2002:a05:6a00:1956:b0:51c:3a0:49d2 with SMTP id s22-20020a056a00195600b0051c03a049d2mr18054731pfk.29.1654666165165; Tue, 07 Jun 2022 22:29:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666165; cv=none; d=google.com; s=arc-20160816; b=Y6ZYaaTCynxGnhs4IdLhUWKNMDvgpqOS2qdbCvSYTCNozT6IjdroVyJ8WIOCmK5oGB zEppeNDaz8yD3bBjEcRNbfEk7wQVT9lJr7fgGNgPOqEx5eWmbAip7CcAwQ4wXoCj7hGL /JWmVEHVb0gQXfpCgM2lgA+jKjlCbSGsd5okG1npkzKV+kiQRSF69neKxZU9ERqc/XoI Q6HdlPwf8Tss+6fEFmBQj+Vm9mahJyjV/QgzyUfUJs16oPLZF44DotKJ3P3JwEGR2usq l6sX8VWCFHMMoZL7nEUuudLYr7Xnlpu7DxOVAqnRMRSlz7tYncVyMuK/H6RCjDbi+ubD inRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vV5rtSm8VGvlGDmuW/xbk+RmxFw21oHcQvrVTGDgE7g=; b=krIoOnN7mG+CfpH+Z0PSo9G+ENC0geMDcDH1EpmLvYHEelJ4QXx3Biz7co1dCAkn17 sudvzH6rz/nfvhCZAX/6HLwaiItmFY+yWynWQxNrX4hxPAXH5oGSg1WngWjJdrsTaJ+Z byFirYdIAG2dcLpGmEC2PsHU4qOY00tkdeI5yS8jkhMaXN2Hum54OGqE5slHm1zmfSyB yLl73CEY4/EmVym2bVE/PEDzMgBYsh7NGXaP8F9+C5B+XG1312ldyb3XGWPbhn6iU3nU 1/tpSe3KqyVrC66u/nf5ZvK6+aimGeoiNpuwCV9r1dGQpGIbzSd3SnZBGlvcjKhJayI7 9NBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PY11wD6H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h13-20020a170902f70d00b00163783a3464si25968272plo.427.2022.06.07.22.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:29:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PY11wD6H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3B7F347C25B; Tue, 7 Jun 2022 21:55:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385056AbiFGWUz (ORCPT + 99 others); Tue, 7 Jun 2022 18:20:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380427AbiFGVQS (ORCPT ); Tue, 7 Jun 2022 17:16:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE48B21CBFC; Tue, 7 Jun 2022 11:55:05 -0700 (PDT) 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 925EE61277; Tue, 7 Jun 2022 18:55:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A399EC385A2; Tue, 7 Jun 2022 18:55:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628105; bh=Io4HhJb+Cz16sRUnVJbOtBv6IWiQnhJuRY59WG07j+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PY11wD6HNhsbobYiOdBf9xufMl36zGVvY814mOQlai5kAgoMazkXnpdPfdBdCGHNs aAlw9gNfK2Sf+zBIORMZOzFPEoi3pRZThrwWB5kEymlCIUHoYuBVI3zF1/6s559Oqo 2oGRs5dD033v/g3r3n2JDlaflAoJz4X1UDFSyRDI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niels Dossche , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.18 209/879] IB/rdmavt: add missing locks in rvt_ruc_loopback Date: Tue, 7 Jun 2022 18:55:27 +0200 Message-Id: <20220607165008.918827102@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Niels Dossche [ Upstream commit 22cbc6c2681a0a4fe76150270426e763d52353a4 ] The documentation of the function rvt_error_qp says both r_lock and s_lock need to be held when calling that function. It also asserts using lockdep that both of those locks are held. rvt_error_qp is called form rvt_send_cq, which is called from rvt_qp_complete_swqe, which is called from rvt_send_complete, which is called from rvt_ruc_loopback in two places. Both of these places do not hold r_lock. Fix this by acquiring a spin_lock of r_lock in both of these places. The r_lock acquiring cannot be added in rvt_qp_complete_swqe because some of its other callers already have r_lock acquired. Link: https://lore.kernel.org/r/20220228195144.71946-1-dossche.niels@gmail.com Signed-off-by: Niels Dossche Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/sw/rdmavt/qp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c index 8ef112f883a7..3acab569fbb9 100644 --- a/drivers/infiniband/sw/rdmavt/qp.c +++ b/drivers/infiniband/sw/rdmavt/qp.c @@ -2775,7 +2775,7 @@ void rvt_qp_iter(struct rvt_dev_info *rdi, EXPORT_SYMBOL(rvt_qp_iter); /* - * This should be called with s_lock held. + * This should be called with s_lock and r_lock held. */ void rvt_send_complete(struct rvt_qp *qp, struct rvt_swqe *wqe, enum ib_wc_status status) @@ -3134,7 +3134,9 @@ void rvt_ruc_loopback(struct rvt_qp *sqp) rvp->n_loop_pkts++; flush_send: sqp->s_rnr_retry = sqp->s_rnr_retry_cnt; + spin_lock(&sqp->r_lock); rvt_send_complete(sqp, wqe, send_status); + spin_unlock(&sqp->r_lock); if (local_ops) { atomic_dec(&sqp->local_ops_pending); local_ops = 0; @@ -3188,7 +3190,9 @@ void rvt_ruc_loopback(struct rvt_qp *sqp) spin_unlock_irqrestore(&qp->r_lock, flags); serr_no_r_lock: spin_lock_irqsave(&sqp->s_lock, flags); + spin_lock(&sqp->r_lock); rvt_send_complete(sqp, wqe, send_status); + spin_unlock(&sqp->r_lock); if (sqp->ibqp.qp_type == IB_QPT_RC) { int lastwqe; -- 2.35.1