Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.199 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796002421; b=lilxTMkxkHbPO4M+aYvesDk3S5XbtrdwJT/WF98qn2NZuSI8J7oIgHIO1nPQG6A36zez A3rY7k2slQxaLfo9TaT/nE9T+BU7rCJShD33jMPa/gFXZ38YUyyyd8Dn/1R4A6Dw6PY5b hXFyutrnN4X+/FWgo8s/ibgRGUUjBHEG9CEeVTMzqVcnRN2vThrVCjjKqJ2q6JPcrm7r7 amVBLjN6r+acDYqtJydwo1Vqg9RbeCS6qVcjSQhaRqSHpi7nayCe6kxLFZcIhwF0CI2dx +duqscpuFRUt8Xmzo/0qDkZsuJMXdg8fqyrv1RXX+qIdsbplTqb8R7du4NH8ytIhgmA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796002421; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Received:Date:In-Reply-To:Mime-Version: References:X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=C2f5Xm4Eq2UOJ7X6ZQmE+0ZIf6PdeT+Xfv3UXkcG0Tg=; b=16J15YYxgryJvsfS6EMQsT61ozldeDlPD3CR+FhXPRunGGygL4Uao3hlnNaap1MuH1R6 3RXH1jyke2NViKoGJdCjLmDRM379fhNJO9C9z+XXLyJIetSc11v54B6ALAC7XO8Sz2pW2 LOSV7F1CHz503O+rBpWAtv8HLAGtDRWGunYYaFsS7TcbNcleIHWmMAm8kv0RMVFceFWGX EtGFvyLKDxOr73BglozYXgef0vh08dlvNYalg+8dQEjzH4UCM2JnJR970bWuKdR5ixj48 T2HXdZvPuDaVUOAlvzuQa0WKSLIRHjnDPI20Km76c8r6q+QbgeTUGEUUjvZY4aiR1cA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--jmoroni.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=l+XnkB34; arc=none smtp.remote-ip=209.85.128.199 Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C980606A32A for ; Mon, 30 Nov 2026 01:33:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9C980606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jmoroni.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=l+XnkB34 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-8b4d9d2e261so146024887b3.0 for ; Sun, 29 Nov 2026 17:33:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796002419; x=1796607219; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=C2f5Xm4Eq2UOJ7X6ZQmE+0ZIf6PdeT+Xfv3UXkcG0Tg=; b=l+XnkB348lyZpsKOf/SvCuBQaFLInaQ4mbQ+eiesFkZaSEw/q0kWa5shCz7gU/Ejpq T7Q4ltIiiI7tZ+HMAuSIAZwUxnXrvBYEQt5p6BxOT66VvuERiNX1+4G7Jz/iyLLGjv35 fkiwEoUVuTIy+xLkZSJBE7luOqwbfNuXVc/0E57ZUW+oRbo5geRe0QPOgX1koDBVMnfs UpxDURXMJoHtaV1kPIdRhmJX31wrtY+KTzIhFRM2XduWIBVtDfLGsZE3yyxiKdMhFvYY y7IJ/wPUh7oYU2OVey/ZgjkXVC2JRQWy3xgg2vnykYtccVHHDa0ExrJSTnnMDaKA/Bm3 b7cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796002419; x=1796607219; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=C2f5Xm4Eq2UOJ7X6ZQmE+0ZIf6PdeT+Xfv3UXkcG0Tg=; b=XnJsGPMmX3qaQxpil+kpiEfQbvg3XTOZiOJrvBMHD8OiCqJ5582ipqO9rwedsiS6kw GufnpOLTZlU1s8aahjQRsOhwYpqMiOQRscUNRTGPW/tlQ3vlV+E+p3E/OCxZY/uiCWyD 8qC7/Vfk8qgW8YE45qKxwAMBc/QhFd7TsPjUBIHafmQoJA/YVyc/9ebfuujwfL5R3OIU ldfiHMZv6jR+wLS9MK2QJs/8/hnkwZAx+Gca0iT+/m40dziX3DZe68Ahyida24cR1WB1 NMPpebW+nBj2svZ8s8cqomZBldLw/SdDj3G6TaUlao2ci2yHLEOxuhWGdkbbnCTwp+uA 6j/Q== X-Gm-Message-State: APuU4Z/vqujVVOpCcBIBCKUwRFnkQ+ifuOdXd7FH8ejAmvB8RNXscPLS y6mHUSahOGGsMSS6uNZ57tG3O/2MO11lzcJ/UHpOlbQbA5B1MMbIfi7Fl3f+jI0zaHxf/YYJXI5 LKYPIbLuVjA== X-Received: from ywjj2-n1.prod.google.com ([2002:a05:690c:a082:10b0:8b4:e03d:7895]) (user=jmoroni job=prod-delivery.src-stubby-dispatcher) by 2002:a05:690c:a08e:10b0:8b3:90db:a83c with SMTP id 00721157ae682-8b52043c59bmr87205157b3.35.1796002419464; Sun, 29 Nov 2026 17:33:39 -0800 (PST) Date: Mon, 30 Nov 2026 01:33:07 +0000 In-Reply-To: <20261130013307.2848330-1-jmoroni@google.com> X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261130013307.2848330-1-jmoroni@google.com> X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog Message-ID: <20261130013307.2848330-9-jmoroni@google.com> Subject: [PATCH rdma-next 8/8] RDMA/irdma: Fix MPA v2 private data length handling From: Jacob Moroni To: tatyana.e.nikolova@intel.com, jgg@ziepe.ca, leon@kernel.org Cc: linux-rdma@vger.kernel.org, jdz@google.com, Jacob Moroni Content-Type: text/plain; charset="UTF-8" For MPA v2, the private data length in the frame includes the 4 byte RTR message that precedes the private data. irdma_build_mpa_v2() sets it up this way, but irdma_parse_mpa() treats the entire length as private data. The issue is that a v2 frame with a length below 4 passes the length check without containing a full RTR message, so the RTR message is read from past the end of the received data. For a valid v2 frame, the private data copy reads 4 bytes past the end of the received data and hands them to the application. Fix this by rejecting v2 frames with a private data length below 4 and by excluding the RTR message from the private data. Note that the private data length reported to the application is now the length that the peer actually sent. Tested on an E830 in iWARP mode with a small program that connects over loopback with known private data in both directions (verified with 0 bytes and 16 bytes). The private data now matches what was sent and MPA v2 is still negotiated. Fixes: 146b9756f14c ("RDMA/irdma: Add connection manager") Signed-off-by: Jacob Moroni --- drivers/infiniband/hw/irdma/cm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/infiniband/hw/irdma/cm.c b/drivers/infiniband/hw/irdma/cm.c index b3394f084098..d39e0e174fbf 100644 --- a/drivers/infiniband/hw/irdma/cm.c +++ b/drivers/infiniband/hw/irdma/cm.c @@ -1112,6 +1112,12 @@ static int irdma_parse_mpa(struct irdma_cm_node *cm_node, u8 *buf, u32 *type, switch (mpa_frame->rev) { case IETF_MPA_V2: + /* The private data length of a v2 frame includes the RTR + * message, which is not private data. + */ + if (priv_data_len < IETF_RTR_MSG_SIZE) + return -EINVAL; + priv_data_len -= IETF_RTR_MSG_SIZE; mpa_hdr_len += IETF_RTR_MSG_SIZE; ret = irdma_negotiate_mpa_v2_ird_ord(cm_node, buf); if (ret) -- 2.56.1.839.g22a8290db9-goog