Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2987453pxm; Mon, 28 Feb 2022 09:48:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfR/6JadlfxFI0TwGzEfHPQX1zrEJRiuoXLPPWZR0wT8PG9JIwlQSQBerUtvh8x7YbprjY X-Received: by 2002:a05:6a00:1a09:b0:4e1:67a7:2c87 with SMTP id g9-20020a056a001a0900b004e167a72c87mr22849795pfv.37.1646070490432; Mon, 28 Feb 2022 09:48:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646070490; cv=none; d=google.com; s=arc-20160816; b=CKD3WeV8EGvjJDqG8TL80razTZsKIWA3+D0Arrw5dNYhLXXmjO+kTXIsBTxPyIWmmF J+nOnmGWN2BMA9PRsQ6jgsx8nZ/fZkEzc0DV1LA8JQ/p6l78oamYvHS5AgNkp07m4rLY DS7rV4dJfuJiwzbeXaGEA+yIoRMHv+OZAgK1+1jVaOpBhsJGobB4rBkwrgDtGbYN7bfC IhzF4YUfsK6aP9QwFC0QnEm6fxeZ3ggh/de6QEg1LVEAY4CZSgViX8V0E6a2jAH9StLU gRCCKJ1xMhEtNs8C509pTe9LjDKV2xOsHo42YsIZrq2rb0IYiQ9twmGP2A2hGAMSlFWr 3CRA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=C5YgVD22pchSFr4n2QRFausc1ftChAmgohwP8Wg5Uus=; b=eZD2RSn7r94aauPIF4dAhEnqr6vnrt/M1ewMJTwx78HQlze99ZaVMvUqTklfJrCHsC uzUrA/kgbjwukkfUgcMXbIlaBhB9LK1qJrXjtKcNHZCZxRE5ipwHlJA2w1Jvag8geD/H OLVn0uzTiVTUF3fbGZOmhXcw5Gu9YQkp2EjIE+wfHUqeyvrdohqgNO8c7p6+D4kF8MXw kx8J/DKNZHR5/b/hsRqm2x9w4Aq/x+u69Jrf+VhNespkEPlnS3otQhEuFdU66sqCRXXY 3yqK6vAREE/T+m//FTrxXYmMf6Gs0alZb89ISMk6Oiicgk1752++ZNfSPE84KvMiySS9 RXGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="A/mk/cfu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 19-20020a631853000000b00373c8b90609si9789072pgy.486.2022.02.28.09.47.53; Mon, 28 Feb 2022 09:48:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="A/mk/cfu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238054AbiB1QzL (ORCPT + 99 others); Mon, 28 Feb 2022 11:55:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238046AbiB1QzD (ORCPT ); Mon, 28 Feb 2022 11:55:03 -0500 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48FB127B29; Mon, 28 Feb 2022 08:54:24 -0800 (PST) Received: by mail-ed1-x52b.google.com with SMTP id w3so18463613edu.8; Mon, 28 Feb 2022 08:54:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=C5YgVD22pchSFr4n2QRFausc1ftChAmgohwP8Wg5Uus=; b=A/mk/cfu3W4LvbXsuH6OPqnixZcNLGsp8U+j1ppeX3CDyeeLa2XWuhr6hjGduM1c5w ZhQc5XHsPXylQSYkVQU1+HG79BlfZc+9ol2776y8YGlVlTN/NH7q5QCUSlZ2v5W+lJDs OiQciIn5M5RbGYS14MbyDtCj9+O1JoVJVW/2isYYMWom3fopfilIUMED8qxdVMRYTr2I v0gdbOjShBRyZDVnm8AQhLS6NqG/fj18CL71AcF3qdrdWuj8UGwW0jdkOSlZq1PCnz5g hPXsumBTHKfcV0VeFdjXFeSr7P3CbmOtQY8mI8gCWncanuQ2klpe8eDRWYwydT79gvVd sWjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=C5YgVD22pchSFr4n2QRFausc1ftChAmgohwP8Wg5Uus=; b=rO/0GXinbyGnK9bCcvsInGFK7yhvmh2OTfobC4bpBALcswrZ1jEjo9zpLEL+Ggej2B CuYPUgIWkV2W/XZ6e68zirEwgF3kdytHKpclp7jJA8Jbw/EU37liyygymUaSwtfy6JTJ ocnxQogcPdGhF45T6252QWBUQREXIjGA+DlZe3m/LGNkzzLSK79enr8j6SH/VTJ4o5Ah nOpxVc9zSnkkljywYgqhFC6y/FqsyzQC0eJNyDEe8Xa3X0X9q6/faT3MFyWXRXtHP1m7 uCRfrNcVzhNDooJ0p91AIiZgl3Dz94CT/mgWI8Kqm0RpfzD04mDigYef6UteXEZ6di4Z yp6g== X-Gm-Message-State: AOAM5310MdDvqvlnglDwb+muTcZMYizjn/7+baacUIibr+Jv8tk8Fkyf pgEnCCF7erFCk1V3UcS5mjOikJkdatloWw== X-Received: by 2002:a05:6402:4491:b0:413:162a:fc85 with SMTP id er17-20020a056402449100b00413162afc85mr20419425edb.115.1646067262926; Mon, 28 Feb 2022 08:54:22 -0800 (PST) Received: from nlaptop.localdomain (ptr-dtfv0poj8u7zblqwbt6.18120a2.ip6.access.telenet.be. [2a02:1811:cc83:eef0:f2b6:6987:9238:41ca]) by smtp.gmail.com with ESMTPSA id ju22-20020a17090798b600b006ce70fa8e4fsm4495828ejc.187.2022.02.28.08.54.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 08:54:22 -0800 (PST) From: Niels Dossche To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dennis Dalessandro , Mike Marciniszyn , Jason Gunthorpe , Niels Dossche Subject: [PATCH] IB/rdmavt: add lock to call to rvt_error_qp to prevent a race condition Date: Mon, 28 Feb 2022 17:53:30 +0100 Message-Id: <20220228165330.41546-1-dossche.niels@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 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. However, the commit I referenced in Fixes accidentally makes the call to rvt_error_qp in rvt_ruc_loopback no longer covered by r_lock. This results in the lockdep assertion failing and also possibly in a race condition. Fixes: d757c60eca9b ("IB/rdmavt: Fix concurrency panics in QP post_send and modify to error") Signed-off-by: Niels Dossche --- 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 ae50b56e8913..8ef112f883a7 100644 --- a/drivers/infiniband/sw/rdmavt/qp.c +++ b/drivers/infiniband/sw/rdmavt/qp.c @@ -3190,7 +3190,11 @@ void rvt_ruc_loopback(struct rvt_qp *sqp) spin_lock_irqsave(&sqp->s_lock, flags); rvt_send_complete(sqp, wqe, send_status); if (sqp->ibqp.qp_type == IB_QPT_RC) { - int lastwqe = rvt_error_qp(sqp, IB_WC_WR_FLUSH_ERR); + int lastwqe; + + spin_lock(&sqp->r_lock); + lastwqe = rvt_error_qp(sqp, IB_WC_WR_FLUSH_ERR); + spin_unlock(&sqp->r_lock); sqp->s_flags &= ~RVT_S_BUSY; spin_unlock_irqrestore(&sqp->s_lock, flags); -- 2.35.1