Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp399454pxb; Wed, 3 Mar 2021 06:13:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgvfp6mRtH6QjdNG+/e2GRJjvIDHjoomLcue3t3Quj6Ab3SnU3OAMI1sgSPpO62YKXMbUr X-Received: by 2002:a17:906:1754:: with SMTP id d20mr25604774eje.221.1614780784069; Wed, 03 Mar 2021 06:13:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614780784; cv=none; d=google.com; s=arc-20160816; b=plJoZhB53e2Nnoh7YBSgYCUkiirtjidKz/3lxr3w6VSfd+k3uGPgOiWvy6q8Hsczlb uzcS7GgMqBa/gmrIqf/NKHTwjm4F+XcVI3u0Hdd4gmE15VXISTLsdLx34oRfjo8uDUeb htJ20QdSNq4lFL5aY7uA0OAIIynR5bvoOZ2y0Ml188ZF7lgiuhkfMLU4mRIxJyfViL0W nM1yjD17iDUDhMUjLUIl6ILvt8OUMpxZjcqAHgNjr6Dluze7yfYUhtlFp6pxB7iWduM1 HYIODxFUVALr+eRpL1G8nauYCLTV4CNZmAMh/QRCJSxfWX7HTQ+7G8MzeAKs/QRSTtAT 5RbA== 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=hHAYR1koVdZ4MBP5wt0MmKmvEVYJBk8JcDX8jkXXvoU=; b=QWf7OjldoFtl04QZS4a13JyUFHnRUAzAwzeYjg6lN2ivFHNGdN4WW96Jy0rQHWqhwL FhImDlOapTGgsiOkEh43iO+p+EfqPZcnrBJhUJvHNaM+bDKgrPEKrF7ZE2JAHaKhJ2I9 5FgdpPOi18qabd0UHAsjc0b1EPP+eVkpYD11HgnycmxqdAqScJJ+BvADXWmNQC+A/qSt eoyYeln+nUE5CyW0sM1gK1oNJ7bmNsezo4A+Di/yvJq9h+8J6qu7XWyMMyIpc2KwVmbh nIEAAbnrECeoMINbmMJHX27bocaO3O5nW+oP8aInlthPKoj/RIZ8PPiI42nqJLVowsSv nLRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xWwY0Iq3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g12si18979213edj.22.2021.03.03.06.12.19; Wed, 03 Mar 2021 06:13:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xWwY0Iq3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236917AbhCAUv4 (ORCPT + 99 others); Mon, 1 Mar 2021 15:51:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:37624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236667AbhCARIl (ORCPT ); Mon, 1 Mar 2021 12:08:41 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9AAD365013; Mon, 1 Mar 2021 16:41:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614616920; bh=xDwEW4+jr+KPC+KdUdpWdvNyAV8fF00I/vEh8pQNG/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xWwY0Iq3/GuY6Yha1lPQA6m2n3p55nebOLnKT9atVmSzpjGykfhe5ZsS6C4bUUQ1A wlZ5seJWZ6WNcNdO4PMAcULJNZs0FgVJ9/jzHfSdg8Akcuhol5uiS2RXUXX6ToqT4L G+bhyQpTMkuKStfw6KBmOBCl7eY1K7EROsMyPyk4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bob Pearson , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.19 141/247] RDMA/rxe: Fix coding error in rxe_recv.c Date: Mon, 1 Mar 2021 17:12:41 +0100 Message-Id: <20210301161038.573369527@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bob Pearson [ Upstream commit 7d9ae80e31df57dd3253e1ec514f0000aa588a81 ] check_type_state() in rxe_recv.c is written as if the type bits in the packet opcode were a bit mask which is not correct. This patch corrects this code to compare all 3 type bits to the required type. Fixes: 8700e3e7c485 ("Soft RoCE driver") Link: https://lore.kernel.org/r/20210127214500.3707-1-rpearson@hpe.com Signed-off-by: Bob Pearson Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/sw/rxe/rxe_recv.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_recv.c b/drivers/infiniband/sw/rxe/rxe_recv.c index b8f3e65402d1d..d94e2c5bc317d 100644 --- a/drivers/infiniband/sw/rxe/rxe_recv.c +++ b/drivers/infiniband/sw/rxe/rxe_recv.c @@ -36,21 +36,26 @@ #include "rxe.h" #include "rxe_loc.h" +/* check that QP matches packet opcode type and is in a valid state */ static int check_type_state(struct rxe_dev *rxe, struct rxe_pkt_info *pkt, struct rxe_qp *qp) { + unsigned int pkt_type; + if (unlikely(!qp->valid)) goto err1; + pkt_type = pkt->opcode & 0xe0; + switch (qp_type(qp)) { case IB_QPT_RC: - if (unlikely((pkt->opcode & IB_OPCODE_RC) != 0)) { + if (unlikely(pkt_type != IB_OPCODE_RC)) { pr_warn_ratelimited("bad qp type\n"); goto err1; } break; case IB_QPT_UC: - if (unlikely(!(pkt->opcode & IB_OPCODE_UC))) { + if (unlikely(pkt_type != IB_OPCODE_UC)) { pr_warn_ratelimited("bad qp type\n"); goto err1; } @@ -58,7 +63,7 @@ static int check_type_state(struct rxe_dev *rxe, struct rxe_pkt_info *pkt, case IB_QPT_UD: case IB_QPT_SMI: case IB_QPT_GSI: - if (unlikely(!(pkt->opcode & IB_OPCODE_UD))) { + if (unlikely(pkt_type != IB_OPCODE_UD)) { pr_warn_ratelimited("bad qp type\n"); goto err1; } -- 2.27.0