Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp31756ybl; Tue, 7 Jan 2020 13:30:43 -0800 (PST) X-Google-Smtp-Source: APXvYqzs6co4EwZ7YQJ2icm6C9qYz38k1ivV/JX5q00xroM+ZZ4OXJPIkEDCBoPhqT4bvobzgDYV X-Received: by 2002:aca:4442:: with SMTP id r63mr423504oia.33.1578432643868; Tue, 07 Jan 2020 13:30:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578432643; cv=none; d=google.com; s=arc-20160816; b=sIzOI33+fAEaNyD0jnu1GNhXMVvR/+DpCfyIJSZB+yupphRoaHM89KiWagDeafHbo8 VXEbNszIkLGU9gXvn7QYmBhlG9bbvJneXK1An+0bw1VNIXgMccOV/lrEWG+dt8ZUne9a 7kDw3GWdZFZMr/nY8md+G0qBZBZeTjNv2pXBVPQv2OvzOue+6jGtpElztgvCb09+ykvA v2A3VSFCRob1vqeOZ1iRaZ89mgEXeERNa9RXQpX7PVbO1tdjs83XiUXeVhSJgrTNonO0 7vZuibTwj9p7MeEm6H+CNBuilbhoAGUARoOkxftmCC1N56NZCD+Cn3QeB6Oo2IHQ615b jlag== 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=8IMPKag3q9VFzW732anPEwXoNnX9T5YK35x5MJdD4Ls=; b=XbTvPcsknQ42k9ULOAZ9vRlPureND3gpLO3N/4Blu4A05fiAWQWoNdQhfDt6vBiRm+ a6oj0dH4JgT3aHGjj8qqSHvLeF5IMidmeUmLrGXg5DpuCgsvmO+MCmCdIIjaoy62zMwp W93PyxUe7UnrvvY8bNqCTXt63mZJcYcEnrqmKHsG42Xr+TeX6y058MX2bk0IM1Id9dd0 3HxOxaIVUS9DHwNBuOYGkRW7tNHCUM+Rzhhflxh8L6phcYkU6hPXvdpKBj01Xr+yMx4C WoP9udTQZSgy4jbW/5gpQqFrZkfl5Mtt0NR3pXEw829dgoKbs8cPMTyteFuRMXwi11xP c0lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="iv/GQuOJ"; 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 j13si520478otq.146.2020.01.07.13.30.31; Tue, 07 Jan 2020 13:30:43 -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="iv/GQuOJ"; 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 S1727316AbgAGU4t (ORCPT + 99 others); Tue, 7 Jan 2020 15:56:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:52760 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727287AbgAGU4r (ORCPT ); Tue, 7 Jan 2020 15:56:47 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 E318C24672; Tue, 7 Jan 2020 20:56:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578430606; bh=3LQTQLau0COdzUYzcCjCQs+p0oOs4r5SsqHDMBvNqcg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iv/GQuOJgOy5gnl6OyhFmWhvnzBp4F1mUhfytBdWll1nhQtIAvIJrtfHmwx3J/K0U /m5jMJQNALbG34YD5rxVc7cCwRfi9SF0XIR3VckTAoYC2uHjOh5DvT7H0lsqyBcb/1 U0V9FzEqYezoppZZfu4ep5JmU6IvabnZLBKA7FdM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steve Wise , Doug Ledford , Sasha Levin Subject: [PATCH 5.4 022/191] rxe: correctly calculate iCRC for unaligned payloads Date: Tue, 7 Jan 2020 21:52:22 +0100 Message-Id: <20200107205334.190976846@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200107205332.984228665@linuxfoundation.org> References: <20200107205332.984228665@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Steve Wise [ Upstream commit 2030abddec6884aaf5892f5724c48fc340e6826f ] If RoCE PDUs being sent or received contain pad bytes, then the iCRC is miscalculated, resulting in PDUs being emitted by RXE with an incorrect iCRC, as well as ingress PDUs being dropped due to erroneously detecting a bad iCRC in the PDU. The fix is to include the pad bytes, if any, in iCRC computations. Note: This bug has caused broken on-the-wire compatibility with actual hardware RoCE devices since the soft-RoCE driver was first put into the mainstream kernel. Fixing it will create an incompatibility with the original soft-RoCE devices, but is necessary to be compatible with real hardware devices. Fixes: 8700e3e7c485 ("Soft RoCE driver") Signed-off-by: Steve Wise Link: https://lore.kernel.org/r/20191203020319.15036-2-larrystevenwise@gmail.com Signed-off-by: Doug Ledford Signed-off-by: Sasha Levin --- drivers/infiniband/sw/rxe/rxe_recv.c | 2 +- drivers/infiniband/sw/rxe/rxe_req.c | 6 ++++++ drivers/infiniband/sw/rxe/rxe_resp.c | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/sw/rxe/rxe_recv.c b/drivers/infiniband/sw/rxe/rxe_recv.c index f9a492ed900b..831ad578a7b2 100644 --- a/drivers/infiniband/sw/rxe/rxe_recv.c +++ b/drivers/infiniband/sw/rxe/rxe_recv.c @@ -389,7 +389,7 @@ void rxe_rcv(struct sk_buff *skb) calc_icrc = rxe_icrc_hdr(pkt, skb); calc_icrc = rxe_crc32(rxe, calc_icrc, (u8 *)payload_addr(pkt), - payload_size(pkt)); + payload_size(pkt) + bth_pad(pkt)); calc_icrc = (__force u32)cpu_to_be32(~calc_icrc); if (unlikely(calc_icrc != pack_icrc)) { if (skb->protocol == htons(ETH_P_IPV6)) diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index c5d9b558fa90..e5031172c019 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -500,6 +500,12 @@ static int fill_packet(struct rxe_qp *qp, struct rxe_send_wqe *wqe, if (err) return err; } + if (bth_pad(pkt)) { + u8 *pad = payload_addr(pkt) + paylen; + + memset(pad, 0, bth_pad(pkt)); + crc = rxe_crc32(rxe, crc, pad, bth_pad(pkt)); + } } p = payload_addr(pkt) + paylen + bth_pad(pkt); diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c index 1cbfbd98eb22..c4a8195bf670 100644 --- a/drivers/infiniband/sw/rxe/rxe_resp.c +++ b/drivers/infiniband/sw/rxe/rxe_resp.c @@ -732,6 +732,13 @@ static enum resp_states read_reply(struct rxe_qp *qp, if (err) pr_err("Failed copying memory\n"); + if (bth_pad(&ack_pkt)) { + struct rxe_dev *rxe = to_rdev(qp->ibqp.device); + u8 *pad = payload_addr(&ack_pkt) + payload; + + memset(pad, 0, bth_pad(&ack_pkt)); + icrc = rxe_crc32(rxe, icrc, pad, bth_pad(&ack_pkt)); + } p = payload_addr(&ack_pkt) + payload + bth_pad(&ack_pkt); *p = ~icrc; -- 2.20.1