Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2691234imj; Mon, 11 Feb 2019 07:05:28 -0800 (PST) X-Google-Smtp-Source: AHgI3IYo1ShKpncwYTqdVWM8XNzU6r1PcSaPGz3Mg8G9qSfPnk5vntQyYFdoVlidx+OnzgACDHOp X-Received: by 2002:a63:ec48:: with SMTP id r8mr4951273pgj.50.1549897528397; Mon, 11 Feb 2019 07:05:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549897528; cv=none; d=google.com; s=arc-20160816; b=QIGoUWuiUEPJZRKxcC5Xo5NC+H0xKX3vjMninLBivEgNScbNCC656G/4rBifh6zUKC pfG18ptx5SlgerlVqZnTHILzlF5d8xHnS/4oUAq1sbr2QAQ5wytpnDPElMCom+jXE2J4 QKXFy7lbppksiEG+J/iTyquay2P6AnJsYxqbsu4+ZUTDXf3rE1gsXJXTzV7aXO2Y2k3e G8cVIKaPYjVwNDMDk5YrNWtW6WZMtqUFVHPSHM8ndIOrV1YhtZw3yT/MjcX02L4+Agk0 Vj2h4PgIz+X/0baHXvkRZ0kM3+ghNz7GcB1unq/nK0pIVHmvvtkQihSB0XlDr81F8AqC gfPA== 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=jEf+sVPfaC5GjRwYkNMmwqsbYClltajtAQWjJYoeXWU=; b=MBT5/C13MQRonESu/QTDFOAxshTyCVsfXblWDWEp4ocCGbRKM6eJX3+rfVLPjQ6VO4 HWUSQP8AibfjvVN3UU8QMkMEAWnonNrYpFEFyrYyw5zQOTo2rRF92+0nxX4poEP/MCYe VOFCzxTq1uYQPL0b6rWFL4zAHKrDu/j8qSIswl8idl8dalRijjaY4hRWDvrTY+82KoIJ c0g5RUxbOGLqtISV9DSFHwt6tIs6hwm58NAU0rOtVkW5b56P+D8WS4SlJ2F0V13wpvZE pEJTzB3Gv0nlgBHdHqg7cKMC2oG6KLoDkslxmJFxQKVtQzYu+/y9wb/Cr64onhMIOZum ZgwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fwe2zK9E; 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 w5si5852773pgh.493.2019.02.11.07.05.07; Mon, 11 Feb 2019 07:05:28 -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=fwe2zK9E; 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 S2390692AbfBKPEG (ORCPT + 99 others); Mon, 11 Feb 2019 10:04:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:52838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390698AbfBKPEC (ORCPT ); Mon, 11 Feb 2019 10:04:02 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 BB71C222B1; Mon, 11 Feb 2019 15:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897441; bh=vsvl/RBmdO8DV9rUsOFFPy6XQC91IeUG4Qp4oOsBQzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fwe2zK9ERrzTk9u03UbkUqV9FkF0eJ/6GVz/AnUEyujxEG7icsMAENbL7M7loRsap Sceqv0QS+CPXZ7jNEH6/OXfiSaY07n3k+IRVO2GrGi7GoaOc+UNawM8labmTdDMUOm mz+78Y96WP74QyvWeN5JKzQCUOglYvJ/Smr7/Oqg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Michael J. Ruhl" , Mike Marciniszyn , Dennis Dalessandro , Jason Gunthorpe Subject: [PATCH 4.14 204/205] IB/hfi1: Add limit test for RC/UC send via loopback Date: Mon, 11 Feb 2019 15:20:02 +0100 Message-Id: <20190211141841.901234258@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mike Marciniszyn commit 09ce351dff8e7636af0beb72cd4a86c3904a0500 upstream. Fix potential memory corruption and panic in loopback for IB_WR_SEND variants. The code blindly assumes the posted length will fit in the fetched rwqe, which is not a valid assumption. Fix by adding a limit test, and triggering the appropriate send completion and putting the QP in an error state. This mimics the handling for non-loopback QPs. Fixes: 15703461533a ("IB/{hfi1, qib, rdmavt}: Move ruc_loopback to rdmavt") Cc: #v4.20+ Reviewed-by: Michael J. Ruhl Signed-off-by: Mike Marciniszyn Signed-off-by: Dennis Dalessandro Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman Signed-off-by: Mike Marciniszyn --- drivers/infiniband/hw/hfi1/ruc.c | 7 ++++++- drivers/infiniband/hw/qib/qib_ruc.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) --- a/drivers/infiniband/hw/hfi1/ruc.c +++ b/drivers/infiniband/hw/hfi1/ruc.c @@ -440,6 +440,8 @@ send: goto op_err; if (!ret) goto rnr_nak; + if (wqe->length > qp->r_len) + goto inv_err; break; case IB_WR_RDMA_WRITE_WITH_IMM: @@ -607,7 +609,10 @@ op_err: goto err; inv_err: - send_status = IB_WC_REM_INV_REQ_ERR; + send_status = + sqp->ibqp.qp_type == IB_QPT_RC ? + IB_WC_REM_INV_REQ_ERR : + IB_WC_SUCCESS; wc.status = IB_WC_LOC_QP_OP_ERR; goto err; --- a/drivers/infiniband/hw/qib/qib_ruc.c +++ b/drivers/infiniband/hw/qib/qib_ruc.c @@ -425,6 +425,8 @@ again: goto op_err; if (!ret) goto rnr_nak; + if (wqe->length > qp->r_len) + goto inv_err; break; case IB_WR_RDMA_WRITE_WITH_IMM: @@ -585,7 +587,10 @@ op_err: goto err; inv_err: - send_status = IB_WC_REM_INV_REQ_ERR; + send_status = + sqp->ibqp.qp_type == IB_QPT_RC ? + IB_WC_REM_INV_REQ_ERR : + IB_WC_SUCCESS; wc.status = IB_WC_LOC_QP_OP_ERR; goto err;